
    JTh{                     Z   % S SK r S SKrS SKrS SKrS SKr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JrJrJrJrJr  S SKJr  S SKrS SKJr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#  SSK$J%r%J&r&  SSK'J(r(  SSK)J*r*J+r+  SSK,J-r-  \(       a  SSK.J/r/  S/r0/ SQr1\
\2   \3S'   S\2\4S.0r5\6\2\6\2\4   4   \3S'    " S S\-5      r7\8" 5       r9Sr:\:S-   r; " S S5      r< " S S\<5      r= " S S\<5      r> " S S \<5      r?\" 5       r@\\3S!'   \R                  rBS" rC\C\lA         " S# S$5      rDg)%    N)Iterable)contextmanager)AnyCallablecastOptionalTYPE_CHECKINGUnion)WeakValueDictionary)_get_restore_location_maybe_decode_ascii)FileLike   )DirectoryReader)_calc___package___normalize_line_endings_normalize_path_resolve_name_sanity_check)demanglePackageManglerPackageUnpickler) _create_directory_from_file_list	Directory)Importer)GlobPatternPackageImporter)numpyz
numpy.coreznumpy.core._multiarray_umathbuiltinsIMPLICIT_IMPORT_ALLOWLISTr   )strbool!EXTERN_IMPORT_COMPAT_NAME_MAPPINGc                   *   \ rS rSr% Sr \\\R                  4   \	S'   S 4S\
\\R                  R                  4   S\\/\4   4S jjrS9S	\4S
 jjrS\S\S\4S jr  S:S\S\S\S\S\4
S jjrS9S\S\S\4S jjrS rSSS.SSSSS\4S jjrS rS rS	\S\\   S\S\4S  jrS	\S\4S! jrS"\S#\4S$ jr S\4S% jr!S& r"S\S	\S'\R                  4S( jr#S) r$S* r%S;S+ jr&S,S-.S. jr'S<S/ jr(S0 r)S9S1 jr*S2\+\   SS34S4 jr,S\4S5 jr-S6\4S7 jr.S8r/g)=r   B   a  Importers allow you to load code written to packages by :class:`PackageExporter`.
Code is loaded in a hermetic way, using files from the package
rather than the normal python import system. This allows
for the packaging of PyTorch model code and data so that it can be run
on a server or used in the future for transfer learning.

The importer for packages ensures that code in the module can only be loaded from
within the package, except for modules explicitly listed as external during export.
The file ``extern_modules`` in the zip archive lists all the modules that a package externally depends on.
This prevents "implicit" dependencies where the package runs locally because it is importing
a locally-installed package, but then fails when the package is copied to another machine.
modulesc                     g)NT )module_names    V/var/www/auris/envauris/lib/python3.13/site-packages/torch/package/package_importer.py<lambda>PackageImporter.<lambda>Y   s    D    file_or_buffermodule_allowedc                 0  ^  [         R                  R                  S5        T   [        U[         R                  R                  5      (       a  ST l        UT l        O[        U[        R                  [        45      (       a  [        R                  " U5      T l        [        R                  R                  T R
                  5      (       d/  [         R                  R	                  T R
                  5      T l        OF[        T R
                  5      T l        O+ST l        [         R                  R	                  U5      T l        [         R                  R                  ST R                  R                  5       T R
                  S.5        [!        S5      T l        0 T l        T R'                  5       T l        T R(                   H3  nU" U5      (       d  [+        SU SU S	35      eT R-                  U5        M5     T R                  R/                  5        H  nT R1                  U5        M     [2        R4                  R7                  5       T l        T R:                  T R8                  S
'   T T R$                  S'   [=        5       T l        ST l         ST l!        U 4S jT l"        g)a  Open ``file_or_buffer`` for importing. This checks that the imported package only requires modules
allowed by ``module_allowed``

Args:
    file_or_buffer: a file-like object (has to implement :meth:`read`, :meth:`readline`, :meth:`tell`, and :meth:`seek`),
        a string, or an ``os.PathLike`` object containing a filename.
    module_allowed (Callable[[str], bool], optional): A method to determine if a externally provided module
        should be allowed. Can be used to ensure packages loaded do not depend on modules that the server
        does not support. Defaults to allowing anything.

Raises:
    ImportError: If the package will use a disallowed module.
ztorch.package.PackageImporterz<pytorch_file_reader>z<binary>z&torch.package.PackageImporter.metadata)serialization_id	file_nameNz	package 'z' needs the external module 'z%' but that module has been disallowed
__import__torch_package_importerc                  "   > [        T/U Q70 UD6$ Nr   )argskwargsselfs     r+   r,   *PackageImporter.__init__.<locals>.<lambda>   s    1A$1X1XQW1Xr.   )#torch_C_log_api_usage_once
isinstancePyTorchFileReaderfilename
zip_readerosPathLiker"   fspathpathisdirr   _log_api_usage_metadatar2   _PackageNoderootr'   _read_externextern_modulesImportError_add_externget_all_records	_add_filer    __dict__copypatched_builtinsr4   r   _manglerstorage_contextlast_map_location	Unpickler)r:   r/   r0   extern_modulefnames   `    r+   __init__PackageImporter.__init__V   s   $ 	$$%DEnehh&@&@AA3DM,DOc(:;;IIn5DM77==//"'(("<"<T]]"K"1$--"@&DM#hh88HDO((4$(OO$D$D$F!]]	
 !&	"//1!00M!-00!//L]O \: ;  ]+ 1 __446ENN5! 7 !) 1 1 6 6 8.2ool+15-.&( %)!% Yr.   Nnamec                 Z    U R                   R                  U5      nU R                  U5      $ )a  Load a module from the package if it hasn't already been loaded, and then return
the module. Modules are loaded locally
to the importer and will appear in ``self.modules`` rather than ``sys.modules``.

Args:
    name (str): Fully qualified name of the module to load.
    package ([type], optional): Unused, but present to match the signature of importlib.import_module. Defaults to ``None``.

Returns:
    types.ModuleType: The (possibly already) loaded module.
)rT   r   _gcd_import)r:   r\   packages      r+   import_modulePackageImporter.import_module   s)    & }}%%d+%%r.   r_   resourcereturnc                 Z    U R                  X5      nU R                  R                  U5      $ )zLoad raw bytes.

Args:
    package (str): The name of module package (e.g. ``"my_package.my_subpackage"``).
    resource (str): The unique name for the resource.

Returns:
    bytes: The loaded data.
)_zipfile_pathrB   
get_record)r:   r_   rb   rF   s       r+   load_binaryPackageImporter.load_binary   s)     !!'4))$//r.   encodingerrorsc                 F    U R                  X5      nUR                  X45      $ )a^  Load a string.

Args:
    package (str): The name of module package (e.g. ``"my_package.my_subpackage"``).
    resource (str): The unique name for the resource.
    encoding (str, optional): Passed to ``decode``. Defaults to ``'utf-8'``.
    errors (str, optional): Passed to ``decode``. Defaults to ``'strict'``.

Returns:
    str: The loaded text.
)rg   decode)r:   r_   rb   ri   rj   datas         r+   	load_textPackageImporter.load_text   s#    $ 2{{8,,r.   c                    ^ ^^
^^^^ T R                  X5      n[        T5      m0 m0 m[        R                  R	                  5       mUU U4S jm
U
UUUU 4S jn[
        R                  " T R                  R                  U5      5      nT R                  U5      nXWl
        [        UU U4S j5       nU" 5          UR                  5       n	SSS5        [        R                  R                  5         W	$ ! , (       d  f       N.= f)a  Unpickles the resource from the package, loading any modules that are needed to construct the objects
using :meth:`import_module`.

Args:
    package (str): The name of module package (e.g. ``"my_package.my_subpackage"``).
    resource (str): The unique name for the resource.
    map_location: Passed to `torch.load` to determine how tensors are mapped to devices. Defaults to ``None``.

Returns:
    Any: The unpickled object.
c                 x  > U S3nT
R                  U5      (       a   T
R                  XP5      R                  5       nOsT	R                  R	                  SU-   X5      n[        T	R                  [        R                  R                  5      (       a  T
R                  XW5        UR                  5       nU" Xc5      TU'   g )Nz.storagez.data/)
has_storageget_storage_typed_storagerB   get_storage_from_recordr?   r<   r=   r@   add_storage)dtypesizekeylocationrestore_locationr\   storagetensorloaded_storagesr:   rU   s           r+   load_tensor0PackageImporter.load_pickle.<locals>.load_tensor   s    U(#D**400)55dBQQS@@tOT doouxx/I/IJJ#//= //1#3G#FOC r.   c                   > [        U [        5      (       d   e[        U S   5      nU SS  nUS:X  a~  Uu  p4pVU[        R                  L a  [        R
                  nOUR                  nUT;  a  T" UUU[        U5      T5        TU   n[        R                  R                  UR                  USS9$ US:X  a8  [        U5      S:X  a  Uu  pU	" T/U
Q76 $ Uu  pn
UT;  a  U	" T/U
Q76 TU'   TU   $ SU S	3  g )
Nr   r   r|   T)wrap_storagerw   	_internalreduce_package   zVUnknown typename for persistent_load, expected 'storage' or 'reduce_package' but got '')r?   tupler   r<   UntypedStorageuint8rw   r|   TypedStorage_untyped_storagelen)saved_idtypenamerm   storage_typery   rz   rx   rw   r|   funcr8   	reduce_idr   loaded_reducesr~   r{   r:   s               r+   persistent_load4PackageImporter.load_pickle.<locals>.persistent_load   s.   h....*8A;7HAB<D9$48185#7#77!KKE(..Eo-+H5( *#. }}11!(!9!9RV 2   -- t9>!%JD,t,,(,%	N204T0AD0AN9-%i00hiqhrrstr.   c               3   v   >#    TTl         T Tl         S v   S Tl         S Tl        g ! S Tl         S Tl        f = f7fr7   )rU   rV   )map_locationr:   rU   s   r+   set_deserialization_context@PackageImporter.load_pickle.<locals>.set_deserialization_context#  sC      $3D %1D".'+$)-& (,$)-&s   9& 969N)re   r   r<   r=   DeserializationStorageContextioBytesIOrB   rf   rW   r   r   load_utils_validate_loaded_sparse_tensors)r:   r_   rb   r   pickle_filer   	data_file	unpicklerr   resultr   r   r~   r{   rU   s   `  `      @@@@@r+   load_picklePackageImporter.load_pickle   s     ((;0>((@@B	G%	u %	uP JJt99+FG	NN9-	$3!		. 
	. )*^^%F + 	446 +*s   6C//
C=c                 6    U R                   R                  5       $ )z
Returns internal identifier that torch.package uses to distinguish :class:`PackageImporter` instances.
Looks like::

    <torch_package_0>
)rT   parent_namer:   s    r+   idPackageImporter.id9  s     }}((**r.   z**r)   )includeexcluder   r   r   c                `    [        U R                  U R                  R                  5       X5      $ )a  Returns a file structure representation of package's zipfile.

Args:
    include (Union[List[str], str]): An optional string e.g. ``"my_package.my_subpackage"``, or optional list of strings
        for the names of the files to be included in the zipfile representation. This can also be
        a glob-style pattern, as described in :meth:`PackageExporter.mock`

    exclude (Union[List[str], str]): An optional pattern that excludes files whose name match the pattern.

Returns:
    :class:`Directory`
)r   rA   rB   rO   )r:   r   r   s      r+   file_structurePackageImporter.file_structureB  s)     0MM4??::<g
 	
r.   c                     SnU R                   R                  U5      (       a8  U R                   R                  U5      R                  S5      R	                  5       $ S$ )a-  Returns the version of python that was used to create this package.

Note: this function is experimental and not Forward Compatible. The plan is to move this into a lock
file later on.

Returns:
    :class:`Optional[str]` a python version e.g. 3.8.9 or None if no version was stored with this package
z.data/python_versionutf-8N)rB   
has_recordrf   rl   strip)r:   python_version_paths     r+   python_versionPackageImporter.python_versionU  sZ     5 ))*=>> OO&&':;BB7KQQS	
 	
r.   c                 p    U R                   R                  S5      R                  S5      R                  SS9$ )Nz.data/extern_modulesr   F)keepends)rB   rf   rl   
splitlinesr   s    r+   rK   PackageImporter._read_externe  s/    OO&&'=>VG_ZZ'	
r.   rA   
is_packageparentc                    U(       a  U R                   R                  U5      OS n[        R                  R	                  UU SUS9n[        R
                  R                  U5      nXpR                  U'   U R                   R                  U5      Ul        UR                  nXhS'   XS'   XXS'   S US'   U R                  US'   SUS	'   UR                  [        ;  d   eU[        UR                  '   U R                  XAU5        UbM  Uc   eU[        R                  ;  d   e[        R                  " XX5        U R!                  X%5      n	[#        X5        U$ )
Nz<package_importer>)originr   __spec__
__loader____file__
__cached____builtins__T__torch_package__)rT   mangle	importlib	machinery
ModuleSpecutilmodule_from_specr'   __name__rQ   rS   _package_imported_modules_install_on_parent	linecachecache	lazycache_compile_sourceexec)
r:   r\   rA   r   r   mangled_filenamespecmodulenscodes
             r+   _make_modulePackageImporter._make_modulel  sH    >F4==//94""--'!	 . 
 006#T--..t4__:<):<!22>"& &????5;!&//2 	f5#/// 9??222 05''CDNr.   c           	         U R                   nUR                  S5       GH  n[        U[        5      (       a  XCR                  ;  aY  U[
        ;   a(  [        R                  " U5      =oPR                  U'   Us  $ [        SU SU R                   SU R                   3US9eUR                  U   n[        U[        5      (       d  M  [        R                  " U5      =oPR                  U'   [        R                  U5      =n(       a4  UR                  5        H   u  pxUR                   R#                  Xx5        M"     Us  $    U R%                  XR&                  [        U[        5      U5      $ )N.zNo module named "z" in self-contained archive "zF" and the module is also not in the list of allowed external modules: r\   )rJ   splitr?   rI   childrenr!   r   r`   r'   ModuleNotFoundErrorrA   rL   _ExternNoder$   getitemsrQ   
setdefaultr   source_file)	r:   r\   r   curatomr   compat_mappingold_namenew_names	            r+   _load_modulePackageImporter._load_module  s:   JJsODc<00D4L442;2I2I$2OOF\\$/!M)'v-J4==/ Z\\`\o\o[pr 
 ,,t$C#{++.7.E.Ed.KKd+%F%J%J4%PP>P.<.B.B.D*228F /E % $&   
38UW]^^r.   fullpathr   c                 d    U R                   R                  U5      n[        U5      n[        X2SSS9$ )Nr   T)dont_inherit)rB   rf   r   compile)r:   r   r   sources       r+   r   PackageImporter._compile_source  s/    ++H5(0vdKKr.   c                     U R                  [        U5      5      nU R                  R                  [        UR                  5      5      R                  S5      $ )Nr   )r`   r   rB   rf   r   rl   )r:   r*   r   s      r+   
get_sourcePackageImporter.get_source  s@    ##H[$9:))(6??*CDKKGTTr.   c                 |     U R                  U5      nUR                  U La  g [        X5      $ ! [         a     g f = fr7   )_get_packagerM   r   _PackageResourceReader)r:   fullnamer_   s      r+   get_resource_reader#PackageImporter.get_resource_reader  sI    	''1G T)%d55	  		s   . 
;;r   c                     U(       d  g U R                   U   nUR                  U L a  [        XBR                  S5      S   U5        g g )Nr   r   )r'   r   setattr
rpartition)r:   r   r\   r   parent_modules        r+   r   "PackageImporter._install_on_parent  sA    V,##t+M??3#7#:FC ,r.   c                 @   UR                  S5      S   nUR                  S5      S   nU(       aZ  X R                  ;  a  U R                  U5        XR                  ;   a  U R                  U   $ U R                  U   n UR                    U R%                  X5      nU R'                  X!U5        U$ ! [         a    [        UR                  [        R                  R                  5      (       a  XR                  ;  a"  [        S-   R                  X5      n[        XQS9S e[        UR                  R                  U5      [         R"                  5      (       d#  [        S-   R                  XU5      n[        XQS9S e N[        S-   R                  X5      n[        XQS9S ef = f)Nr   r   z; {!r} is a c extension module which was not externed. C extension modules                             need to be externed by the PackageExporter in order to be used as we do not support interning them.}.r   z<; {!r} is a c extension package which does not contain {!r}.z; {!r} is not a package)r   r'   r^   __path__AttributeErrorr?   r   r   r   ExtensionFileLoaderrL   _ERR_MSGformatr   rQ   r   types
ModuleTyper   r   )r:   r\   r   module_name_no_parentr   msgr   s          r+   _do_find_and_load!PackageImporter._do_find_and_load  s   %a( $ 4R 8\\)  (||#||D)) LL0MH&&< ""40f5A " H !,,'';;  #6#66$CC !&,	 
 2#AtK%%..223HI(( 
 %\] &t4  2#AtK $&??GGUC-c=4G5Hs   >B/ /C	F:#Fc                    U R                   R                  U[        5      nU[        L a  U R                  U5      $ Uc  SU S3n[	        X1S9eUS:X  a)  [        [        U5      R                  U R                   S'   U$ US:X  ab  [        R                  S:  aN  [        [        U5      R                  U R                   S'   [        [        U5      R                  U R                   S	'   U$ )
Nz
import of z halted; None in sys.modulesr   rC   zos.pathtyping)      z	typing.ioz	typing.re)r'   r   _NEEDS_LOADINGr
  r   r   r   rF   sysversion_infor   re)r:   r\   r   messages       r+   _find_and_loadPackageImporter._find_and_load  s    !!$7^#))$//>"4&(DEG%g99
 4<&*3&7&<&<DLL#  X'),0f,=,@,@[),0f,=,@,@[)r.   c                 `    [        XU5        US:  a  [        XU5      nU R                  U5      $ )a  Import and return the module based on its name, the package the call is
being made from, and the level adjustment.

This function represents the greatest common denominator of functionality
between import_module and __import__. This includes setting __package__ if
the loader did not.

r   )r   r   r  )r:   r\   r_   levels       r+   r^   PackageImporter._gcd_import  s2     	dU+19 6D""4((r.   F	recursivec          	      Z   [        UR                  5      n[        US5      (       a  U H  n[        U[        5      (       d3  U(       a  US-   nOSn[        SU S[        U5      R                   35      eUS:X  a8  U(       d/  [        US5      (       a  U R                  XR                  SS	9  M  M  M  [        X5      (       a  M  U S
U 3n U R                  U5        M     U$ ! [         a=  nUR                  U:X  a'  U R                  R                  U[        5      b   SnAM  e SnAff = f)zFigure out what __import__ should return.

The import_ parameter is a callable which takes the name of module to
import. It is required to decouple the function from assuming importlib's
import implementation is desired.

r  z.__all__z``from list''zItem in z must be str, not *__all__Tr  r   N)r   r   hasattrr?   r"   	TypeErrortype_handle_fromlistr  r^   r   r\   r'   r   r  )	r:   r   fromlistr  r*   xwhere	from_nameexcs	            r+   r"   PackageImporter._handle_fromlist"  s    v/ 6:&&!!S))  +j 8 /#"5');DG<L<L;MN  #X$)C)C--fnnPT-U *D9 ++#.-q 4I((3 4  / 	
  HH	1 $ 0 0N K W$	s   C##
D*-1D%$D%%D*c                    US:X  a  U R                  U5      nO$Ub  UO0 n[        U5      nU R                  XU5      nU(       d  US:X  a#  U R                  UR                  S5      S   5      $ U(       d  U$ [        U5      [        UR                  S5      S   5      -
  n	[	        UR
                  5      n
U R                  U
S [        U
5      U	-
      $ U R                  Xd5      $ )Nr   r   )r^   r   	partitionr   r   r   r'   r"  )r:   r\   globalslocalsr#  r  r   globals_r_   cut_offr*   s              r+   r4   PackageImporter.__import__J  s    A:%%d+F")"5w2H'1G%%dU;F z''s(;A(>?? d)c$..*=a*@&AA 'v7||K0L#k2BW2L$MNN((::r.   c                    [        US5      (       a<  UR                  R                  c#  [        UR                  R                  < S35      eU$ U R                  U5      nUR                  R                  c  [        U< S35      eU$ )zTake a package name or module object and return the module.

If a name, the module is imported.  If the passed or imported module
object is not a package, raise an exception.
r   z is not a package)r  r   submodule_search_locationsr   r\   r`   )r:   r_   r   s      r+   r   PackageImporter._get_packagec  s     7J''::B7#3#3#8#8";;L MNN''0F99A7+-> ?@@r.   c                     U R                  U5      nUR                  U L d   e[        UR                  5      nUb"  [	        U5      nUR                  SS5       SU 3$ UR                  SS5       $ )Nr   /)r   r   r   r   r   replace)r:   r_   rb   r\   s       r+   re   PackageImporter._zipfile_pathu  sw    ##G,!!T)))(()&x0Hll3,-Qxj99ll3,-.r.   atomsz Union[_PackageNode, _ExternNode]c                    U R                   n[        U5       H  u  p4UR                  R                  US 5      nUc  [	        S 5      =oRR                  U'   [        U[        5      (       a  Us  $ [        U[        5      (       a#  SR                  US U 5      n[        SU S35      e[        U[        5      (       d   eUnM     U$ )Nr   z&inconsistent module structure. module z% is not a package, but has submodules)
rJ   	enumerater   r   rI   r?   r   _ModuleNodejoinrM   )r:   r7  r   ir   noder\   s          r+   _get_or_create_package&PackageImporter._get_or_create_package  s     ii 'GA<<##D$/D|,8,>>||D)$,,$,,xxbq	*!<TFBgh  dL1111C ( 
r.   c                 \   UR                  S5      Gt p#[        U5      S:  a
  US   S:X  a  gU R                  U5      n[        U[        5      (       a  [        SU S35      eUS:X  a  Xl        gUR                  S	5      (       a(  US[        S	5      *  n[        U5      UR                  U'   gg)
zAssembles a Python module out of the given file. Will ignore files in the .data directory.

Args:
    filename (str): the name of the file inside of the package archive to be added
r4  r   r   z.dataNz>inconsistent module structure. package contains a module file z2 that is a subpackage of a module marked external.z__init__.pyz.py)
r   r   r>  r?   r   rM   r   endswithr:  r   )r:   rA   prefixlastr_   package_names         r+   rP   PackageImporter._add_file  s     !s+v;?vayG3--f5g{++PQYPZDF  = "*]]5!!3u:+.L-8-BG\* "r.   extern_namec                     UR                  S5      Gt p#U R                  U5      n[        U[        5      (       a  g [        5       UR                  U'   g )Nr   )r   r>  r?   r   r   )r:   rF  rB  rC  r_   s        r+   rN   PackageImporter._add_extern  sF    #))#.--f5g{++!,r.   )
rW   rT   rL   rA   rV   r'   rS   rJ   rU   rB   r7   )r   strict)Nr   )NNr)   r   )0r   
__module____qualname____firstlineno____doc__dictr"   r  r  __annotations__r
   r   r<   r=   r@   r   r#   rZ   r`   bytesrg   rn   r   r   r   r   r   r   rK   r   r   r   r   r   r   r   r
  r  r^   r"  r4   r   re   listr>  rP   rN   __static_attributes__r)   r.   r+   r   r   B   s    #u'''((
 1IEYh(B(BBCEY !#-EYN&# &.03 0# 0% 0$  -- - 	-
 - 
-*`3 `# `S `D+ +/
'
9F
	
&
 
''#+C='>B'LO'R_ _c _.L Ls LU U6D DC DAQAQ D.b*)  ?D &P;2$/#Y	+&C# C*/s /r.   zNo module named z{!r}c                       \ rS rSrSrg)	_PathNodei  r)   Nr   rJ  rK  rL  rR  r)   r.   r+   rT  rT        r.   rT  c                   (    \ rS rSrS\\   4S jrSrg)rI   i  r   c                     Xl         0 U l        g r7   )r   r   r:   r   s     r+   rZ   _PackageNode.__init__  s    &.0r.   )r   r   N)r   rJ  rK  rL  r   r"   rZ   rR  r)   r.   r+   rI   rI     s    1HSM 1r.   rI   c                   (    \ rS rSrS/rS\4S jrSrg)r:  i  r   c                     Xl         g r7   r   rY  s     r+   rZ   _ModuleNode.__init__  s    &r.   r]  N)r   rJ  rK  rL  	__slots__r"   rZ   rR  r)   r.   r+   r:  r:    s    I'C 'r.   r:  c                       \ rS rSrSrg)r   i  r)   NrU  r)   r.   r+   r   r     rV  r.   r   r   c                     [         R                  " U 5      (       a1  U R                  [        ;   a  [        U R                     R                  $ [        U 5      $ r7   )inspectisclassrJ  r   r   _orig_getfile)objects    r+   _patched_getfilerf    sB    v 99,V->->?HHH  r.   c                   6    \ rS rSrSrS rS rS rS rS r	Sr
g	)
r   i  zPrivate class used to support PackageImporter.get_resource_reader().

Confirms to the importlib.abc.ResourceReader interface. Allowed to access
the innards of PackageImporter.
c                     Xl         X l        g r7   )importerr   )r:   ri  r   s      r+   rZ   _PackageResourceReader.__init__  s      r.   c                 f    SSK Jn  U" U R                  R                  U R                  U5      5      $ )Nr   )r   )r   r   ri  rg   r   )r:   rb   r   s      r+   open_resource$_PackageResourceReader.open_resource  s%    t}}00IJJr.   c                    [        U R                  R                  [        5      (       a  U R                  R                  R	                  [
        R                  R                  U R                  U5      5      (       aI  [
        R                  R                  U R                  R                  R                  U R                  U5      $ [        er7   )r?   ri  rB   r   r   rC   rF   r;  r   	directoryFileNotFoundError)r:   rb   s     r+   resource_path$_PackageResourceReader.resource_path  s     MM$$o
 
mm&&11GGLL1
 
 77<<((22DMM8   r.   c                     U R                   R                  U R                  U5      nU R                   R                  R	                  U5      $ r7   )ri  re   r   rB   r   )r:   r\   rF   s      r+   is_resource"_PackageResourceReader.is_resource  s7    }}**4==$?}}''22488r.   c              #     #    SSK Jn  U R                  R                  SS5      nU" U R                  R                  U R                  5      5      nU R                  R                  R                  5       n[        5       nU Hl  n U" U5      R                  U5      nUR                  R                  n[        U5      S:X  a  UR                  v   MP  Xu;  d  MW  UR                  U5        Uv   Mn     g ! [         a     M~  f = f7f)Nr   )Pathr   r4  )pathlibrw  r   r5  ri  re   rB   rO   setrelative_to
ValueErrorr   r\   r   add)r:   rw  rA   fullname_pathfilessubdirs_seenrelativer   s           r+   contents_PackageResourceReader.contents  s      ==((c2T]]88GH((88:uH>55mD #//..K;1$mm#0  -!!   s0   BDC18DD1
C?;D>C??D)r   ri  N)r   rJ  rK  rL  rM  rZ   rl  rq  rt  r  rR  r)   r.   r+   r   r     s!    !K
 9"r.   r   )Er    r   importlib.machineryrb  r   r   rC   r  r  collections.abcr   
contextlibr   r  r   r   r   r   r	   r
   weakrefr   r<   torch.serializationr   r   torch.typesr   _directory_readerr   
_importlibr   r   r   r   r   	_manglingr   r   _package_unpicklerr   file_structure_representationr   r   ri  r   
glob_groupr   r  r!   r"   rO  r#   r$   rN  r   re  r  _ERR_MSG_PREFIXr  rT  rI   r:  r   r   getfilerd  rf  r   r)   r.   r+   <module>r     s2       	  	 
  $ % F F '  J   .  0 0 V  '
, 8C=  @ !4T#s(^(;#< j	/h j	/Z $V#	 	19 1') '	) 	
 2E1F . F ! #7" 7"r.   