Ë
    ÿÍ:jO0  ã                   óš  — d Z ddlZddlZddlZddlZddlmZmZ ddlm	Z	m
Z
 ddlmZmZmZmZ ddlmZ ddlZddlmZ ddlmZ d	ed
efd„Zded
dfd„Zded
eeee   ee   f   fd„Z dejB                  d
e"eef   fd„Z#dejB                  d
eee   e"eef   f   fd„Z$	 	 d(dejB                  de%e"eef      dedeedf   d
e%e"eef      f
d„Z&ddddœd	ededeeee   ef      deejB                     dee"eef      d
dfd„Z' G d„ de«      Zdd d!ed
e%e   fd"„Z(dd d!ed
ee   fd#„Z)dd d!ed
efd$„Z*dd d!ed
ee   fd%„Z+dd d!ed&ed
dfd'„Z,y))z%Utilities used for parameter parsing.é    N)ÚMutableMappingÚSequence)ÚfieldsÚis_dataclass)ÚAnyÚLiteralÚOptionalÚUnion)Únn)ÚAttributeDict)Úrank_zero_warnÚobjÚreturnc                 ó‚   — 	 t        j                  | «       y# t         j                  t        t        t
        f$ r Y yw xY w)z"Tests if an object can be pickled.TF)ÚpickleÚdumpsÚPickleErrorÚAttributeErrorÚRuntimeErrorÚ	TypeError)r   s    úx/home/mcse/projects/srt_converter/srt-converter-venv/lib/python3.12/site-packages/pytorch_lightning/utilities/parsing.pyÚis_picklabler      s7   € ðÜ�‰�SÔØøÜ×Ñ¤´¼iÐHò Ùðús   ‚ ˜#>½>Úhparamsc                 ó¤   — | j                  «       D ��cg c]  \  }}t        |«      rŒ|‘Œ }}}|D ]  }t        d|› d|› d�«       | |= Œ yc c}}w )z-Removes all unpicklable entries from hparams.zAttribute 'z‚' removed from hparams because it cannot be pickled. You can suppress this warning by setting `self.save_hyperparameters(ignore=['z'])`.N)Úitemsr   r   )r   ÚkÚvÚ	del_attrss       r   Úclean_namespacer   (   sd   € à&Ÿ}™}›×F‘t�q˜!´lÀ1µo’ÐF€IÑFàò ˆÜØ˜!˜ð <Ø<=¸3¸eðEô	
ð �A‰Jñùó Gs
   ”A¨AÚclsc                 óø  — t        j                  | j                  «      j                  }t	        |j                  «       «      }|d   j                  }dt        t         j                     dt        t         j                  j                  t         j                  j                  f   dt        t           fd„} ||t         j                  j                  «      } ||t         j                  j                  «      }|||fS )a*  Parse key words for standard ``self``, ``*args`` and ``**kwargs``.

    Examples:

        >>> class Model:
        ...     def __init__(self, hparams, *my_args, anykw=42, **my_kwargs):
        ...         pass
        >>> parse_class_init_keys(Model)
        ('self', 'my_args', 'my_kwargs')

    r   ÚparamsÚ
param_typer   c                 óL   — | D ]  }|j                   |k(  sŒ|j                  c S  y )N)ÚkindÚname)r"   r#   Úps      r   Ú_get_first_if_anyz0parse_class_init_keys.<locals>._get_first_if_anyG   s-   € ð ò 	ˆAØ�v‰v˜Ó#Ø—v‘v’ð	ð ó    )ÚinspectÚ	signatureÚ__init__Ú
parametersÚlistÚvaluesr&   Ú	Parameterr   Ú_ParameterKindÚVAR_POSITIONALÚVAR_KEYWORDr	   Ústr)r    Úinit_parametersÚinit_paramsÚn_selfr(   Ún_argsÚn_kwargss          r   Úparse_class_init_keysr:   4   sÑ   € ô ×'Ñ'¨¯©Ó5×@Ñ@€Oô �×-Ñ-Ó/Ó0€Kà˜‰^× Ñ €FðÜ”W×&Ñ&Ñ'ðäœG×2Ñ2×AÑAÄ7×CYÑCY×CeÑCeÐeÑfðô 
”#‰óñ ˜{¬G×,=Ñ,=×,LÑ,LÓM€FÙ  ¬g×.?Ñ.?×.KÑ.KÓL€Hà�6˜8Ð#Ð#r)   Úframec                 ó"   — t        | «      \  }}|S )z$For backwards compatibility: #16369.)Ú_get_init_args)r;   Ú_Ú
local_argss      r   Úget_init_argsr@   V   s   € ä" 5Ó)�M€A€zØÐr)   c                 ó:  — t        j                  | «      \  }}}}d|vs| j                  j                  dk7  rd i fS |d   }t        j                  |j
                  «      j                  }t        |«      \  }}}|||fD �cg c]  }|sŒ|‘Œ	 }	}g |	¢d‘d‘d‘­}
|D �ci c]  }|||   “Œ
 }}|r!|j                  |j                  |i «      «       |j                  «       D ��ci c]  \  }}||
vsŒ||“Œ }}}|j                  |d «      }||fS c c}w c c}w c c}}w )NÚ	__class__r,   r;   Ú
frame_args)r*   ÚgetargvaluesÚf_codeÚco_namer+   r,   r-   r:   ÚupdateÚgetr   )r;   r>   Ú
local_varsr    r5   Úself_varÚargs_varÚ
kwargs_varÚnÚfiltered_varsÚexclude_argnamesr   r?   r   Úself_args                  r   r=   r=   \   s8  € Ü!×.Ñ.¨uÓ5Ñ€A€qˆ!ˆZØ˜*Ñ$¨¯©×(<Ñ(<À
Ò(JØ�RˆxˆØ
�[Ñ
!€CÜ×'Ñ'¨¯©Ó5×@Ñ@€OÜ%:¸3Ó%?Ñ"€Hˆh˜
Ø!)¨8°ZÐ @ÖF˜1ÂA’QÐF€MÐFØK˜ÐK¨ÐK°WÐK¸lÑKÐà,;Ö< q�!�Z ‘]Ñ"Ð<€JÐ<áØ×Ñ˜*Ÿ.™.¨°RÓ8Ô9Ø#-×#3Ñ#3Ó#5×S™4˜1˜a¸ÐBRÒ9R�!�Q‘$ÐS€JÑSØ�~‰~˜h¨Ó-€HØ�ZÐÐùò Gùò =ùó Ts   Â DÂDÂDÃ"DÃ/DÚ	path_argsÚinsideÚclasses.c                 óP  — t        j                  | «      \  }}}}t        | j                  t        j
                  «      s|S t        | «      \  }}d|v r8|rt        ||«      r*|j                  |«       t        | j                  |d|¬«      S |st        | j                  |d|¬«      S |S )a|  Recursively collects the arguments passed to the child constructors in the inheritance tree.

    Args:
        frame: the current stack frame
        path_args: a list of dictionaries containing the constructor args in all parent classes
        inside: track if we are inside inheritance path, avoid terminating too soon
        classes: the classes in which to inspect the frames

    Return:
          A list of dictionaries where each dictionary contains the arguments passed to the
          constructor at that level. The last entry corresponds to the constructor call of the
          most specific class in the hierarchy.

    rB   T)rR   rS   F)	r*   rD   Ú
isinstanceÚf_backÚtypesÚ	FrameTyper=   ÚappendÚcollect_init_args)r;   rQ   rR   rS   r>   rI   Ú
local_selfr?   s           r   rZ   rZ   o   s™   € ô( "×.Ñ.¨uÓ5Ñ€A€qˆ!ˆZä�e—l‘l¤E§O¡OÔ4ØÐä+¨EÓ2Ñ€J�
Ø�jÑ ©'´ZÀ
ÈGÔ5Tà×Ñ˜Ô$Ü  §¡¨yÀÈwÔWÐWÙÜ  §¡¨yÀÐPWÔXÐXØÐr)   )Úignorer;   Úgiven_hparamsÚargsr\   r]   c                óÔ  — t        |«      dk(  rt        |t        «      s|d   sy|s"t        j                  «       }|r|j
                  }t        |t        j                  «      st        d«      ‚|�|}nt        | «      rGt        | «      }|D �ci c]0  }|j                  sŒ|j                  t        | |j                  «      “Œ2 }}n-i }ddlm}	 t!        |g |	f¬«      D ]  }
|j#                  |
«       Œ |€g }nJt        |t        «      r|g}n6t        |t$        t&        f«      r |D �cg c]  }t        |t        «      sŒ|‘Œ }}t%        t)        |«      «      }|j+                  «       D ��ci c]  \  }}||vsŒ||“Œ }}}|s|}|rdnd| _        n¦t/        |«      D ��cg c]  \  }}t        |t        «      rŒ|‘Œ }}}t        |«      dk(  r?||d      }|j+                  «       D ��cg c]  \  }}||k(  sŒ|‘Œ }}}|r|d   nd| _        n+|D �ci c]  }t        |t        «      sŒ|||   “Œ }}d| _        | j1                  |«       | j3                  |«       | j4                  j+                  «       D ]2  \  }}t        |t6        j8                  «      sŒ!t;        d|›d	|›d
�«       Œ4 t=        j>                  | j4                  «      | _         yc c}w c c}w c c}}w c c}}w c c}}w c c}w )zCSee :meth:`~pytorch_lightning.LightningModule.save_hyperparameters`é   r   Nz3There is no `frame` available while being required.)ÚHyperparametersMixin)rS   Úkwargsz
Attribute z” is an instance of `nn.Module` and is already saved during checkpointing. It is recommended to ignore them using `self.save_hyperparameters(ignore=[z])`.)!ÚlenrU   r4   r*   ÚcurrentframerV   rW   rX   r   r   r   Úinitr&   ÚgetattrÚpytorch_lightning.core.mixinsra   rZ   rG   r.   ÚtupleÚsetr   Ú_hparams_nameÚ	enumerateÚ_set_hparamsÚremove_ignored_hparamsÚ_hparamsr   ÚModuler   ÚcopyÚdeepcopyÚ_hparams_initial)r   r\   r;   r]   r^   Úcurrent_frameÚ	init_argsÚ
obj_fieldsÚfra   r?   Úargr   r   ÚhpÚiÚisx_non_strÚ
cand_namess                     r   Úsave_hyperparametersr|   ’   s¶  € ô ˆ4ƒy�A‚~œj¨¬sÔ3¸DÀºGàáÜ×,Ñ,Ó.ˆáØ!×(Ñ(ˆEÜ�eœUŸ_™_Ô-ÜÐRÓSÐSàÐ Ø!‰	Ü	�cÔ	Ü˜C“[ˆ
Ø;EÖP°aÈÏË�Q—V‘VœW S¨!¯&©&Ó1Ñ1ÐPˆ	ÑPàˆ	åFä+¨E°2Ð@TÐ?VÔWò 	)ˆJØ×Ñ˜ZÕ(ð	)ð €~Ø‰Ü	�FœCÔ	 Ø�‰Ü	�FœT¤5˜MÔ	*Ø!'Ö@˜#¬:°c¼3Õ+?’#Ð@ˆÐ@ä”#�f“+Ó€FØ"+§/¡/Ó"3×G™$˜!˜Q°qÀ²��A‘ÐG€IÑGáàˆÙ(*™H°ˆÕô (1°£×S™V˜Q ¼jÈÌcÕ>R’qÐSˆÑSÜˆ{Ó˜qÒ Ø�k !‘nÑ%ˆBØ(1¯©Ó(9×E¡  1¸QÀ"»Wš!ÐEˆJÑEÙ1; 
¨1¢ÀˆCÕà15ÖN¨#¼ÀCÌÕ9M�#�y ‘~Ñ%ÐNˆBÐNØ (ˆCÔð ×Ñ�RÔð ×Ñ˜vÔ&à—‘×"Ñ"Ó$ò ‰ˆˆ1Ü�aœŸ™Õ#ÜØ˜Q˜Eð "^Ø^_Ð]bÐbfðhõðô  Ÿ=™=¨¯©Ó6€CÕùòa Qùò Aùó Hùó Tùó Fùò OsH   ÂK	Â#K	Ä%KÄ;KÅ(KÅ5KÆKÆ4KÇ$KÇ2KÈK%È"K%c                   ó   — e Zd ZdZy)r   a0  Extended dictionary accessible with dot notation.

    >>> ad = AttributeDict({'key1': 1, 'key2': 'abc'})
    >>> ad.key1
    1
    >>> ad.update({'my-key': 3.14})
    >>> ad.update(new_key=42)
    >>> ad.key1 = 2
    >>> ad
    "key1":    2
    "key2":    abc
    "my-key":  3.14
    "new_key": 42

    N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__© r)   r   r   r   Þ   s   „ òr)   r   Úmodelzpl.LightningModuleÚ	attributec                 óê  — g }t        | |«      r|j                  | «       t        | d«      r)|| j                  v r|j                  | j                  «       | j                  }|��|j                  �„t        |j                  |«      r|j                  |j                  «       t        |j                  d«      r=||j                  j                  v r%|j                  |j                  j                  «       |S )zËSpecial attribute finding for Lightning.

    Gets all of the objects or dicts that holds attribute. Checks for attribute in model namespace, the old hparams
    namespace/dict, and the datamodule.

    r   )ÚhasattrrY   r   Ú_trainerÚ
datamodule)rƒ   r„   ÚholdersÚtrainers       r   Ú_lightning_get_all_attr_holdersr‹   ð   sÄ   € ð €Gô ˆu�iÔ Ø�‰�uÔô ˆu�iÔ  Y°%·-±-Ñ%?Ø�‰�u—}‘}Ô%à�n‰n€GàÐ˜w×1Ñ1Ð=Ü�7×%Ñ% yÔ1Ø�N‰N˜7×-Ñ-Ô.ä�7×%Ñ% yÔ1°iÀ7×CUÑCU×C]ÑC]Ñ6]Ø�N‰N˜7×-Ñ-×5Ñ5Ô6à€Nr)   c                 óB   — t        | |«      }t        |«      dk(  ry|d   S )zíSpecial attribute finding for Lightning.

    Gets the object or dict that holds attribute, or None. Checks for attribute in model namespace, the old hparams
    namespace/dict, and the datamodule, returns the last one that has it.

    r   Néÿÿÿÿ)r‹   rc   )rƒ   r„   r‰   s      r   Ú _lightning_get_first_attr_holderrŽ     s)   € ô .¨e°YÓ?€GÜ
ˆ7ƒ|�qÒØà�2‰;Ðr)   c                 ó   — t        | |«      duS )z†Special hasattr for Lightning.

    Checks for attribute in model namespace, the old hparams namespace/dict, and the datamodule.

    N)rŽ   )rƒ   r„   s     r   Úlightning_hasattrr�     s   € ô ,¨E°9Ó=ÀTÐIÐIr)   c                 ó|   — t        | |«      }|€t        |› d�«      ‚t        |t        «      r||   S t	        ||«      S )a5  Special getattr for Lightning. Checks for attribute in model namespace, the old hparams namespace/dict, and the
    datamodule.

    Raises:
        AttributeError:
            If ``model`` doesn't have ``attribute`` in any of
            model namespace, the hparams namespace/dict, and the datamodule.

    ú_ is neither stored in the model namespace nor the `hparams` namespace/dict, nor the datamodule.)rŽ   r   rU   Údictrf   )rƒ   r„   Úholders      r   Úlightning_getattrr•   $  sW   € ô .¨e°YÓ?€FØ€~ÜØˆkð Eð Eó
ð 	
ô
 �&œ$ÔØ�iÑ Ð Ü�6˜9Ó%Ð%r)   Úvaluec                 ó¨   — t        | |«      }t        |«      dk(  rt        |› d�«      ‚|D ]%  }t        |t        «      r|||<   Œt        |||«       Œ' y)a]  Special setattr for Lightning. Checks for attribute in model namespace and the old hparams namespace/dict. Will
    also set the attribute on datamodule, if it exists.

    Raises:
        AttributeError:
            If ``model`` doesn't have ``attribute`` in any of
            model namespace, the hparams namespace/dict, and the datamodule.

    r   r’   N)r‹   rc   r   rU   r“   Úsetattr)rƒ   r„   r–   r‰   r”   s        r   Úlightning_setattrr™   :  sk   € ô .¨e°YÓ?€GÜ
ˆ7ƒ|�qÒÜØˆkð Eð Eó
ð 	
ð
 ò .ˆÜ�fœdÔ#Ø %ˆF�9Òä�F˜I uÕ-ñ	.r)   )Fr‚   )-r�   rp   r*   r   rW   Úcollections.abcr   r   Údataclassesr   r   Útypingr   r   r	   r
   Útorchr   Úpytorch_lightningÚplÚlightning_fabric.utilities.datar   Ú_AttributeDictÚ%pytorch_lightning.utilities.rank_zeror   ÚobjectÚboolr   r   Útyperh   r4   r:   rX   r“   r@   r=   r.   rZ   r|   r‹   rŽ   r�   r•   r™   r‚   r)   r   ú<module>r¦      sU  ðñ ,ã Û Û Û ß 4ß ,ß 0Ó 0å ã Ý KÝ @ð�fð  ó ð	˜^ð 	°ó 	ð$˜tð $¨¨c°8¸C±=À(È3Á-Ð.OÑ(Pó $ðD˜Ÿ™ð ¨T°#°s°(©^ó ð ˜%Ÿ/™/ð  ¨e°H¸S±MÀ4ÈÈSÈÁ>Ð4QÑ.Ró  ð, Ø "ñ	 Ø�?‰?ð à�D˜˜c˜‘NÑ#ð ð ð ð �4˜�9Ñð	 ð
 
ˆ$ˆs�Cˆx‰.Ñó ðL 37Ø'+Ø.2òI7Ø	ðI7àðI7ð �U˜8 C™=¨#Ð-Ñ.Ñ/ðI7ð �E—O‘OÑ$ð	I7ð
 ˜D  c ™NÑ+ðI7ð 
óI7ôX�Nô ð$Ð+?ð ÈCð ÐTXÐY\ÑT]ó ð:Ð,@ð ÈSð ÐU]Ð^aÑUbó ðJÐ1ð J¸cð JÀdó Jð&Ð1ð &¸cð &ÀhÈsÁmó &ð,.Ð1ð .¸cð .È#ð .ÐRVô .r)   