§
    Ë²Åj¹#  ã                   ó  — d dl Z d dlmZmZ d dlmZmZmZ d dl	m
Z
 d dlmZmZmZmZmZ ddlmZmZmZ g d¢Z G d	„ d
e¦  «        Z G d„ de¦  «        Z G d„ de¦  «        Z G d„ de¦  «        Z e¦   «         Z G d„ de¦  «        ZdS )é    N)ÚABCÚabstractmethod)Ú_getattributeÚ_PicklerÚwhichmodule)Ú
ModuleType)ÚAnyÚDictÚListÚOptionalÚTupleé   )ÚdemangleÚget_mangle_prefixÚ
is_mangled)ÚObjNotFoundErrorÚObjMismatchErrorÚImporterÚOrderedImporterc                   ó   — e Zd ZdZdS )r   zHRaised when an importer cannot find an object by searching for its name.N©Ú__name__Ú
__module__Ú__qualname__Ú__doc__© ó    úGC:\Projects\Historical\venv\Lib\site-packages\torch/package/importer.pyr   r      s   € € € € € ØRÐRÐRÐRr   r   c                   ó   — e Zd ZdZdS )r   z]Raised when an importer found a different object with the same name as the user-provided one.Nr   r   r   r   r   r      s   € € € € € ØgÐgÐgÐgr   r   c            	       ó”   — e Zd ZU dZeeef         ed<   ededefd„¦   «         Z	dde
dee         deeef         fd	„Zde
dedefd
„ZdS )r   ad  Represents an environment to import modules from.

    By default, you can figure out what module an object belongs by checking
    __module__ and importing the result using __import__ or importlib.import_module.

    torch.package introduces module importers other than the default one.
    Each PackageImporter introduces a new namespace. Potentially a single
    name (e.g. 'foo.bar') is present in multiple namespaces.

    It supports two main operations:
        import_module: module_name -> module object
        get_name: object -> (parent module name, name of obj within module)

    The guarantee is that following round-trip will succeed or throw an ObjNotFoundError/ObjMisMatchError.
        module_name, obj_name = env.get_name(obj)
        module = env.import_module(module_name)
        obj2 = getattr(module, obj_name)
        assert obj1 is obj2
    ÚmodulesÚmodule_nameÚreturnc                 ó   — dS )zvImport `module_name` from this environment.

        The contract is the same as for importlib.import_module.
        Nr   ©Úselfr"   s     r   Úimport_modulezImporter.import_module1   s   € € € r   NÚobjÚnamec                 óÎ  ‡ ‡— ‰€t|rrt           j                             t          |¦  «        ¦  «        €Ft	          |dd¦  «        }|�3	  |¦   «         }t          |t          ¦  «        r|Šn# t          $ r Y nw xY w‰€t	          |dd¦  «        Š‰€|j        Š‰  	                    |‰¦  «        }t          |¦  «        }	 ‰                      |¦  «        }t          |‰¦  «        \  }}	n3# t          t          t          f$ r t!          |› d|› d‰› �¦  «        d‚w xY w||u r|‰fS ˆˆ fd„}
 |
|¦  «        \  }}} |
|¦  «        \  }}}d|› d|› d	|› d
|› d|› d|› d�}t#          |¦  «        ‚)ai  Given an object, return a name that can be used to retrieve the
        object from this environment.

        Args:
            obj: An object to get the module-environment-relative name for.
            name: If set, use this name instead of looking up __name__ or __qualname__ on `obj`.
                This is only here to match how Pickler handles __reduce__ functions that return a string,
                don't use otherwise.
        Returns:
            A tuple (parent_module_name, attr_name) that can be used to retrieve `obj` from this environment.
            Use it like:
                mod = importer.import_module(parent_module_name)
                obj = getattr(mod, attr_name)

        Raises:
            ObjNotFoundError: we couldn't retrieve `obj by name.
            ObjMisMatchError: we found a different object with the same name as `obj`.
        NÚ
__reduce__r   z was not found as ú.c                 ó²   •— ‰€J ‚‰                      | ‰¦  «        }t          |¦  «        }|rt          |¦  «        nd}|rdt          |¦  «        › �nd}|||fS )Nzthe current Python environmentzthe importer for z'sys_importer')r   r   r   )r(   r"   Úis_mangled_ÚlocationÚimporter_namer)   r&   s        €€r   Úget_obj_infoz'Importer.get_name.<locals>.get_obj_infon   s‰   ø€ ØÐ#Ð#Ð#Ø×*Ò*¨3°Ñ5Ô5ˆKÝ$ [Ñ1Ô1ˆKð ð6Õ! +Ñ.Ô.Ð.à5ð ð ð&ÐDÕ$5°kÑ$BÔ$BÐDÐDÐDà%ð ð
  ¨-Ð7Ð7r   z

The object provided is from 'z', which is coming from z.
However, when we import 'z', it's coming from z@.
To fix this, make sure this 'PackageExporter's importer lists z before )r   ÚdispatchÚgetÚtypeÚgetattrÚ
isinstanceÚstrÚ	Exceptionr   r   r   r'   r   ÚImportErrorÚKeyErrorÚAttributeErrorr   r   )r&   r(   r)   ÚreduceÚrvÚorig_module_namer"   ÚmoduleÚobj2Ú_r1   Úobj_module_nameÚobj_locationÚobj_importer_nameÚobj2_module_nameÚobj2_locationÚobj2_importer_nameÚmsgs   ` `               r   Úget_namezImporter.get_name8   s5  øø€ ð& ˆ<˜Cˆ<¥HÔ$5×$9Ò$9½$¸s¹)¼)Ñ$DÔ$DÐ$Lõ ˜S ,°Ñ5Ô5ˆFØÐ!ðØ˜™œ�BÝ! "¥cÑ*Ô*ð "Ø!˜øøÝ ð ð ð Ø�Dðøøøàˆ<Ý˜3 °Ñ5Ô5ˆDØˆ<Ø”<ˆDà×+Ò+¨C°Ñ6Ô6Ðõ Ð/Ñ0Ô0ˆð	Ø×'Ò'¨Ñ4Ô4ˆFÝ# F¨DÑ1Ô1‰GˆD�!�!øÝ�X¥~Ð6ð 	ð 	ð 	Ý"ØÐ>Ð>¨+Ð>Ð>¸Ð>Ð>ñô àðð	øøøð
 �$ˆ;ˆ;Ø Ð$Ð$ð	8ð 	8ð 	8ð 	8ð 	8ð 	8ð  <H¸<ÈÑ;LÔ;LÑ8ˆ˜Ð'8Ø>J¸lÈ4Ñ>PÔ>PÑ;Ð˜-Ð);ð@°ð @ð @Ø$0ð@ð @à*:ð@ð @àP]ð@ð @ð !ð	@ð @ð +=ð	@ð @ð @ð 	õ ˜sÑ#Ô#Ð#s   Á!A) Á)
A6Á5A6Â;(C$ Ã$0Dc                 ó
  — t          |dd¦  «        }|�|S | j                             ¦   «                              ¦   «         D ]A\  }}|dk    s|dk    s|€Œ	 t	          ||¦  «        d         |u r|c S Œ2# t
          $ r Y Œ>w xY wdS )a  Find the module name an object belongs to.

        This should be considered internal for end-users, but developers of
        an importer can override it to customize the behavior.

        Taken from pickle.py, but modified to exclude the search into sys.modules
        r   NÚ__main__Ú__mp_main__r   )r5   r!   ÚcopyÚitemsr   r;   )r&   r(   r)   r"   r?   s        r   r   zImporter.whichmodule‰   sÆ   € õ ˜c <°Ñ6Ô6ˆØÐ"ØÐð $(¤<×#4Ò#4Ñ#6Ô#6×#<Ò#<Ñ#>Ô#>ð 	ð 	ÑˆK˜à˜zÒ)Ð)Ø -Ò/Ð/Ø�>àðÝ  ¨Ñ.Ô.¨qÔ1°SÐ8Ð8Ø&Ð&Ð&Ð&ð 9øå!ð ð ð Ø�ðøøøð ˆzs   ÁA3Á3
B Á?B ©N)r   r   r   r   r
   r7   r   Ú__annotations__r   r'   r	   r   r   rI   r   r   r   r   r   r      sÏ   € € € € € € ðð ð( �#�z�/Ô"Ð"Ð"Ñ"àð¨ð °ð ð ð ñ „^ððO$ð O$˜Cð O$ x°¤}ð O$ÀÀcÈ3ÀhÄð O$ð O$ð O$ð O$ðb˜sð ¨#ð °#ð ð ð ð ð ð r   r   c                   ó2   — e Zd ZdZdefd„Zdededefd„ZdS )	Ú_SysImporterz;An importer that implements the default behavior of Python.r"   c                 ó*   — t          j        |¦  «        S rO   )Ú	importlibr'   r%   s     r   r'   z_SysImporter.import_moduleª   s   € ÝÔ& {Ñ3Ô3Ð3r   r(   r)   r#   c                 ó"   — t          ||¦  «        S rO   )Ú_pickle_whichmodule)r&   r(   r)   s      r   r   z_SysImporter.whichmodule­   s   € Ý" 3¨Ñ-Ô-Ð-r   N)r   r   r   r   r7   r'   r	   r   r   r   r   rR   rR   §   s^   € € € € € ØEÐEð4¨ð 4ð 4ð 4ð 4ð.˜sð .¨#ð .°#ð .ð .ð .ð .ð .ð .r   rR   c                   óB   — e Zd ZdZd„ Zd„ Zdedefd„Zde	dedefd	„Z
d
S )r   z—A compound importer that takes a list of importers and tries them one at a time.

    The first importer in the list that returns a result "wins".
    c                 ó.   — t          |¦  «        | _        d S rO   )ÚlistÚ
_importers)r&   Úargss     r   Ú__init__zOrderedImporter.__init__º   s   € Ý*.¨t©*¬*ˆŒˆˆr   c                 ó‚   — t          |dd¦  «        sdS t          |d¦  «        sdS t          |d¦  «        sdS |j        du S )aà  Returns true iff this module is an empty PackageNode in a torch.package.

        If you intern `a.b` but never use `a` in your code, then `a` will be an
        empty module with no source. This can break cases where we are trying to
        re-package an object after adding a real dependency on `a`, since
        OrderedImportere will resolve `a` to the dummy package and stop there.

        See: https://github.com/pytorch/pytorch/pull/71520#issuecomment-1029603769
        Ú__torch_package__FÚ__path__Ú__file__TN)r5   Úhasattrr`   )r&   r?   s     r   Ú_is_torchpackage_dummyz&OrderedImporter._is_torchpackage_dummy½   sY   € õ �vÐ2°EÑ:Ô:ð 	Ø�5Ý�v˜zÑ*Ô*ð 	Ø�5Ý�v˜zÑ*Ô*ð 	Ø�4ØŒ $Ð&Ð&r   r"   r#   c                 ó  — d }| j         D ]q}t          |t          ¦  «        st          |› d�¦  «        ‚	 |                     |¦  «        }|                      |¦  «        rŒU|c S # t          $ r}|}Y d }~Œjd }~ww xY w|�|‚t          |¦  «        ‚)NzP is not a Importer. All importers in OrderedImporter must inherit from Importer.)rZ   r6   r   Ú	TypeErrorr'   rb   ÚModuleNotFoundError)r&   r"   Úlast_errÚimporterr?   Úerrs         r   r'   zOrderedImporter.import_moduleÏ   sÔ   € ØˆØœð 	ð 	ˆHÝ˜h­Ñ1Ô1ð ÝØð Sð Sð Sñô ð ðØ!×/Ò/°Ñ<Ô<�Ø×.Ò.¨vÑ6Ô6ð ØØ���øÝ&ð ð ð Ø������øøøøðøøøð ÐØˆNå% kÑ2Ô2Ð2s   ´*A#ÁA#Á#
A9Á-A4Á4A9r(   r)   c                 óZ   — | j         D ]"}|                     ||¦  «        }|dk    r|c S Œ#dS )NrK   )rZ   r   )r&   r(   r)   rg   r"   s        r   r   zOrderedImporter.whichmoduleä   sK   € Øœð 	#ð 	#ˆHØ"×.Ò.¨s°DÑ9Ô9ˆKØ˜jÒ(Ð(Ø"Ð"Ð"Ð"ð )ð ˆzr   N)r   r   r   r   r\   rb   r7   r   r'   r	   r   r   r   r   r   r   ´   s‡   € € € € € ðð ð
5ð 5ð 5ð'ð 'ð 'ð$3¨ð 3°ð 3ð 3ð 3ð 3ð*˜sð ¨#ð °#ð ð ð ð ð ð r   r   )rT   Úabcr   r   Úpickler   r   r   rV   Útypesr   Útypingr	   r
   r   r   r   Ú	_manglingr   r   r   Ú__all__r8   r   r   r   rR   Úsys_importerr   r   r   r   ú<module>rq      sÇ  ðà Ð Ð Ð Ø #Ð #Ð #Ð #Ð #Ð #Ð #Ð #ðð ð ð ð ð ð ð ð ð ð
 Ð Ð Ð Ð Ð Ø 3Ð 3Ð 3Ð 3Ð 3Ð 3Ð 3Ð 3Ð 3Ð 3Ð 3Ð 3Ð 3Ð 3à >Ð >Ð >Ð >Ð >Ð >Ð >Ð >Ð >Ð >ð RÐ
QÐ
Q€ðSð Sð Sð Sð S�yñ Sô Sð Sðhð hð hð hð h�yñ hô hð hðJð Jð Jð Jð Jˆsñ Jô Jð JðZ.ð .ð .ð .ð .�8ñ .ô .ð .ð ˆ|‰~Œ~€ð6ð 6ð 6ð 6ð 6�hñ 6ô 6ð 6ð 6ð 6r   