o
    2hp                     @   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base_cls g/var/www/html/chatgem/venv/lib/python3.10/site-packages/tensorflow/python/keras/layers/serialization.py<lambda>D       z1populate_deserializable_objects.<locals>.<lambda>)
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   GENERATED_WITH_V2r   enabledr   Layerr   !populate_dict_with_module_objectsALL_MODULESALL_V2_MODULEStensorflow.python.kerasr#   r   r$   r   r%   r&   r'   r(   r   r)   r*   r+   r,   r-   r.   r/   r0   r"   r   r   r   populate_deserializable_objects0   sB   



r:   c                 C   s
   t | S r   )r   serialize_keras_object)layerr   r   r   	serializea   s   
r=   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...)
  r<   )module_objectscustom_objectsprintable_module_name)r:   r   deserialize_keras_objectr2   r   )configr?   r   r   r   deserializee   s   rC   r   )__doc__	threadingtensorflow.pythonr   tensorflow.python.keras.enginer   r   r   tensorflow.python.keras.layersr   r   r   r	   r
   r   r   r   r   r   tensorflow.python.keras.utilsr   r   r   r7   r8   localr2   r:   r=   rC   r   r   r   r   <module>   s6   1