
    &Vf                     f    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dZ	d Z
d Zd Zd	 Zd
 ZdS )    Nc                     d| _         | S )z5Decorates a method to detect overrides in subclasses.T)_is_defaultmethods    Y/var/www/html/software/conda/lib/python3.11/site-packages/keras/src/utils/python_utils.pydefaultr      s    FM    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00r	   c                    t           j        dk    rVt          j        | j                                      dd          }t          j        |d                              d          }nAt          j        | j                  }t          j        |d                              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   $   K   | ]}|j         V  d S N)cell_contents).0cs     r   	<genexpr>zfunc_dump.<locals>.<genexpr>$   s$      BBABBBBBBr	   N)osnamemarshaldumps__code__replacecodecsencodedecode__defaults____closure__tuple)funcraw_codecodedefaultsclosures        r   	func_dumpr*      s     
w$=//77tDD}Xx0077@@=//}Xx0077@@ H BB1ABBBBB7""r	   c                 
   t          | t          t          f          r*| \  } }}t          |t                    rt          |          }d |t          fd|D                       }	 t          j        |                     d          d          }n1# t          t          j        f$ r |                     d          }Y nw xY wt          j
        |          } |t                      }t          j        | || j        ||          S )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                 j      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                        d S r    )values   r   dummy_fnz9func_load.<locals>.ensure_value_to_cell.<locals>.dummy_fnE   s    EEEr	   r   )r#   
isinstancetype)r/   r0   
cell_values   `  r   ensure_value_to_cellz'func_load.<locals>.ensure_value_to_cell;   sP    	 	 	 	 	 )!,
%j!1!122 	r	   Nc              3   .   K   | ]} |          V  d S r   r.   )r   _r4   s     r   r   zfunc_load.<locals>.<genexpr>N   s/      AAA,,Q//AAAAAAr	   r   r   raw_unicode_escape)r   argdefsr)   )r1   r$   listr   r!   r    UnicodeEncodeErrorbinasciiErrorr   loadsglobalspython_typesFunctionTypeco_name)r'   r(   r)   globsr&   r4   s        @r   	func_loadrC   *   s    $&& '"&hh%% 	'XH  $ AAAAAAAAA5=W!5!5x@@/ 5 5 5;;3445=""D}		$e$,'   s   )(B +C ?C c                 6    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.
    )r1   r9   )xs    r   to_listrF   [   s"     !T 3Jr	   c                     g g }}t          ||          D ]B\  }}t          |          | k     r*|                    |           |                    |           C||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`.
    )ziplenappend)maxlenseqlabelnew_seq	new_labelrE   ys          r   remove_long_seqrQ   l   si     RYGC    1q66F??NN1QIr	   c                     t          |          dk    r,|                     |          r| t          |          d         S | S )z5Backport of `removeprefix` from PEP-616 (Python 3.9+)r   N)rI   
startswith)rE   prefixs     r   removeprefixrU      s=     6{{Q1<<//Vr	   c                     t          |          dk    r-|                     |          r| dt          |                    S | S )z5Backport of `removesuffix` from PEP-616 (Python 3.9+)r   N)rI   endswith)rE   suffixs     r   removesuffixrY      s?     6{{Q1::f--CKK<  r	   c                 |    t          |           D ]+\  }}t          |          t          |          k    r| |=  dS ,dS )z!Remove a value from a list by id.N)	enumerateid)lstr/   ivs       r   remove_by_idr`      sO    #  1a55BuIIAFF  r	   )NNN)r;   r   r   r   typesr?   r   r   r*   rC   rF   rQ   rU   rY   r`   r.   r	   r   <module>rb      s       				      1 1 1
# # #.. . . .b  "  &        r	   