Ë
    þÍ:jø&  ã            
       ó4  — 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 d dl	m
Z
 d dlmZ d dlmZ d dlmZ d dlmZmZmZmZmZmZ d d	lmZ d
dlmZ g d¢Ze G d„ d«      «       Z G d„ de
«      Zdedefd„Zdeeef   de e   fd„Z!dede e   fd„Z" edejF                  ¬«      Z$i Z%d"dee   deede$f   gede$f   f   fd„Z&	 	 	 d#dee   deee   edf   deee   edf   de'e   fd„Z(dededejF                  f   fd„Z)ded edejF                  fd!„Z*y)$é    N)ÚIterableÚMapping)Ú	dataclass)ÚEnum)Úpartial)Ú	signature)Ú
ModuleType)ÚAnyÚCallableÚget_argsÚOptionalÚTypeVarÚUnion)Únné   )Úload_state_dict_from_url)ÚWeightsEnumÚWeightsÚ	get_modelÚget_model_builderÚget_model_weightsÚ
get_weightÚlist_modelsc                   óJ   — e Zd ZU dZeed<   eed<   eeef   ed<   dede	fd„Z
y)	r   aß  
    This class is used to group important attributes associated with the pre-trained weights.

    Args:
        url (str): The location where we find the weights.
        transforms (Callable): A callable that constructs the preprocessing method (or validation preset transforms)
            needed to use the model. The reason we attach a constructor method rather than an already constructed
            object is because the specific object might have memory and thus we want to delay initialization until
            needed.
        meta (Dict[str, Any]): Stores meta-data related to the weights of the model and its configuration. These can be
            informative attributes (for example the number of parameters/flops, recipe link/methods used in training
            etc), configuration parameters (for example the `num_classes`) needed to construct the model or important
            meta-data (for example the `classes` of a classification model) needed to use the model.
    ÚurlÚ
transformsÚmetaÚotherÚreturnc                 óF  — t        |t        «      st        S | j                  |j                  k7  ry| j                  |j                  k7  ryt        | j
                  t        «      r¥t        |j
                  t        «      r‹| j
                  j                  |j
                  j                  k(  xr\ | j
                  j                  |j
                  j                  k(  xr- | j
                  j                  |j
                  j                  k(  S | j
                  |j
                  k(  S )NF)
Ú
isinstancer   ÚNotImplementedr   r   r   r   ÚfuncÚargsÚkeywords)Úselfr   s     úl/home/mcse/projects/srt_converter/srt-converter-venv/lib/python3.12/site-packages/torchvision/models/_api.pyÚ__eq__zWeights.__eq__*   sÚ   € ô ˜%¤Ô)Ü!Ð!à�8‰8�u—y‘yÒ Øà�9‰9˜Ÿ
™
Ò"Øä�d—o‘o¤wÔ/´J¸u×?OÑ?OÔQXÔ4Yà—‘×$Ñ$¨×(8Ñ(8×(=Ñ(=Ñ=ò JØ—O‘O×(Ñ(¨E×,<Ñ,<×,AÑ,AÑAòJà—O‘O×,Ñ,°×0@Ñ0@×0IÑ0IÑIðð —?‘? e×&6Ñ&6Ñ6Ð6ó    N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__ÚstrÚ__annotations__r   Údictr
   Úboolr(   © r)   r'   r   r      s5   … ñð 
ƒHØÓØ
ˆs�Cˆx‰.Óð7˜Cð 7 Dô 7r)   r   c                   ó„   — e Zd ZdZededefd„«       Zdededeeef   fd„Z	defd„Z
ed	„ «       Zed
„ «       Zed„ «       Zy)r   aM  
    This class is the parent class of all model weights. Each model building method receives an optional `weights`
    parameter with its associated pre-trained weights. It inherits from `Enum` and its values should be of type
    `Weights`.

    Args:
        value (Weights): The data class entry with the weight information.
    Úobjr   c                 óì   — |�qt        |«      t        u r$| |j                  | j                  dz   d«         }|S t	        || «      s0t        d| j                  › d|j                  j                  › d�«      ‚|S )Nú.Ú z(Invalid Weight class provided; expected z but received )Útyper.   Úreplacer*   r!   Ú	TypeErrorÚ	__class__)Úclsr4   s     r'   ÚverifyzWeightsEnum.verifyO   s}   € àˆ?Ü�C‹yœCÑØ˜#Ÿ+™+ c§l¡l°SÑ&8¸"Ó=Ñ>�ð
 ˆ
ô	    SÔ)ÜØ>¸s¿|¹|¸nÈNÐ[^×[hÑ[h×[qÑ[qÐZrÐrsÐtóð ð ˆ
r)   r$   Úkwargsc                 ó4   — t        | j                  g|¢­i |¤ŽS ©N)r   r   )r&   r$   r>   s      r'   Úget_state_dictzWeightsEnum.get_state_dictZ   s   € Ü'¨¯©ÐB°4ÒB¸6ÑBÐBr)   c                 óL   — | j                   j                  › d| j                  › �S )Nr6   )r;   r*   Ú_name_©r&   s    r'   Ú__repr__zWeightsEnum.__repr__]   s"   € Ø—.‘.×)Ñ)Ð*¨!¨D¯K©K¨=Ð9Ð9r)   c                 ó.   — | j                   j                  S r@   )Úvaluer   rD   s    r'   r   zWeightsEnum.url`   s   € à�z‰z�~‰~Ðr)   c                 ó.   — | j                   j                  S r@   )rG   r   rD   s    r'   r   zWeightsEnum.transformsd   s   € à�z‰z×$Ñ$Ð$r)   c                 ó.   — | j                   j                  S r@   )rG   r   rD   s    r'   r   zWeightsEnum.metah   s   € à�z‰z�‰Ðr)   N)r*   r+   r,   r-   Úclassmethodr
   r=   r   r.   rA   rE   Úpropertyr   r   r   r2   r)   r'   r   r   E   s˜   „ ñð ð˜ð  ò ó ððC Cð C°3ð C¸7À3ÈÀ8Ñ;Ló Cð:˜#ó :ð ñó ðð ñ%ó ð%ð ñó ñr)   r   Únamer   c                 ón  — 	 | j                  d«      \  }}dj                  t        j                  t
           j
                  j                  d«      dd «      }t        j                  |«      }|gt        j                  |t        j                  «      D �cg c]%  }|d   j                  j                  d«      r|d   ‘Œ' c}z   }d}|D ]5  }|j                  j                  |d«      }	|	€Œ"t        |	t         «      sŒ3|	} n |€t        d|› d	�«      ‚||   S # t        $ r t        d| › d�«      ‚w xY wc c}w )
zá
    Gets the weights enum value by its full name. Example: "ResNet50_Weights.IMAGENET1K_V1"

    Args:
        name (str): The name of the weight enum entry.

    Returns:
        WeightsEnum: The requested weight enum.
    r6   zInvalid weight name provided: 'ú'.Néÿÿÿÿé   z__init__.pyzThe weight enum 'z0' for the specific method couldn't be retrieved.)ÚsplitÚ
ValueErrorÚjoinÚsysÚmodulesr*   Ú	importlibÚimport_moduleÚinspectÚ
getmembersÚismoduleÚ__file__ÚendswithÚ__dict__ÚgetÚ
issubclassr   )
rL   Ú	enum_nameÚ
value_nameÚbase_module_nameÚbase_moduleÚxÚmodel_modulesÚweights_enumÚmÚpotential_classs
             r'   r   r   m   sB  € ðEØ $§
¡
¨3£Ñˆ	�:ð —x‘x¤§¡¬HÑ 5× >Ñ >× DÑ DÀSÓ IÈ#È2Ð NÓOÐÜ×)Ñ)Ð*:Ó;€KØ �Mä×#Ñ# K´×1AÑ1AÓBö%àØˆQ‰4�=‰=×!Ñ! -Ô0ð 	
ˆ!‹ò%ñ €Mð €LØò ˆØŸ*™*Ÿ.™.¨°DÓ9ˆØÑ&¬:°oÄ{Õ+SØ*ˆLÙð	ð ÐÜÐ,¨Y¨KÐ7gÐhÓiÐià˜
Ñ#Ð#øô+ ò EÜÐ:¸4¸&ÀÐCÓDÐDðEüò
%s   ‚D Â*D2ÄD/c                 óR   — t        | t        «      rt        | «      n| }t        |«      S )a  
    Returns the weights enum class associated to the given model.

    Args:
        name (callable or str): The model builder function or the name under which it is registered.

    Returns:
        weights_enum (WeightsEnum): The weights enum class associated with the model.
    )r!   r.   r   Ú_get_enum_from_fn)rL   Úmodels     r'   r   r   ‘   s%   € ô (2°$¼Ô'<Ô˜dÔ#À$€EÜ˜UÓ#Ð#r)   Úfnc                 óN  — t        | «      }d|j                  vrt        d«      ‚|j                  d   j                  }d}t	        |t
        «      rt        |t        «      r|}n5t        |«      D ]'  }t	        |t
        «      sŒt        |t        «      sŒ%|} n |€t        d«      ‚|S )zã
    Internal method that gets the weight enum of a specific model builder method.

    Args:
        fn (Callable): The builder method used to create the model.
    Returns:
        WeightsEnum: The requested weight enum.
    Úweightsz-The method is missing the 'weights' argument.NzjThe WeightsEnum class for the specific method couldn't be retrieved. Make sure the typing info is correct.)	r   Ú
parametersrR   Ú
annotationr!   r8   r_   r   r   )rl   ÚsigÚannrf   Úts        r'   rj   rj   Ÿ   s¦   € ô �B‹-€CØ˜Ÿ™Ñ&ÜÐHÓIÐIà
�.‰.˜Ñ
#×
.Ñ
.€CØ€LÜ�#”tÔ¤¨C´Ô!=Ø‰ô ˜#“ò 	ˆAÜ˜!œTÕ"¤z°!´[Õ'AØ �Ùð	ð
 ÐÜØxó
ð 	
ð Ðr)   ÚM)Úbound.c                 óP   ‡ — dt         dt        f   dt         dt        f   fˆ fd„}|S )Nrl   .r   c                 óh   •— ‰�‰n| j                   }|t        v rt        d|› d�«      ‚| t        |<   | S )Nz/An entry is already registered under the name 'rN   )r*   ÚBUILTIN_MODELSrR   )rl   ÚkeyrL   s     €r'   Úwrapperzregister_model.<locals>.wrapperÅ   s@   ø€ ØÐ&‰d¨B¯K©KˆØ”.Ñ ÜÐNÈsÈeÐSUÐVÓWÐWØ Œ�sÑØˆ	r)   )r   rt   )rL   rz   s   ` r'   Úregister_modelr{   Ä   s/   ø€ ð”H˜S¤!˜VÑ$ð ¬°#´q°&Ñ)9õ ð €Nr)   ÚmoduleÚincludeÚexcludec                 óà  — t         j                  «       D ��ch c]6  \  }}| �-|j                  j                  dd«      d   | j                  k(  sŒ5|’Œ8 }}}|rGt        «       }t        |t        «      r|g}|D ]$  }|t        t        j                  ||«      «      z  }Œ& n|}|r<t        |t        «      r|g}|D ]$  }|t        t        j                  ||«      «      z
  }Œ& t        |«      S c c}}w )a§  
    Returns a list with the names of registered models.

    Args:
        module (ModuleType, optional): The module from which we want to extract the available models.
        include (str or Iterable[str], optional): Filter(s) for including the models from the set of all models.
            Filters are passed to `fnmatch <https://docs.python.org/3/library/fnmatch.html>`__ to match Unix shell-style
            wildcards. In case of many filters, the results is the union of individual filters.
        exclude (str or Iterable[str], optional): Filter(s) applied after include_filters to remove models.
            Filter are passed to `fnmatch <https://docs.python.org/3/library/fnmatch.html>`__ to match Unix shell-style
            wildcards. In case of many filters, the results is removal of all the models that match any individual filter.

    Returns:
        models (list): A list with the names of available models.
    r6   rP   r   )rx   Úitemsr+   Úrsplitr*   Úsetr!   r.   ÚfnmatchÚfilterÚsorted)	r|   r}   r~   ÚkÚvÚ
all_modelsÚmodelsÚinclude_filterÚexclude_filters	            r'   r   r   Ï   só   € ô* %×*Ñ*Ó,÷Ùˆa�°°À!Ç,Á,×BUÑBUÐVYÐ[\ÓB]Ð^_ÑB`Ðdj×dsÑdsÓBsŠð€Jñ ñ Ü›5ˆÜ�gœsÔ#Ø�iˆGØ%ò 	NˆNØœc¤'§.¡.°¸^Ó"LÓMÑM‰Fñ	Nð ˆáÜ�gœsÔ#Ø�iˆGØ%ò 	NˆNØœc¤'§.¡.°¸^Ó"LÓMÑM‰Fð	Nä�&‹>Ðùó#s   ˜6C*ÁC*c                 óp   — | j                  «       } 	 t        |    }|S # t        $ r t        d| › �«      ‚w xY w)zÏ
    Gets the model name and returns the model builder method.

    Args:
        name (str): The name under which the model is registered.

    Returns:
        fn (Callable): The model builder method.
    zUnknown model )Úlowerrx   ÚKeyErrorrR   )rL   rl   s     r'   r   r   ÷   sH   € ð �:‰:‹<€Dð2Ü˜DÑ!ˆð €Iøô ò 2Ü˜>¨$¨Ð0Ó1Ð1ð2ús   ’	 �5Úconfigc                 ó(   — t        | «      } |di |¤ŽS )a&  
    Gets the model name and configuration and returns an instantiated model.

    Args:
        name (str): The name under which the model is registered.
        **config (Any): parameters passed to the model builder method.

    Returns:
        model (nn.Module): The initialized model.
    r2   )r   )rL   r�   rl   s      r'   r   r   	  s   € ô 
˜4Ó	 €BÙ‰<�‰<Ðr)   r@   )NNN)+rƒ   rV   rX   rT   Úcollections.abcr   r   Údataclassesr   Úenumr   Ú	functoolsr   r   Útypesr	   Útypingr
   r   r   r   r   r   Útorchr   Ú_internally_replaced_utilsr   Ú__all__r   r   r.   r   r8   r   rj   ÚModulert   rx   r{   Úlistr   r   r   r2   r)   r'   ú<module>rœ      s˜  ðÛ Û Û Û 
ß -Ý !Ý Ý Ý Ý ß D× Då å Aò y€ð ÷,7ð ,7ó ð,7ô^%�$ô %ðP!$�Sð !$˜[ó !$ðH$˜E (¨C -Ñ0ð $°T¸+Ñ5Fó $ð˜(ð  t¨KÑ'8ó ñ@ ˆC�r—y‘yÔ!€à€ñ˜ #™ð °(¸HÀSÈ!ÀVÑ<LÐ;MÈxÐX[Ð]^ÐX^ÑO_Ð;_Ñ2`ó ð $(Ø/3Ø/3ñ%Ø�ZÑ ð%à�8˜C‘= # tÐ+Ñ,ð%ð �8˜C‘= # tÐ+Ñ,ð%ð 
ˆ#�Yó	%ðP˜Cð  H¨S°"·)±)¨^Ñ$<ó ð$�Cð  3ð ¨2¯9©9ô r)   