
    ijp                     p    d dl Z d dlZd dlZd dlZd dlZd Zd Zd Zd Z	ddZ
d Zd Zd	 Zd
 Zd Zd Zy)    Nc                      t         t              st               dk  ry d    d   z
  dvryt         fdt	        t               dz
        D              S )N   Tr   )r   Fc              3   @   K   | ]  }|d z      |   z
  k(    yw)r   N ).0iaxissteps     q/var/www/html/emotional.easysim.app/public_html/venv/lib/python3.12/site-packages/keras/src/utils/python_utils.py	<genexpr>z%is_continuous_axis.<locals>.<genexpr>   s'     KtAE{T!W$,Ks   )
isinstanceintlenallrange)r
   r   s   `@r   is_continuous_axisr      sU    $D	Q7T!WD7KeCIM6JKKK    c                     d| _         | S )z5Decorates a method to detect overrides in subclasses.T)_is_defaultmethods    r   defaultr      s    FMr   c                     t        | dd      S )z:Check if a method is decorated with the `default` wrapper.r   F)getattrr   s    r   
is_defaultr      s    6=%00r   c                    t         j                  dk(  rUt        j                  | j                        j                  dd      }t        j                  |d      j                  d      }nDt        j                  | j                        }t        j                  |d      j                  d      }| j                  }| j                  rt        d | j                  D              }nd}|||fS )zSerializes a user-defined function.

    Args:
        func: the function to serialize.

    Returns:
        A tuple `(code, defaults, closure)`.
    nt   \   /base64asciic              3   4   K   | ]  }|j                     y wN)cell_contents)r   cs     r   r   zfunc_dump.<locals>.<genexpr>0   s     BABs   N)osnamemarshaldumps__code__replacecodecsencodedecode__defaults____closure__tuple)funcraw_codecodedefaultsclosures        r   	func_dumpr8      s     
ww$==/77tD}}Xx077@==/}}Xx077@  HB1A1ABB7""r   c                    t        | t        t        f      r!| \  } }}t        |t              rt        |      }d |t        fd|D              }	 t        j                  | j                  d      d      }t        j                  |      } |
t               }t        j                  | || j                  ||      S # t        t        j                  f$ r | j                  d      }Y qw xY w)a	  Deserializes a user defined function.

    Args:
        code: bytecode of the function.
        defaults: defaults of the function.
        closure: closure of the function.
        globs: dictionary of global objects.

    Returns:
        A function object.
    c                 ^      fd}|j                   d   }t         t        |            s|S  S )zEnsures that a value is converted to a python cell object.

        Args:
            value: Any value that needs to be casted to the cell type

        Returns:
            A value wrapped as a cell object (see function "func_load")
        c                  
      y r$   r   )values   r   dummy_fnz9func_load.<locals>.ensure_value_to_cell.<locals>.dummy_fnQ   s    r   r   )r1   r   type)r<   r=   
cell_values   `  r   ensure_value_to_cellz'func_load.<locals>.ensure_value_to_cellG   s4    	 ))!,
%j!12r   c              3   .   K   | ]  } |        y wr$   r   )r   _r@   s     r   r   zfunc_load.<locals>.<genexpr>Z   s     AA,Q/As   r"   r!   raw_unicode_escape)r(   argdefsr7   )r   r2   listr-   r/   r.   UnicodeEncodeErrorbinasciiErrorr)   loadsglobalspython_typesFunctionTypeco_name)r5   r6   r7   globsr4   r@   s        @r   	func_loadrO   6   s     $&"&hh%XH$ AAA5==W!5x@ =="D}	$$e$,,'  / 5;;345s   %B= =*C*)C*c                 ,    t        | t              r| S | gS )zNormalizes a list/tensor into a list.

    If a tensor is passed, we return
    a list of size 1 containing the tensor.

    Args:
        x: target object to be normalized.

    Returns:
        A list.
    )r   rE   )xs    r   to_listrR   g   s     !T3Jr   c                     g g }}t        ||      D ]6  \  }}t        |      | k  s|j                  |       |j                  |       8 ||fS )aC  Removes sequences that exceed the maximum length.

    Args:
        maxlen: Int, maximum length of the output sequences.
        seq: List of lists, where each sublist is a sequence.
        label: List where each element is an integer.

    Returns:
        new_seq, new_label: shortened lists for `seq` and `label`.
    )zipr   append)maxlenseqlabelnew_seq	new_labelrQ   ys          r   remove_long_seqr\   x   sX     RYGC  1q6F?NN1Q  Ir   c                 `    t        |      dkD  r| j                  |      r| t        |      d S | S )z5Backport of `removeprefix` from PEP-616 (Python 3.9+)r   N)r   
startswith)rQ   prefixs     r   removeprefixr`      s0     6{Q1<</Vr   c                 b    t        |      dkD  r | j                  |      r| dt        |        S | S )z5Backport of `removesuffix` from PEP-616 (Python 3.9+)r   N)r   endswith)rQ   suffixs     r   removesuffixrd      s2     6{Q1::f-CK<  r   c                 b    t        |       D ]!  \  }}t        |      t        |      k(  s| |=  y y)z!Remove a value from a list by id.N)	enumerateid)lstr<   r	   vs       r   remove_by_idrj      s3    # 1a5BuIAr   c                 .   ddl m} | xs i } i }t        | j                               D ]c  \  }}t	        |t
              r|j                  t        |             1	 |j                  |      r|j                  |      }t        |      }|||<   e |S #  Y xY w)aI  Flatten and convert log values to Python-native types.

    This function attempts to convert dict value by `float(value)` and skips
    the conversion if it fails.

    Args:
        logs: A dict containing log values.

    Returns:
        A flattened dict with values converted to Python-native types if
        possible.
    r   )backend)	keras.srcrl   sorteditemsr   dictupdatepythonify_logs	is_tensorconvert_to_numpyfloat)logsrl   resultkeyr<   s        r   rr   rr      s     ":2DFTZZ\*  
UeT"MM./0$$U+#44U;Ee  F3K  Ms   -BB)NNN)rG   r-   r)   r'   typesrK   r   r   r   r8   rO   rR   r\   r`   rd   rj   rr   r   r   r   <module>rz      sM       	 	L1
#..b"&r   