
    3j                    0    S SK Jr  SSKJr  SS jrSS jrg)	    )annotations   )	StateDictc           	        ^ [        U 5      S:  ad  U H^  m[        U4S jU R                  5        5       5      (       d  M-  U R                  5        VVs0 s H  u  p#U[        T5      S  U_M     n nnM`     U $ s  snnf )Nr   c              3  D   >#    U  H  oR                  T5      v   M     g 7f)N)
startswith).0iprefixs     Y/home/wildlama/miniconda3/lib/python3.13/site-packages/spandrel/__helpers/canonicalize.py	<genexpr>'remove_common_prefix.<locals>.<genexpr>	   s     C1BA<<''1Bs    )lenallkeysitems)
state_dictprefixeskvr   s       @r   remove_common_prefixr      sr    
:FC1BCCC>H>N>N>PQ>PdaaF.1>P
Q
   Rs   A7c                   / SQnU H'  nX ;   d  M
  [        X   [        5      (       d  M#  X   n   O   [        U 5      S:X  a9  [        [	        U R                  5       5      5      n[        U[        5      (       a  Un [        U SS/5      n U $ )z
Canonicalize a state dict.

This function is used to canonicalize a state dict, so that it can be
used for architecture detection and loading.

This function is not intended to be used in production code.
)model_state_dictr   
params_emaz
params-emaparamsmodelnetr   zmodule.znetG.)
isinstancedictr   nextitervaluesr   )r   unwrap_keys
unwrap_keysingles       r   canonicalize_state_dictr&      s    K "
#
:3I4(P(P#/J " :!d:,,./0fd##J &j9g2FGJ    N)r   r   r   z	list[str]returnr   )r   r   r(   r   )
__future__r   model_descriptorr   r   r&    r'   r   <module>r,      s    " '"r'   