
    &Vfj                     j    d dl mZ d Zd ZddZd Zd Zd Zdd	ZddZ		 ddZ
d Zd Zd Zd Zd
S )    )dmtreec                     | S N )clss    W/var/www/html/software/conda/lib/python3.11/site-packages/keras/src/tree/dmtree_impl.pyregister_tree_node_classr	      s    J    c                 .    t          j        |            d S r   )r   	is_nested	structures    r   r   r      s    
Yr
   Tc                 0    t          j        | ||          S )N)top_down)r   traverse)funcr   r   s      r   r   r      s    ?4X>>>>r
   c                 *    t          j        |           S r   )r   flattenr   s    r   r   r      s    >)$$$r
   c                 &    t          j        | g|R  S r   )r   map_structure)r   
structuress     r   r   r      s    2z2222r
   c                 (    t          j        | |g|R  S r   )r   map_structure_up_to)shallow_structurer   r   s      r   r   r      s    %&7K
KKKKr
   c                 0    t          j        | ||          S )N)check_types)r   assert_same_structure)abr   s      r   r   r      s    '1+FFFFr
   Nc                 D   t           j        }|pt           j        }d } ||          s:t          d                     ||d          t          |                               ||           s|t          |          dk    rat          d                    t          |            || d          t          |          t          |           ||d                              |d         S 	 t          | |d||          \  }}|t          |          k     rt          nz# t          $ rm t          j
        |           }t          |          t          |          k    r6t          dt          |           dt          |           d	|  d
| d	          Y nw xY w || |          S )Nc                 N    t          |           }|d |         ||d          odz   S )Nz...)str)valuelength	value_strs      r   truncatez"pack_sequence_as.<locals>.truncate$   s/    JJ	&!Yvww%7%AEBBr
   zYAttempted to pack value:
  {}
into a structure, but found incompatible type `{}` instead.d      zThe target structure is of type `{}`
  {}
However the input is a sequence ({}) of length {}.
  {}
nest cannot guarantee that it is safe to map one to the other.r   z'Could not pack sequence. Structure had z atoms, but flat_sequence had z items. Structure: z, flat_sequence: .)r   r   _sequence_like	TypeErrorformattypelen
ValueErrorpacked_nest_with_indices
IndexErrorr   )r   flat_sequencesequence_fnis_nested_fnr&   final_indexpackedflat_structures           r   pack_sequence_asr8       s*   #L6!6KC C C <&& 
..4f,,d=.A.A/ /
 
 	
 <	""  }""EEKVOOHY,,''&&H]C00F F
 
 
 Q6}a{
 
V ]++++ , 	 	 		22~#m"4"444K!$^!4!4K K%(%7%7K K (K K ;HK K K   54	 ;y&)))s   +0D A4FFc                    g }|pt           j        }t          |           D ]e} ||          r8t          |||||          \  }}|                     |||                     |}E|                    ||                    |dz  }f||fS )a  Helper function for pack_sequence_as.

    Args:
        structure: structure to mimic.
        flat: Flattened values to output substructure for.
        index: Index at which to start reading from flat.
        is_nested_fn: Function used to test if a value should
            be treated as a nested structure.
        sequence_fn: Function used to generate a new structure instance.

    Returns:
        The tuple (new_index, child), where:
        * new_index - the updated index into `flat`
            having processed `structure`.
        * packed - the subset of `flat` corresponding to `structure`,
            having started at `index`, and packed into the same nested
            format.
    r(   )r   r*   yield_valuer0   append)	r   flatindexr4   r3   r6   s	new_indexchilds	            r   r0   r0   R   s    * F6!6K## 	 	<?? 	74k   Iu MM++a//000EEMM$u+&&&QJEE&=r
   c              #   F   K   t          j        |           D ]	\  }}|V  
d S r   )r   _yield_sorted_items)iterable_vs      r   r:   r:   v   s9      *844  1 r
   c                 P    d }t          | t          j        |           |          S )Nc                 t    t          | t                    rt          |          S t          j        | |          S r   )
isinstancelisttupler   r*   )instanceargss     r   r3   z$lists_to_tuples.<locals>.sequence_fn|   s3    h%% 	;;$Xt444r
   )r3   )r8   r   r   )r   r3   s     r   lists_to_tuplesrM   {   s=    5 5 5
 y!!   r
   c                 t    t          | t          t          f          rt          d | D                       rdS dS )Nc              3   ^   K   | ](}t          |t          t          d           f          V  )d S r   )rH   intr-   ).0es     r   	<genexpr>z!is_shape_tuple.<locals>.<genexpr>   s7      ;;Az!c4::.//;;;;;;r
   TF)rH   rI   rJ   all)xs    r   is_shape_tuplerV      sA    !dE]## ;;;;;;; 	45r
   c                     t          |          r  t          |                    S t          |t                    r fd|D             S t          |t                    rt           fd|D                       S t          |t                    r  fd|                                D             S t          d|           )Nc                 0    g | ]}t          |          S r   map_shape_structurerQ   rR   r   s     r   
<listcomp>z'map_shape_structure.<locals>.<listcomp>   s$    @@@#D!,,@@@r
   c              3   8   K   | ]}t          |          V  d S r   rY   r[   s     r   rS   z&map_shape_structure.<locals>.<genexpr>   s.      EEa(q11EEEEEEr
   c                 8    i | ]\  }}|t          |          S r   rY   )rQ   krE   r   s      r   
<dictcomp>z'map_shape_structure.<locals>.<dictcomp>   s*    NNNDAq&tQ//NNNr
   z&Cannot map function to unknown object )rV   rJ   rH   rI   dictitemsr/   )r   r   s   ` r   rZ   rZ      s    i   &tE)$$%%%)T"" A@@@@i@@@@)U## FEEEE9EEEEEE)T"" ONNNNIOO<M<MNNNNM)MMNNNr
   )Tr   )keras.src.utils.module_utilsr   r	   r   r   r   r   r   r   r8   r0   r:   rM   rV   rZ   r   r
   r   <module>rd      s   / / / / / /       ? ? ? ?% % %3 3 3L L LG G G G/* /* /* /*f 7;! ! ! !H  

 
 
  
O 
O 
O 
O 
Or
   