o
    i e!
                     @   sF   d Z ddlZddlZddlm  mZ ddlmZ dd Z	dd Z
dS )z5Saving utilities to support Python's Pickle protocol.    N)
saving_libc              
   C   s   t  }zCz*tj|d}t|d}||  W d   n1 s"w   Y  tj|dd}W n t	y= } z|d}~ww |W t
jj| S t
jj| w )zReconstruct a Model from the output of `serialize_model_as_bytecode`.

    Args:
        serialized_model: (bytes) return value from
          `serialize_model_as_bytecode`.

    Returns:
        Keras Model instance.
    model.keraswbNF)	safe_mode)tempfilemkdtempospathjoinopenwriter   
load_model	Exceptiontfiogfilermtree)serialized_modeltemp_dirfilepathfmodele r   L/var/www/myenv/lib/python3.10/site-packages/keras/src/saving/pickle_utils.pydeserialize_model_from_bytecode   s    r   c              
   C   s   t  }zAz(tj|d}t| | t|d}| }W d   n1 s'w   Y  W n t	y; } z|d}~ww |W t
jj| S t
jj| w )zConvert a Keras Model into a bytecode representation for pickling.

    Args:
        model: Keras Model instance.

    Returns:
        Tuple that can be read by `deserialize_from_bytecode`.
    r   rbN)r   r   r   r	   r
   r   
save_modelr   readr   r   r   r   r   )r   r   r   r   datar   r   r   r   serialize_model_as_bytecode7   s   
 r    )__doc__r   r   tensorflow.compat.v2compatv2r   keras.src.savingr   r   r    r   r   r   r   <module>   s   