
    Pgz                         U d dl Z d dlZd dlZd dlZd dlZd dlZd dlZd dlZ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mZmZmZ d dlmZ d dlmZmZ d dlmZ d dlmZmZ d dlZd dlmZ  G d	 d
      Z 	 d dl!m!Z! g dZ# ejH                  d      Z%dZ&dZ'dZ(dZ)dZ*dZ+dZ,dZ-da.ee/   e0d<   e jb                  d        Z2d Z3d Z4d Z5d Z6d Z7d Z8d Z9d Z:	 	 dAd"Z;	 dBd#Z<d$ Z=d% Z>d& Z?d'e/fd(Z@d)ee/ej                  f   d'dfd*ZB	 	 	 	 dCd+ZCdDd,ZDd-dd!d d!d.d/ZEd0 ZF	 	 dEd1e/d2e/d3ee/   d4eGd'df
d5ZHd6e/d'eGfd7ZI ed8eJ9      d6e/d:e/d;ed<eGd'ee/ef   f
d=       ZK	 	 	 	 	 	 dFd1e/d:ee/   d;ed4eGd>eGd?ee/   d<eGd'ee/ef   fd@ZLy# e"$ r e Z!Y w xY w)G    N)Path)AnyDictOptionalUnion)
deprecated)	HTTPErrorURLError)urlparse)Requesturlopen)MAP_LOCATIONc                   8    e Zd Zd	dZd Zd Zd Zd Zd Zd Z	y)
	_FaketqdmNc                 .    || _         || _        d| _        y Nr   )totaldisablen)selfr   r   unitargskwargss         P/var/www/html/suriana-translation/venv/lib/python3.12/site-packages/torch/hub.py__init__z_Faketqdm.__init__   s    
    c                    | j                   ry | xj                  |z  c_        | j                  /t        j                  j                  d| j                  dd       nGt        j                  j                  dd| j                  z  t        | j                        z  dd       t        j                  j                          y )Nz.1fz bytesd   %)r   r   r   sysstderrwritefloatflush)r   r   s     r   updatez_Faketqdm.update    s    <<!::JJr$&&V45JJr#,tzz1B"B3!GqIJ

r   c                      y N )r   r   r   s      r   set_descriptionz_Faketqdm.set_description,   s    r   c                 H    t         j                  j                  | d       y N
)r!   r"   r#   )r   ss     r   r#   z_Faketqdm.write/   s    

A3b"r   c                     d| _         y NT)r   r   s    r   closez_Faketqdm.close2   s	    r   c                     | S r(   r)   r1   s    r   	__enter__z_Faketqdm.__enter__5   s    r   c                 \    | j                   ry t        j                  j                  d       y r,   )r   r!   r"   r#   )r   exc_typeexc_valexc_tbs       r   __exit__z_Faketqdm.__exit__8   s    <<

r   )NFN)
__name__
__module____qualname__r   r&   r*   r#   r2   r4   r9   r)   r   r   r   r      s%    	#r   r   )tqdm)download_url_to_fileget_dirhelplistloadload_state_dict_from_urlset_dirz-([a-f0-9]*)\.)facebookresearchfacebookincubatorpytorchfairinternalGITHUB_TOKEN
TORCH_HOMEXDG_CACHE_HOMEz~/.cachedependenciesz
hubconf.pyi   _hub_dirc              #      K   t         j                  j                  d|        	 d  t         j                  j                  |        y # t         j                  j                  |        w xY wwr   )r!   pathinsertremoverO   s    r   _add_to_sys_pathrS   a   s@     HHOOAts   !A,A  A,!A))A,c                     dd l }ddlm} |j                  j	                  | |      }|J |j                  j                  |      }t        |j                  |      sJ |j                  j                  |       |S )Nr   )Loader)	importlib.utilimportlib.abcrU   utilspec_from_file_locationmodule_from_spec
isinstanceloaderexec_module)namerO   	importlibrU   specmodules         r   _import_modulerb   k   si    $>>11$=D^^,,T2Fdkk6***KKF#Mr   c                     t         j                  j                  |       rKt         j                  j                  |       rt        j                  |        y t        j                  |        y y r(   )osrO   existsisfilerQ   shutilrmtreerR   s    r   _remove_if_existsri   w   s>    	ww~~d77>>$IIdOMM$	 r   c                     d|  d| d| S )Nhttps://github.com//z	/zipball/r)   )
repo_owner	repo_namerefs      r   _git_archive_linkrp      s     Ai[	#GGr   c                 6    |t        |       vry t        | |      S r(   )dirgetattr)ra   	func_names     r   _load_attr_from_moduleru      s    F#69%%r   c                      t         j                  j                  t        j                  t        t         j                  j                  t        j                  t        t              d                  } | S )Ntorch)rd   rO   
expandusergetenvENV_TORCH_HOMEjoinENV_XDG_CACHE_HOMEDEFAULT_CACHE_DIR)
torch_homes    r   _get_torch_homer      sL    ##
		GGLL#57HI7S	
J r   c                    d| v r| j                  d      \  }}n| d }}|j                  d      \  }}|	 t        d| d| d      5  d}d d d        |||fS # 1 sw Y   xY w# t        $ r}|j                  dk(  rd}n Y d }~2d }~wt        $ ra}dD ]8  }t
        j                  j                  t                d| d	| d	|       s6|} n |t        d
t                d      |Y d }~d }~ww xY w)N:rl   rk   z/tree/main/maini  master)r   r   _z\It looks like there is no internet connection and the repo could not be found in the cache ())
splitr   r	   coder
   rd   rO   re   r?   RuntimeError)github	repo_inforo   rm   rn   epossible_refs          r   _parse_repo_infor      s+   
f}c*	33	%OOC0J	
{	.zl!I;kRS ( y#%%)  	vv}   	 2 77>>yk:,a	{!L>J 'C {"==DYKqJ  	sA   A# A
A# A A# #	C1,BC17C,C,,C1c                     t        |       5 }|j                         j                  |j                  j	                  d            cd d d        S # 1 sw Y   y xY w)Nzutf-8)r   readdecodeheadersget_content_charset)urlrs     r   	_read_urlr      sE    	 Gvvxqyy<<WEFG G Gs   8AAc           	         ddi}t         j                  j                  t              }|d| |d<   d|  d| dd|  d| dfD ]f  }d	}	 |d
z  }| d| }t	        j
                  t        t        ||                  }|s>|D ]$  }	|	d   |k(  s|	d   d   j                  |      s#  y  b t        d| d|  d| d      )NAcceptzapplication/vnd.github.v3+jsonztoken Authorizationzhttps://api.github.com/repos/rl   z	/branchesz/tagsr      z?per_page=100&page=r   r^   commitshazCannot find z in https://github.com/zX. If it's a commit from a forked repo, please call hub.load() with forked repo directly.)
rd   environgetENV_GITHUB_TOKENjsonloadsr   r   
startswith
ValueError)
rm   rn   ro   r   token
url_prefixpager   responsebrs
             r   _validate_not_a_forked_repor      s   9:GJJNN+,E%+E7#3 
'
|1YKyI
'
|1YKuE 
 AIDL 3D6:Czz)GC,I"JKH f:$8U(;(F(Fs(K   
se2:,a	{ Ka 	a r   TFc                    t               }t        j                  |d       t        |       \  }}}	|	j	                  dd      }
dj                  |||
g      }t        j                  j                  ||      }t        |||||       | xr t        j                  j                  |      }|r'|r#t        j                  j                  d| d       |S |st        |||	       t        j                  j                  ||
dz         }t        |       	 t        |||	      }t        j                  j                  d	| d
| d       t        ||d       t)        j*                  |      5 }|j-                         d   j.                  }t        j                  j                  ||      }t        |       |j1                  |       d d d        t        |       t        |       t3        j4                  |       |S # t         $ rU}|j"                  dk(  r;t%        j&                  d|	 d       d|	 }t        |||      }t        ||d       n Y d }~d }~ww xY w# 1 sw Y   xY w)NTexist_okrl   r   )
trust_repo
calling_fnzUsing cache found in r-   z.zipDownloading: "" to Fprogressi,  zThe ref a   is ambiguous. Perhaps it is both a tag and a branch in the repo? Torchhub will now assume that it's a branch. You can disambiguate tags and branches by explicitly passing refs/heads/branch_name or refs/tags/tag_name as the ref. That might require using skip_validation=True.zrefs/heads/)ro   r   )r?   rd   makedirsr   replacer{   rO   _check_repo_is_trustedre   r!   r"   r#   r   ri   rp   r>   r	   r   warningswarnzipfileZipFileinfolistfilename
extractallrg   move)r   force_reloadr   r   verboseskip_validationhub_dirrm   rn   ro   normalized_browner_name_branchrepo_dir	use_cachecached_filer   errdisambiguated_branch_refcached_zipfileextraced_repo_nameextracted_repos                        r   _get_cache_or_reloadr      s>    iGKK$'!1&!9J	3
 KKS)M
 *i!GHww||G%67H "!?rww~~h'?IJJ4XJbABX OS '
IsCggll7MF,BC+&	#J	3?CJJ~cU%}BGH kEB* __[) 	/^!/!8!8!:1!=!F!FWW\\'3EFNn-%%g.	/ 	+&(#NH-O?  	xx3
 se $d d .9+>('	/G %S+F G!	(	/ 	/s'   AG8 (AI8	IAIII"c                 <   t               }t        j                  j                  |d      }t        j                  j	                  |      st        |      j                          t        |      5 }t        d |D              }d d d        t        t        j                  |            d   }	dj                  | |g      }
|
v xs ||	v xs | t        v }||st        j                  d| d| d       y |du s|d	k(  r]|s[t        d
|
 d      }|j                         dv r|r8t!        d       n,|j                         dv rt#        d      t%        d| d      |s*t        |d      5 }|j'                  |
dz          d d d        y y # 1 sw Y   xY w# 1 sw Y   y xY w)Ntrusted_listc              3   <   K   | ]  }|j                           y wr(   )strip).0lines     r   	<genexpr>z)_check_repo_is_trusted.<locals>.<genexpr>:  s     <tdjjl<s   r   r   a)  You are about to download and run code from an untrusted repository. In a future release, this won't be allowed. To add the repository to your trusted list, change the command to {calling_fn}(..., trust_repo=False) and a command prompt will appear asking for an explicit confirmation of trust, or zi(..., trust_repo=True), which will assume that the prompt is to be answered with 'yes'. You can also use z(..., trust_repo='check') which will only prompt for confirmation if the repo is not already trusted. This will eventually be the default behaviourFcheckzThe repository z does not belong to the list of trusted repositories and as such cannot be downloaded. Do you trust this repository and wish to add it to the trusted list of repositories (y/N)?)yyesz"The repository is already trusted.)r   no zUntrusted repository.zUnrecognized response .ar-   )r?   rd   rO   r{   re   r   touchopentuplenextwalk_TRUSTED_REPO_OWNERSr   r   inputlowerprint	Exceptionr   r#   )rm   rn   r   r   r   r   filepathfiletrusted_repostrusted_repos_legacy
owner_name
is_trustedr   s                r   r   r   -  s    iGww||G^4H77>>(#X	h =4<t<<=
   01!4:y12Jm# 	. 44	.--  MM !\ "++5, 7q	r 	ew!6zj\ *i i
 >>|+:;^^03445hZqABB (C  	*DJJzD()	* 	* S= =T	* 	*s   .F&FFFc                 D    dd l }|j                  j                  |       d uS r   )rV   rX   	find_spec)r^   r_   s     r   _check_module_existsr   g  s    >>##D)55r   c                     t        | t              }|D|D cg c]  }t        |      r| }}t        |      rt	        ddj                  |             y y c c}w )NzMissing dependencies: z, )ru   VAR_DEPENDENCYr   lenr   r{   )mrL   pkgmissing_depss       r   _check_dependenciesr   m  sb    )!^<L'3U;OPS;TUU|!7		,8O7PQRR   Us
   AAc                     t        |t              st        d      t        |        t	        | |      }|t        |      st        d| d      |S )Nz8Invalid input: model should be a string of function namezCannot find callable z in hubconf)r[   strr   r   ru   callabler   )r   modelfuncs      r   _load_entry_from_hubconfr   v  sS    eS!STT !!U+D|8D>25'EFFKr   returnc                      t        j                  d      rt        j                  d       t        t        S t         j
                  j                  t               d      S )a  
    Get the Torch Hub cache directory used for storing downloaded models & weights.

    If :func:`~torch.hub.set_dir` is not called, default path is ``$TORCH_HOME/hub`` where
    environment variable ``$TORCH_HOME`` defaults to ``$XDG_CACHE_HOME/torch``.
    ``$XDG_CACHE_HOME`` follows the X Design Group specification of the Linux
    filesystem layout, with a default value ``~/.cache`` if the environment
    variable is not set.
    	TORCH_HUBz:TORCH_HUB is deprecated, please use env TORCH_HOME insteadhub)rd   ry   r   r   rM   rO   r{   r   r)   r   r   r?   r?     s@     
yyRS77<<)511r   dc                 B    t         j                  j                  |       ay)z
    Optionally set the Torch Hub directory used to save downloaded models & weights.

    Args:
        d (str): path to a local folder to save downloaded models & weights.
    N)rd   rO   rx   rM   )r   s    r   rD   rD     s     ww!!!$Hr   c           	      V   t        | ||d||      }t        |      5  t        j                  j	                  |t
              }t        t
        |      }ddd       t              D cg c]*  }t        t        ||            r|j                  d      s|, }	}|	S # 1 sw Y   IxY wc c}w )a*	  
    List all callable entrypoints available in the repo specified by ``github``.

    Args:
        github (str): a string with format "repo_owner/repo_name[:ref]" with an optional
            ref (tag or branch). If ``ref`` is not specified, the default branch is assumed to be ``main`` if
            it exists, and otherwise ``master``.
            Example: 'pytorch/vision:0.10'
        force_reload (bool, optional): whether to discard the existing cache and force a fresh download.
            Default is ``False``.
        skip_validation (bool, optional): if ``False``, torchhub will check that the branch or commit
            specified by the ``github`` argument properly belongs to the repo owner. This will make
            requests to the GitHub API; you can specify a non-default GitHub token by setting the
            ``GITHUB_TOKEN`` environment variable. Default is ``False``.
        trust_repo (bool, str or None): ``"check"``, ``True``, ``False`` or ``None``.
            This parameter was introduced in v1.12 and helps ensuring that users
            only run code from repos that they trust.

            - If ``False``, a prompt will ask the user whether the repo should
              be trusted.
            - If ``True``, the repo will be added to the trusted list and loaded
              without requiring explicit confirmation.
            - If ``"check"``, the repo will be checked against the list of
              trusted repos in the cache. If it is not present in that list, the
              behaviour will fall back onto the ``trust_repo=False`` option.
            - If ``None``: this will raise a warning, inviting the user to set
              ``trust_repo`` to either ``False``, ``True`` or ``"check"``. This
              is only present for backward compatibility and will be removed in
              v2.0.

            Default is ``None`` and will eventually change to ``"check"`` in v2.0.
        verbose (bool, optional): If ``False``, mute messages about hitting
            local caches. Note that the message about first download cannot be
            muted. Default is ``True``.

    Returns:
        list: The available callables entrypoint

    Example:
        >>> # xdoctest: +REQUIRES(env:TORCH_DOCTEST_HUB)
        >>> entrypoints = torch.hub.list("pytorch/vision", force_reload=True)
    rA   r   r   Nr   )r   rS   rd   rO   r{   MODULE_HUBCONFrb   rr   r   rs   r   )
r   r   r   r   r   r   hubconf_path
hub_modulefentrypointss
             r   rA   rA     s    b $'H 
(	# Bww||Hn=#NLA
B ZGJ*+ALL4E 	
K  B B
s   5B'/B&B#c                     t        | ||dd|      }t        |      5  t        j                  j	                  |t
              }t        t
        |      }ddd       t        |      }|j                  S # 1 sw Y   !xY w)aT  
    Show the docstring of entrypoint ``model``.

    Args:
        github (str): a string with format <repo_owner/repo_name[:ref]> with an optional
            ref (a tag or a branch). If ``ref`` is not specified, the default branch is assumed
            to be ``main`` if it exists, and otherwise ``master``.
            Example: 'pytorch/vision:0.10'
        model (str): a string of entrypoint name defined in repo's ``hubconf.py``
        force_reload (bool, optional): whether to discard the existing cache and force a fresh download.
            Default is ``False``.
        skip_validation (bool, optional): if ``False``, torchhub will check that the ref
            specified by the ``github`` argument properly belongs to the repo owner. This will make
            requests to the GitHub API; you can specify a non-default GitHub token by setting the
            ``GITHUB_TOKEN`` environment variable. Default is ``False``.
        trust_repo (bool, str or None): ``"check"``, ``True``, ``False`` or ``None``.
            This parameter was introduced in v1.12 and helps ensuring that users
            only run code from repos that they trust.

            - If ``False``, a prompt will ask the user whether the repo should
              be trusted.
            - If ``True``, the repo will be added to the trusted list and loaded
              without requiring explicit confirmation.
            - If ``"check"``, the repo will be checked against the list of
              trusted repos in the cache. If it is not present in that list, the
              behaviour will fall back onto the ``trust_repo=False`` option.
            - If ``None``: this will raise a warning, inviting the user to set
              ``trust_repo`` to either ``False``, ``True`` or ``"check"``. This
              is only present for backward compatibility and will be removed in
              v2.0.

            Default is ``None`` and will eventually change to ``"check"`` in v2.0.
    Example:
        >>> # xdoctest: +REQUIRES(env:TORCH_DOCTEST_HUB)
        >>> print(torch.hub.help("pytorch/vision", "resnet18", force_reload=True))
    r@   Tr  N)	r   rS   rd   rO   r{   r  rb   r   __doc__)	r   r   r   r   r   r   r  r  entrys	            r   r@   r@     s|    J $'H 
(	# Bww||Hn=#NLA
B %Z7E==B Bs   5A22A;r   )sourcer   r   r   r   c                    |j                         }|dvrt        d| d      |dk(  rt        | ||d||      } t        | |g|i |}|S )a  
    Load a model from a github repo or a local directory.

    Note: Loading a model is the typical use case, but this can also be used to
    for loading other objects such as tokenizers, loss functions, etc.

    If ``source`` is 'github', ``repo_or_dir`` is expected to be
    of the form ``repo_owner/repo_name[:ref]`` with an optional
    ref (a tag or a branch).

    If ``source`` is 'local', ``repo_or_dir`` is expected to be a
    path to a local directory.

    Args:
        repo_or_dir (str): If ``source`` is 'github',
            this should correspond to a github repo with format ``repo_owner/repo_name[:ref]`` with
            an optional ref (tag or branch), for example 'pytorch/vision:0.10'. If ``ref`` is not specified,
            the default branch is assumed to be ``main`` if it exists, and otherwise ``master``.
            If ``source`` is 'local'  then it should be a path to a local directory.
        model (str): the name of a callable (entrypoint) defined in the
            repo/dir's ``hubconf.py``.
        *args (optional): the corresponding args for callable ``model``.
        source (str, optional): 'github' or 'local'. Specifies how
            ``repo_or_dir`` is to be interpreted. Default is 'github'.
        trust_repo (bool, str or None): ``"check"``, ``True``, ``False`` or ``None``.
            This parameter was introduced in v1.12 and helps ensuring that users
            only run code from repos that they trust.

            - If ``False``, a prompt will ask the user whether the repo should
              be trusted.
            - If ``True``, the repo will be added to the trusted list and loaded
              without requiring explicit confirmation.
            - If ``"check"``, the repo will be checked against the list of
              trusted repos in the cache. If it is not present in that list, the
              behaviour will fall back onto the ``trust_repo=False`` option.
            - If ``None``: this will raise a warning, inviting the user to set
              ``trust_repo`` to either ``False``, ``True`` or ``"check"``. This
              is only present for backward compatibility and will be removed in
              v2.0.

            Default is ``None`` and will eventually change to ``"check"`` in v2.0.
        force_reload (bool, optional): whether to force a fresh download of
            the github repo unconditionally. Does not have any effect if
            ``source = 'local'``. Default is ``False``.
        verbose (bool, optional): If ``False``, mute messages about hitting
            local caches. Note that the message about first download cannot be
            muted. Does not have any effect if ``source = 'local'``.
            Default is ``True``.
        skip_validation (bool, optional): if ``False``, torchhub will check that the branch or commit
            specified by the ``github`` argument properly belongs to the repo owner. This will make
            requests to the GitHub API; you can specify a non-default GitHub token by setting the
            ``GITHUB_TOKEN`` environment variable. Default is ``False``.
        **kwargs (optional): the corresponding kwargs for callable ``model``.

    Returns:
        The output of the ``model`` callable when called with the given
        ``*args`` and ``**kwargs``.

    Example:
        >>> # xdoctest: +REQUIRES(env:TORCH_DOCTEST_HUB)
        >>> # from a github repo
        >>> repo = "pytorch/vision"
        >>> model = torch.hub.load(
        ...     repo, "resnet50", weights="ResNet50_Weights.IMAGENET1K_V1"
        ... )
        >>> # from a local directory
        >>> path = "/some/local/path/pytorch/vision"
        >>> # xdoctest: +SKIP
        >>> model = torch.hub.load(path, "resnet50", weights="ResNet50_Weights.DEFAULT")
    )r   localzUnknown source: "z&". Allowed values: "github" | "local".r   rB   r  )r   r   r   _load_local)	repo_or_dirr   r  r   r   r   r   r   r   s	            r   rB   rB   %  sv    b \\^F((x'MN
 	
 *+
 U<T<V<ELr   c                     t        |       5  t        j                  j                  | t              }t        t        |      }t        ||      } ||i |}ddd       |S # 1 sw Y   |S xY w)a  
    Load a model from a local directory with a ``hubconf.py``.

    Args:
        hubconf_dir (str): path to a local directory that contains a
            ``hubconf.py``.
        model (str): name of an entrypoint defined in the directory's
            ``hubconf.py``.
        *args (optional): the corresponding args for callable ``model``.
        **kwargs (optional): the corresponding kwargs for callable ``model``.

    Returns:
        a single model with corresponding pretrained weights.

    Example:
        >>> # xdoctest: +SKIP("stub local path")
        >>> path = "/some/local/path/pytorch/vision"
        >>> model = _load_local(path, "resnet50", weights="ResNet50_Weights.IMAGENET1K_V1")
    N)rS   rd   rO   r{   r  rb   r   )hubconf_dirr   r   r   r  r  r
  s          r   r  r    se    ( 
+	& 'ww||K@#NLA
(U;t&v&' L' Ls   A	AA)r   dsthash_prefixr   c                    d}t        | ddi      }t        |      }|j                         }t        |d      r|j	                  d      }n|j                  d      }|t        |      dkD  rt        |d         }t        j                  j                  |      }t        t        j                        D ]7  }	|dz   t        j                         j                   z   d	z   }
	 t#        |
d
      } n t%        t&        j(                  d      	 |t+        j,                         }t/        || ddd      5 }	 |j1                  t2              }t        |      dk(  rn?|j5                  |       |j7                  |       |j7                  t        |             c	 ddd       |j9                          |3j;                         }|dt        |       |k7  rt=        d| d| d      t?        j@                  |jB                  |       |j9                          t        j                  jE                  |jB                        r t        jF                  |jB                         yy# t$        $ r Y w xY w# 1 sw Y   xY w# |j9                          t        j                  jE                  |jB                        r t        jF                  |jB                         w w xY w)a  Download object at the given URL to a local path.

    Args:
        url (str): URL of the object to download
        dst (str): Full path where object will be saved, e.g. ``/tmp/temporary_file``
        hash_prefix (str, optional): If not None, the SHA256 downloaded file should start with ``hash_prefix``.
            Default: None
        progress (bool, optional): whether or not to display a progress bar to stderr
            Default: True

    Example:
        >>> # xdoctest: +REQUIRES(env:TORCH_DOCTEST_HUB)
        >>> # xdoctest: +REQUIRES(POSIX)
        >>> torch.hub.download_url_to_file(
        ...     "https://s3.amazonaws.com/pytorch/models/resnet18-5c106cde.pth",
        ...     "/tmp/temporary_file",
        ... )

    Nz
User-Agentz	torch.hubr   
getheaderszContent-Lengthr   r   z.partialzw+bz#No usable temporary file name foundBTi   )r   r   r   
unit_scaleunit_divisorzinvalid hash value (expected "z", got "z"))$r   r   infohasattrr  get_allr   intrd   rO   rx   rangetempfileTMP_MAXuuiduuid4hexr   FileExistsErrorerrnoEEXISThashlibsha256r=   r   READ_DATA_CHUNKr#   r&   r2   	hexdigestr   rg   r   r^   re   rQ   )r   r  r  r   	file_sizerequmetacontent_lengthr   tmp_dstr  r'  pbarbufferdigests                   r   r>   r>     sw   2 I
#k:
;CA668Dt\")9:&67!c.&9A&=q)*	 ''

S
!C8##$ S)djjl...;	We$A 	S ell,QRR"^^%F L
 	) 0v;!#*MM&)CK(  	)  	
	"%%'F(K()[8"4[M&QST  	AFFC 		77>>!&&!IIaff "G  			) 	)2 	
	77>>!&&!IIaff "s9   I'I7 .A%I+A-I7 	I('I(+I40I7 7AKr   c                     t        j                  |       rGt        j                  |       j                         }t	        |      dk(  xr |d   j                          S y)Nr   r   F)r   
is_zipfiler   r   r   is_dir)r   r   s     r   _is_legacy_zip_formatr6    sN    (#??8,5578}!>(1+*<*<*>&>>r   zFalling back to the old format < 1.6. This support will be deprecated in favor of default zipfile format introduced in 1.6. Please redo torch.save() to save it in the new zipfile format.)category	model_dirmap_locationweights_onlyc                 X   t        j                  |       5 }|j                         }t        |      dk7  rt	        d      |j                  |       |d   j                  }t        j                  j                  ||      }d d d        t        j                  ||      S # 1 sw Y   !xY w)Nr   z0Only one file(not dir) is allowed in the zipfiler   r9  r:  )r   r   r   r   r   r   r   rd   rO   r{   rw   rB   )r   r8  r9  r:  r  membersextraced_nameextracted_files           r   _legacy_zip_loadr@    s     
	" @a**,w<1QRR	Y
++i?@ ::\ @ @s   A*B  B)
check_hash	file_namec                    t        j                  d      rt        j                  d       |*t	               }t         j
                  j                  |d      }t        j                  |d       t        |       }t         j
                  j                  |j
                        }	||}	t         j
                  j                  ||	      }
t         j
                  j                  |
      sct        j                  j                  d|  d|
 d	       d}|r*t        j                  |	      }|r|j!                  d
      nd}t#        | |
||       t%        |
      rt'        |
|||      S t)        j*                  |
||      S )aq  Loads the Torch serialized object at the given URL.

    If downloaded file is a zip file, it will be automatically
    decompressed.

    If the object is already present in `model_dir`, it's deserialized and
    returned.
    The default value of ``model_dir`` is ``<hub_dir>/checkpoints`` where
    ``hub_dir`` is the directory returned by :func:`~torch.hub.get_dir`.

    Args:
        url (str): URL of the object to download
        model_dir (str, optional): directory in which to save the object
        map_location (optional): a function or a dict specifying how to remap storage locations (see torch.load)
        progress (bool, optional): whether or not to display a progress bar to stderr.
            Default: True
        check_hash(bool, optional): If True, the filename part of the URL should follow the naming convention
            ``filename-<sha256>.ext`` where ``<sha256>`` is the first eight or more
            digits of the SHA256 hash of the contents of the file. The hash is used to
            ensure unique names and to verify the contents of the file.
            Default: False
        file_name (str, optional): name for the downloaded file. Filename from ``url`` will be used if not set.
        weights_only(bool, optional): If True, only weights will be loaded and no complex pickled objects.
            Recommended for untrusted sources. See :func:`~torch.load` for more details.

    Example:
        >>> # xdoctest: +REQUIRES(env:TORCH_DOCTEST_HUB)
        >>> state_dict = torch.hub.load_state_dict_from_url(
        ...     "https://s3.amazonaws.com/pytorch/models/resnet18-5c106cde.pth"
        ... )

    TORCH_MODEL_ZOOz@TORCH_MODEL_ZOO is deprecated, please use env TORCH_HOME insteadNcheckpointsTr   r   r   r-   r   r   r<  )rd   ry   r   r   r?   rO   r{   r   r   basenamere   r!   r"   r#   
HASH_REGEXsearchgroupr>   r6  r@  rw   rB   )r   r8  r9  r   rA  rB  r:  r   partsr   r   r  r   s                r   rC   rC   #  s&   T 
yy"#N	
 )GGLL-8	KK	D)SMEww

+H'',,y(3K77>>+&

>#eK=CD!!(+A()!''!*tKS+{XN[)YlSS::k<XXr   )TF)rB   )FFNT)FFNr0   )NNTFNF)M
contextlibr$  r&  r   rd   rerg   r!   r  r   r   r   pathlibr   typingr   r   r   r   typing_extensionsr   urllib.errorr	   r
   urllib.parser   urllib.requestr   r   rw   torch.serializationr   r   r=   ImportError__all__compilerG  r   r   rz   r|   r}   r   r  r(  rM   r   __annotations__contextmanagerrS   rb   ri   rp   ru   r   r   r   r   r   r   r   r   r   r?   PathLikerD   rA   r@   rB   r  boolr>   r6  FutureWarningr@  rC   r)   r   r   <module>r\     s       	 	  
      - - ( , ! +  ,# #L RZZ)*
  " %  (3-   	 H
& &FG
B Qr 7*t6S$2 2&%uS"++%& %4 % EP4v cLB "&	R	R	R #R 	R
 
RpC D  E 	  	
 
#s(^.  $!%#DY	DY}DY DY 	DY
 DY }DY DY 
#s(^DYE  Ds   5F FF