o
    ?ep                     @   s  d Z ddlZddlmZ ddlmZ ddlmZ ddlmZ ddlm	Z	 ddlm
Z
 dd	lmZ dd
lmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ eee	e
eeeeeeefZefZe add Zdd ZdddZdS )z/Layer serialization/deserialization functions.
    N)tf2)
base_layer)input_layer)
input_spec)advanced_activations)convolutional)convolutional_recurrent)core)dense_attention)
embeddings)merge)pooling)	recurrent)rnn_cell_wrapper_v2)generic_utils)
tf_inspectc                     s,  t tdsi t_dt_tjrtjt krdS i t_t t_tj tj	tjt
 fddd t r@tj	tjt fddd ddlm}  tjtjd	< tjtjd
< | jtjd< | jtjd< | jtjd< tjtjd< tjtjd< tjtjd< tjtjd< tjtjd< tjtjd< tjtjd< tjtjd< dS )z8Populates dict ALL_OBJECTS with every built-in layer.
  ALL_OBJECTSNc                       t | o	t|  S Ninspectisclass
issubclassxZbase_cls m/home/www/facesmatcher.com/pyenv/lib/python3.10/site-packages/tensorflow/python/keras/layers/serialization.py<lambda>D       z1populate_deserializable_objects.<locals>.<lambda>)Z
obj_filterc                    r   r   r   r   r   r   r   r   K   r   r   modelsInput	InputSpec
FunctionalModel
Sequentialaddsubtractmultiplyaveragemaximumminimumconcatenatedot)hasattrLOCALr   ZGENERATED_WITH_V2r   enabledr   ZLayerr   Z!populate_dict_with_module_objectsALL_MODULESALL_V2_MODULESZtensorflow.python.kerasr!   r   r"   r   r#   r$   r%   r&   r   r'   r(   r)   r*   r+   r,   r-   r.   r    r   r   r   populate_deserializable_objects0   sB   



r4   c                 C   s
   t | S r   )r   Zserialize_keras_object)layerr   r   r   	serializea   s   
r6   c                 C   s   t   tj| tj|ddS )aJ  Instantiates a layer from a config dictionary.

  Args:
      config: dict of the form {'class_name': str, 'config': dict}
      custom_objects: dict mapping class names (or function names)
          of custom (non-Keras) objects to class/functions

  Returns:
      Layer instance (may be Model, Sequential, Network, Layer...)
  r5   )Zmodule_objectscustom_objectsZprintable_module_name)r4   r   Zdeserialize_keras_objectr0   r   )configr7   r   r   r   deserializee   s   r9   r   )__doc__	threadingZtensorflow.pythonr   Ztensorflow.python.keras.enginer   r   r   Ztensorflow.python.keras.layersr   r   r   r	   r
   r   r   r   r   r   Ztensorflow.python.keras.utilsr   r   r   r2   r3   localr0   r4   r6   r9   r   r   r   r   <module>   s6   1