
    bi&              
       <   S SK r S SKrS SKrS SKrS SKJr  S SKJr  S SKJ	r	  S SK
Jr  S SKJr  S SKJr  S SKJrJrJrJrJrJr  S S	KJr  S
SKJr  / SQr\ " S S5      5       r " S S\	5      rS\S\4S jrS\\\4   S\\   4S jr S\S\\   4S jr!\" S\RD                  S9r#0 r$S"S\\   S\\S\#4   /\S\#4   4   4S jjr%   S#S\\   S\\\   \S4   S\\\   \S4   S\&\   4S jjr'S\S\S\RD                  4   4S jr(S\S \S\RD                  4S! jr)g)$    N)Iterable)	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                   T    \ rS rSr% Sr\\S'   \\S'   \\\	4   \S'   S\	S\
4S jrS	rg
)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                 |   [        U[        5      (       d  [        $ U R                  UR                  :w  a  gU R                  UR                  :w  a  g[        U R
                  [        5      (       a  [        UR
                  [        5      (       a  U R
                  R                  UR
                  R                  :H  =(       aa    U R
                  R                  UR
                  R                  :H  =(       a-    U R
                  R                  UR
                  R                  :H  $ U R
                  UR
                  :H  $ )NF)

isinstancer   NotImplementedr   r   r   r   funcargskeywords)selfr   s     Q/home/james-whalen/.local/lib/python3.13/site-packages/torchvision/models/_api.py__eq__Weights.__eq__*   s     %))!!88uyy 99

"doow//Ju?O?OQX4Y4Y$$(8(8(=(== JOO((E,<,<,A,AAJOO,,0@0@0I0II ??e&6&666     N)__name__
__module____qualname____firstlineno____doc__str__annotations__r
   dictr	   boolr(   __static_attributes__r+   r*   r'   r   r      s5     
H
sCx.7C 7D 7r*   r   c                       \ rS rSrSr\S\S\4S j5       rS\S\S\\	\4   4S jr
S\	4S	 jr\S
 5       r\S 5       r\S 5       rSrg)r   E   a5  
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                     Ubu  [        U5      [        L a#  XR                  U R                  S-   S5         nU$ [	        X5      (       d0  [        SU R                   SUR                  R                   S35      eU$ )N. z(Invalid Weight class provided; expected z but received )typer1   replacer,   r!   	TypeError	__class__)clsr8   s     r'   verifyWeightsEnum.verifyO   s|    ?CyC++cllS&8"=>
 
	  ))>s||nN[^[h[h[q[qZrrst  
r*   r$   kwargsc                 4    [        U R                  /UQ70 UD6$ N)r   r   )r&   r$   rC   s      r'   get_state_dictWeightsEnum.get_state_dictZ   s    'B4B6BBr*   c                 L    U R                   R                   SU R                   3$ )Nr:   )r?   r,   _name_r&   s    r'   __repr__WeightsEnum.__repr__]   s"    ..))*!DKK=99r*   c                 .    U R                   R                  $ rE   )valuer   rJ   s    r'   r   WeightsEnum.url`   s    zz~~r*   c                 .    U R                   R                  $ rE   )rN   r   rJ   s    r'   r   WeightsEnum.transformsd   s    zz$$$r*   c                 .    U R                   R                  $ rE   )rN   r   rJ   s    r'   r   WeightsEnum.metah   s    zzr*   r+   N)r,   r-   r.   r/   r0   classmethodr	   rA   r3   r1   rF   rK   propertyr   r   r   r5   r+   r*   r'   r   r   E   s        CC C3 C4S> C:# :   % %  r*   r   namer   c                     U R                  S5      u  pSR                  [        R                  [
           R
                  R                  S5      SS 5      n[        R                  " U5      nU/[        R                  " U[        R                  5       Vs/ s H-  nUS   R                  R                  S5      (       d  M(  US   PM/     sn-   nSnU H=  nUR                  R                  US5      n	U	c  M$  [        U	[         5      (       d  M;  U	n  O   Uc  [        SU S	35      eXr   $ ! [         a    [        SU  S35      ef = fs  snf )
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.
r:   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   )
rV   	enum_name
value_namebase_module_namebase_modulexmodel_modulesweights_enummpotential_classs
             r'   r   r   m   sC   E $

3	 xxH 5 > > D DS I#2 NO))*:;K M##K1A1AB%BAQ4==!!-0 	!B% M L**..D9&:o{+S+S*L	  ,YK7ghii##+  E:4&CDDE
%s   D* 'E	E*Ec                 \    [        U [        5      (       a  [        U 5      OU n[        U5      $ )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)rV   models     r'   r   r      s(     (2$'<'<d#$EU##r*   fnc                    [        U 5      nSUR                  ;  a  [        S5      eUR                  S   R                  nSn[	        U[
        5      (       a  [        U[        5      (       a  UnOB[        U5       H3  n[	        U[
        5      (       d  M  [        U[        5      (       d  M1  Un  O   Uc  [        S5      eU$ )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   
parametersr\   
annotationr!   r<   ri   r   r   )rv   sigannrp   ts        r'   rt   rt      s     B-C&HII
..
#
.
.CL#tC!=!= #A!T""z!['A'A  
 x
 	
 r*   M)bound.c                 T   ^  S[         S[        4   S[         S[        4   4U 4S jjnU$ )Nrv   .r   c                 n   > Tb  TOU R                   nU[        ;   a  [        SU S35      eU [        U'   U $ )Nz/An entry is already registered under the name 'rX   )r,   BUILTIN_MODELSr\   )rv   keyrV   s     r'   wrapperregister_model.<locals>.wrapper   s@    &dBKK. NseSUVWW s	r*   )r
   r~   )rV   r   s   ` r'   register_modelr      s/    HS!V$ #q&)9  Nr*   moduleincludeexcludec                    [         R                  5        VVs1 s H9  u  p4U b/  UR                  R                  SS5      S   U R                  :X  d  M7  UiM;     nnnU(       aN  [        5       n[        U[        5      (       a  U/nU H%  nU[        [        R                  " XW5      5      -  nM'     OUnU(       aC  [        U[        5      (       a  U/nU H%  nU[        [        R                  " XX5      5      -
  nM'     [        U5      $ s  snnf )aw  
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.
r:   rZ   r   )r   itemsr-   rsplitr,   setr!   r1   fnmatchfiltersorted)	r   r   r   kv
all_modelsmodelsinclude_filterexclude_filters	            r'   r   r      s    * %**,,da!,,BUBUVY[\B]^_B`djdsdsBs,   5gs##iG%Nc'.."LMMF & gs##iG%Nc'.."LMMF &&>#s   6DDc                 r    U R                  5       n  [        U    nU$ ! [         a    [        SU  35      ef = f)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   KeyErrorr\   )rV   rv   s     r'   r   r      sH     ::<D2D! I  2>$0112s   	 6configc                 (    [        U 5      nU" S0 UD6$ )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.
r+   )r   )rV   r   rv   s      r'   r   r   	  s     
4	 B<<r*   rE   )NNN)*r   r`   rb   r^   collections.abcr   dataclassesr   enumr   	functoolsr   r   typesr   typingr	   r
   r   r   r   r   torchr   _internally_replaced_utilsr   __all__r   r   r1   r   r<   r   rt   Moduler~   r   r   listr   r   r   r+   r*   r'   <module>r      s      
 $ !     D D  A y ,7 ,7 ,7^%$ %P!$S !$[ !$H$E(C-0 $T+5F $( tK'8 @ Cryy!# (HS!V<L;MxX[]^X^O_;_2`  $(/3/3%Z %8C=#t+,% 8C=#t+,% 
#Y	%PC HS"))^$< $C 3 299 r*   