§
    ù²Åj[(  ã            
       óˆ  — d dl Z d dlZd dlZd dl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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j$        ¬¦  «        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j$        f         fd„Z)de dedej$        fd „Z*dS )#é    N)Ú	dataclass)ÚEnum)Úpartial)Ú	signature)Ú
ModuleType)ÚAnyÚCallableÚDictÚIterableÚListÚMappingÚOptionalÚSetÚTypeÚTypeVarÚUnion)Únné   )Úload_state_dict_from_url)ÚWeightsEnumÚWeightsÚ	get_modelÚget_model_builderÚget_model_weightsÚ
get_weightÚlist_modelsc                   óR   — 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
dS )	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                 ó¦  — t          |t          ¦  «        st          S | j        |j        k    rdS | j        |j        k    rdS t          | j        t          ¦  «        rht          |j        t          ¦  «        rN| j        j        |j        j        k    o3| j        j        |j        j        k    o| j        j	        |j        j	        k    S | j        |j        k    S )NF)
Ú
isinstancer   ÚNotImplementedr   r    r   r   ÚfuncÚargsÚkeywords)Úselfr!   s     úHC:\Projects\Historical\venv\Lib\site-packages\torchvision/models/_api.pyÚ__eq__zWeights.__eq__)   sÉ   € õ ˜%¥Ñ)Ô)ð 	"Ý!Ð!àŒ8�u”yÒ Ð Ø�5àŒ9˜œ
Ò"Ð"Ø�5å�d”o¥wÑ/Ô/ð 	7µJ¸uÔ?OÕQXÑ4YÔ4Yð 	7à”Ô$¨Ô(8Ô(=Ò=ð JØ”OÔ(¨EÔ,<Ô,AÒAðJà”OÔ,°Ô0@Ô0IÒIðð ”? eÔ&6Ò6Ð6ó    N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__ÚstrÚ__annotations__r	   r
   r   Úboolr+   © r,   r*   r   r      sm   € € € € € € ðð ð 
€H€H�HØÐÐÑØ
ˆs�CˆxŒ.ÐÐÑð7˜Cð 7 Dð 7ð 7ð 7ð 7ð 7ð 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dS )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                 óê   — |�pt          |¦  «        t          u r%| |                     | j        dz   d¦  «                 }n5t	          || ¦  «        s%t          d| j        › d|j        j        › d�¦  «        ‚|S )Nú.Ú z(Invalid Weight class provided; expected z but received )Útyper1   Úreplacer-   r$   Ú	TypeErrorÚ	__class__)Úclsr6   s     r*   ÚverifyzWeightsEnum.verifyN   sƒ   € àˆ?Ý�C‰yŒy�CÐÐØ˜#Ÿ+š+ c¤l°SÑ&8¸"Ñ=Ô=Ô>��Ý  SÑ)Ô)ð ÝØt¸s¼|ÐtÐtÐ[^Ô[hÔ[qÐtÐtÐtñô ð ð ˆ
r,   r'   Úkwargsc                 ó,   — t          | j        g|¢R i |¤ŽS ©N)r   r   )r)   r'   r@   s      r*   Úget_state_dictzWeightsEnum.get_state_dictY   s"   € Ý'¨¬ÐB°4ÐBÐBÐB¸6ÐBÐBÐBr,   c                 ó.   — | j         j        › d| j        › �S )Nr8   )r=   r-   Ú_name_©r)   s    r*   Ú__repr__zWeightsEnum.__repr__\   s   € Ø”.Ô)Ð9Ð9¨D¬KÐ9Ð9Ð9r,   c                 ó   — | j         j        S rB   )Úvaluer   rF   s    r*   r   zWeightsEnum.url_   s   € àŒzŒ~Ðr,   c                 ó   — | j         j        S rB   )rI   r   rF   s    r*   r   zWeightsEnum.transformsc   s   € àŒzÔ$Ð$r,   c                 ó   — | j         j        S rB   )rI   r    rF   s    r*   r    zWeightsEnum.metag   s   € àŒzŒÐr,   N)r-   r.   r/   r0   Úclassmethodr   r?   r   r1   rC   rG   Úpropertyr   r   r    r4   r,   r*   r   r   D   sñ   € € € € € ðð ð ð˜ð  ð ð ð ñ „[ððC Cð C°3ð C¸7À3ÈÀ8Ô;Lð Cð Cð Cð Cð:˜#ð :ð :ð :ð :ð ðð ñ „Xðð ð%ð %ñ „Xð%ð ðð ñ „Xðð ð r,   r   Únamer"   c                 óB  — 	 |                       d¦  «        \  }}n!# t          $ r t          d| › d�¦  «        ‚w xY wd                     t          j        t
                   j                              d¦  «        dd…         ¦  «        }t          j        |¦  «        }|gd„ t          j	        |t          j
        ¦  «        D ¦   «         z   }d}|D ]8}|j                             |d¦  «        }|�t          |t          ¦  «        r|} nŒ9|€t          d|› d�¦  «        ‚||         S )	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.
    r8   zInvalid weight name provided: 'ú'.Néÿÿÿÿc                 ó^   — g | ]*}|d          j                              d¦  «        ¯"|d          ‘Œ+S )é   z__init__.py)Ú__file__Úendswith)Ú.0Úxs     r*   ú
<listcomp>zget_weight.<locals>.<listcomp>}   sF   € ð %ð %ð %àØˆQŒ4Œ=×!Ò! -Ñ0Ô0ð%Ø	ˆ!Œð%ð %ð %r,   zThe weight enum 'z0' for the specific method couldn't be retrieved.)ÚsplitÚ
ValueErrorÚjoinÚsysÚmodulesr-   Ú	importlibÚimport_moduleÚinspectÚ
getmembersÚismoduleÚ__dict__ÚgetÚ
issubclassr   )	rN   Ú	enum_nameÚ
value_nameÚbase_module_nameÚbase_moduleÚmodel_modulesÚweights_enumÚmÚpotential_classs	            r*   r   r   l   sK  € ðEØ $§
¢
¨3¡¤Ñˆ	�:�:øÝð Eð Eð EÝÐC¸4ÐCÐCÐCÑDÔDÐDðEøøøð —x’x¥¤­HÔ 5Ô >× DÒ DÀSÑ IÔ IÈ#È2È#Ô NÑOÔOÐÝÔ)Ð*:Ñ;Ô;€KØ �Mð %ð %åÔ# KµÔ1AÑBÔBð%ñ %ô %ñ €Mð €LØð ð ˆØœ*Ÿ.š.¨°DÑ9Ô9ˆØÐ&­:°oÅ{Ñ+SÔ+SÐ&Ø*ˆLØˆEøàÐÝÐh¨YÐhÐhÐhÑiÔiÐià˜
Ô#Ð#s   ‚ ›9c                 ól   — 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$   r1   r   Ú_get_enum_from_fn)rN   Úmodels     r*   r   r   �   s4   € õ (2°$½Ñ'<Ô'<ÐFÕ˜dÑ#Ô#Ð#À$€EÝ˜UÑ#Ô#Ð#r,   Úfnc                 ó‚  — t          | ¦  «        }d|j        vrt          d¦  «        ‚t          | ¦  «        j        d         j        }d}t	          |t
          ¦  «        rt          |t          ¦  «        r|}n8|j        D ]0}t	          |t
          ¦  «        rt          |t          ¦  «        r|} nŒ1|€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   Ú
parametersrZ   Ú
annotationr$   r:   re   r   Ú__args__)rq   ÚsigÚannrk   Úts        r*   ro   ro   ž   sÔ   € õ �B‰-Œ-€CØ˜œÐ&Ð&ÝÐHÑIÔIÐIå
�B‰-Œ-Ô
" 9Ô
-Ô
8€CØ€LÝ�#•tÑÔð ¥¨CµÑ!=Ô!=ð Øˆˆð ”ð 	ð 	ˆAÝ˜!�TÑ"Ô"ð ¥z°!µ[Ñ'AÔ'Að Ø �Ø�øàÐÝØxñ
ô 
ð 	
ð Ðr,   ÚM)Úbound.c                 ód   ‡ — dt           dt          f         dt           dt          f         fˆ fd„}|S )Nrq   .r"   c                 ój   •— ‰�‰n| j         }|t          v rt          d|› d�¦  «        ‚| t          |<   | S )Nz/An entry is already registered under the name 'rP   )r-   ÚBUILTIN_MODELSrZ   )rq   ÚkeyrN   s     €r*   Úwrapperzregister_model.<locals>.wrapperÅ   sG   ø€ ØÐ&ˆdˆd¨B¬KˆØ•.Ð Ð ÝÐVÈsÐVÐVÐVÑWÔWÐWØ ��sÑØˆ	r,   )r	   rz   )rN   r€   s   ` r*   Úregister_modelr�   Ä   sH   ø€ ð•H˜S¥!˜VÔ$ð ­°#µq°&Ô)9ð ð ð ð ð ð ð €Nr,   ÚmoduleÚincludeÚexcludec                 óž  ‡ — ˆ fd„t                                ¦   «         D ¦   «         }|rQt          ¦   «         }t          |t          ¦  «        r|g}|D ]'}|t          t          j        ||¦  «        ¦  «        z  }Œ(n|}|rBt          |t          ¦  «        r|g}|D ]'}|t          t          j        ||¦  «        ¦  «        z
  }Œ(t          |¦  «        S )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.
    c                 ór   •— h | ]3\  }}‰�*|j                              dd¦  «        d         ‰j        k    ¯1|’Œ4S )Nr8   rS   r   )r.   Úrsplitr-   )rV   ÚkÚvr‚   s      €r*   ú	<setcomp>zlist_models.<locals>.<setcomp>ã   sP   ø€ ð ð ð Ùˆa�°°À!Ä,×BUÒBUÐVYÐ[\ÑB]ÔB]Ð^_ÔB`ÐdjÔdsÒBsÐBsˆÐBsÐBsÐBsr,   )r~   ÚitemsÚsetr$   r1   ÚfnmatchÚfilterÚsorted)r‚   rƒ   r„   Ú
all_modelsÚmodelsÚinclude_filterÚexclude_filters   `      r*   r   r   Ï   s   ø€ ð(ð ð ð Ý$×*Ò*Ñ,Ô,ðñ ô €Jð ð Ý™5œ5ˆÝ�g�sÑ#Ô#ð 	 Ø�iˆGØ%ð 	Nð 	NˆNØ�c¥'¤.°¸^Ñ"LÔ"LÑMÔMÑMˆFˆFð	Nð ˆàð NÝ�g�sÑ#Ô#ð 	 Ø�iˆGØ%ð 	Nð 	NˆNØ�c¥'¤.°¸^Ñ"LÔ"LÑMÔMÑMˆFˆFÝ�&‰>Œ>Ðr,   c                 óŒ   — |                       ¦   «         } 	 t          |          }n # t          $ r t          d| › �¦  «        ‚w xY w|S )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 )Úlowerr~   ÚKeyErrorrZ   )rN   rq   s     r*   r   r   ÷   sY   € ð �:Š:‰<Œ<€Dð2Ý˜DÔ!ˆˆøÝð 2ð 2ð 2ÝÐ0¨$Ð0Ð0Ñ1Ô1Ð1ð2øøøà€Is	   –$ ¤AÚconfigc                 ó0   — 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.
    r4   )r   )rN   r—   rq   s      r*   r   r   	  s#   € õ 
˜4Ñ	 Ô	 €BØˆ2ˆ<ˆ<�ˆ<ˆ<Ðr,   rB   )NNN)+r�   r^   r`   r\   Údataclassesr   Úenumr   Ú	functoolsr   r   Útypesr   Útypingr   r	   r
   r   r   r   r   r   r   r   r   Útorchr   Ú_internally_replaced_utilsr   Ú__all__r   r   r1   r   r   ro   ÚModulerz   r~   r�   r   r   r   r4   r,   r*   ú<module>r¢      s  ðØ €€€Ø Ð Ð Ð Ø €€€Ø 
€
€
€
Ø !Ð !Ð !Ð !Ð !Ð !Ø Ð Ð Ð Ð Ð Ø Ð Ð Ð Ð Ð Ø Ð Ð Ð Ð Ð Ø Ð Ð Ð Ð Ð Ø dÐ dÐ dÐ dÐ dÐ dÐ dÐ dÐ dÐ dÐ dÐ dÐ dÐ dÐ dÐ dÐ dÐ dÐ dÐ dÐ dÐ dÐ dÐ dÐ dÐ dà Ð Ð Ð Ð Ð à AÐ AÐ AÐ AÐ AÐ Að yÐ
xÐ
x€ð ð,7ð ,7ð ,7ð ,7ð ,7ñ ,7ô ,7ñ „ð,7ð^%ð %ð %ð %ð %�$ñ %ô %ð %ðP!$�Sð !$˜[ð !$ð !$ð !$ð !$ðH$˜E (¨C -Ô0ð $°T¸+Ô5Fð $ð $ð $ð $ð˜(ð  t¨KÔ'8ð ð ð ð ðB €GˆC�r”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ð ð ð ð ð ð r,   