
    JTh
                         S SK r S SKJr  S SKJr  S/rSS jr\" SS5      r\" SS	5      r\" S
S5      r	\" SS5      r
S rS\\   S\\   S\\   4S jrS\\\4   S\SS4S jrg)    N)repeat)Any'consume_prefix_in_state_dict_if_presentc                     ^  U 4S jnXl         U$ )Nc                    > [        U [        R                  R                  5      (       a  [	        U 5      $ [	        [        U T5      5      $ N)
isinstancecollectionsabcIterabletupler   )xns    N/var/www/auris/envauris/lib/python3.13/site-packages/torch/nn/modules/utils.pyparse_ntuple.<locals>.parse   s4    a11228OVAq\""    )__name__)r   namer   s   `  r   _ntupler   
   s    #
 NLr      _single   _pair   _triple   
_quadruplec                 @   ^ [        U4S j[        U 5       5       5      $ )zReverse the order of `t` and repeat each element for `n` times.

This can be used to translate padding arg used by Conv and Pooling modules
to the ones used by `F.pad`.
c              3   L   >#    U  H  n[        T5        H  o!v   M     M     g 7fr   )range).0r   _r   s      r   	<genexpr>(_reverse_repeat_tuple.<locals>.<genexpr>    s     :KqqAKs   !$)r   reversed)tr   s    `r   _reverse_repeat_tupler(      s     :HQK:::r   out_sizedefaultsreturnc                 $   SS K n[        U [        UR                  45      (       a  U $ [	        U5      [	        U 5      ::  a  [        S[	        U 5      S-    35      e[        X[	        U 5      * S  5       VVs/ s H  u  p4Ub  UOUPM     snn$ s  snnf )Nr   z#Input dimension should be at least r   )torchr	   intSymIntlen
ValueErrorzip)r)   r*   r-   vds        r   _list_with_defaultr5   #   s    (S%,,/00
8}H%>s8}q?P>QRSS.1(c(m^EU<V.W.WdaQ]!.W  s   5B
state_dictprefixc                    [        U R                  5       5      nU H<  nUR                  U5      (       d  M  U[        U5      S nU R	                  U5      X'   M>     [        U S5      (       a  [        U R                  R                  5       5      nU Hw  n[        U5      S:X  a  M  X1R                  SS5      :X  d  UR                  U5      (       d  MA  U[        U5      S nU R                  R	                  U5      U R                  U'   My     gg)ax  Strip the prefix in state_dict in place, if any.

.. note::
    Given a `state_dict` from a DP/DDP model, a local model can load it by applying
    `consume_prefix_in_state_dict_if_present(state_dict, "module.")` before calling
    :meth:`torch.nn.Module.load_state_dict`.

Args:
    state_dict (OrderedDict): a state-dict to be loaded to the model.
    prefix (str): prefix.
N	_metadatar   . )listkeys
startswithr0   pophasattrr9   replace)r6   r7   r=   keynewkeys        r   r   r   /   s     
!"D>>&!!V'F!+!4J  z;''J((--/0C
 3x1}nnS"--1G1GS[]+/9/C/C/G/G/L
$$V,  (r   )r   )r
   	itertoolsr   typingr   __all__r   r   r   r   r   r(   r<   r.   r5   dictstrr    r   r   <module>rJ      s       5
5 !Y
7
!Y
Q%
;	c 	d3i 	DI 	"MS#X"M"M 
"Mr   