ó
    "Eñiÿ'  ã                   ó  • S SK r S SKrS SKrS SKJrJr  S SKJrJrJ	r
  S SKJr  S SKJr  SSKJrJrJr  / SQr\R(                  " \5      r " S	 S
\5      r " S S\5      r " S S\5      r " S S\5      r\" 5       r " S S\5      rg)é    N)ÚABCÚabstractmethod)Ú_getattributeÚ_PicklerÚwhichmodule)Ú
ModuleType)ÚAnyé   )ÚdemangleÚget_mangle_prefixÚ
is_mangled)ÚObjNotFoundErrorÚObjMismatchErrorÚImporterÚOrderedImporterc                   ó   • \ rS rSrSrSrg)r   é   zHRaised when an importer cannot find an object by searching for its name.© N©Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__Ú__static_attributes__r   ó    ÚS/home/mande/repo/quber/.venv/lib/python3.13/site-packages/torch/package/importer.pyr   r      s   † ÜRr   r   c                   ó   • \ rS rSrSrSrg)r   é   z]Raised when an importer found a different object with the same name as the user-provided one.r   Nr   r   r   r   r   r      s   † Ügr   r   c            	       óŠ   • \ rS rSr% Sr\\\4   \S'   \	S\S\4S j5       r
SS\S	\S-  S\\\4   4S
 jjrS\S	\S\4S jrSrg)r   é   a,  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                 ó   • g)zfImport `module_name` from this environment.

The contract is the same as for importlib.import_module.
Nr   ©Úselfr#   s     r   Úimport_moduleÚImporter.import_module3   s   � r   NÚobjÚnamec                 óè  ^ ^• Tc_  U(       aX  [         R                  R                  [        U5      5      c/  [	        USS5      nUb   U" 5       n[        U[        5      (       a  UmTc  [	        USS5      mTc  UR                  mT R                  UT5      n[        U5      n T R                  U5      n[        R                  S:¼  a  [        UTR                  S5      5      nO[        UT5      u  p‰ XL a  UT4$ UU 4S jn
U
" U5      u  p¼nU
" U5      u  pïnSU S	U S
U SU SU SU S3n[)        U5      e! [         a     NÞf = f! [         ["        [$        4 a    ['        U SU ST 35      Sef = f)añ  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                 ó¸   >• Tc  [        S5      eTR                  U T5      n[        U5      nU(       a  [        U5      OSnU(       a  S[        U5       3OSnXU4$ )Nzname must not be Nonezthe current Python environmentzthe importer for z'sys_importer')ÚAssertionErrorr   r   r   )r*   r#   Úis_mangled_ÚlocationÚimporter_namer+   r'   s        €€r   Úget_obj_infoÚ'Importer.get_name.<locals>.get_obj_infou   st   ø€ Ø‰|Ü$Ð%<Ó=Ð=Ø×*Ñ*¨3°Ó5ˆKÜ$ [Ó1ˆKö ô " +Ô.à5ð ö ð $Ô$5°kÓ$BÐ#CÑ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(   ÚsysÚversion_infor   ÚsplitÚImportErrorÚKeyErrorÚAttributeErrorr   r   )r'   r*   r+   ÚreduceÚrvÚorig_module_namer#   ÚmoduleÚobj2Ú_r6   Úobj_module_nameÚobj_locationÚobj_importer_nameÚobj2_module_nameÚobj2_locationÚobj2_importer_nameÚmsgs   ` `               r   Úget_nameÚImporter.get_name:   sÇ  ù€ ð& ‰<žC¤H×$5Ñ$5×$9Ñ$9¼$¸s»)Ó$DÑ$Lô ˜S ,°Ó5ˆFØÑ!ðÙ›�BÜ! "¤c×*Ñ*Ø!˜ð ‰<Ü˜3 °Ó5ˆDØ‰<Ø—<‘<ˆDà×+Ñ+¨C°Ó6Ðô Ð/Ó0ˆð	Ø×'Ñ'¨Ó4ˆFÜ×Ñ 7Ó*ô % V¨T¯Z©Z¸«_Ó=‘ä'¨°Ó5‘��að Š;Ø Ð$Ð$ö	8ñ" <HÈÓ;LÑ8ˆÐ'8Ù>JÈ4Ó>PÑ;ÐÐ);à/°Ð/@ð A$Ø$0 >ð 2*Ø*:Ð);Ð;OÐP]Èð _Oà Ð! Ð*<Ð)=¸Qð	@ð 	ô ˜sÓ#Ð#øôq !ó Ùðûô, œX¤~Ð6ó 	Ü"Ø�%Ð)¨+¨°a¸°vÐ>óàðð	ús%   ÁD7 Â"A E Ã#E Ä7
EÅEÅ*E1c                 óú   • [        USS5      nUb  U$ U R                  R                  5       R                  5        H,  u  p4US:X  d	  US:X  d  Uc  M   [	        XB5      S   UL a  Us  $ M.     g! [
         a     M>  f = f)zò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   )r;   r"   ÚcopyÚitemsr   rD   )r'   r*   r+   r#   rH   s        r   r   ÚImporter.whichmodule‘   s–   € ô ˜c <°Ó6ˆØÑ"ØÐð $(§<¡<×#4Ñ#4Ó#6×#<Ñ#<Ö#>ÑˆKà˜zÓ)Ø -Ó/Ø‘>áðÜ  Ó.¨qÑ1°SÒ8Ø&Ò&ñ 9ñ $?ð øô "ó Úðús   ÁA,Á,
A:Á9A:r   ©N)r   r   r   r   r   Údictr=   r   Ú__annotations__r   r(   r	   ÚtuplerR   r   r   r   r   r   r   r      s}   ‡ ñð( �#�z�/Ñ"Ó"àð¨ð °ó ó ðñU$˜Cð U$ s¨T¡zð U$¸UÀ3ÈÀ8¹_õ U$ðn˜sð ¨#ð °#÷ r   r   c                   ó<   • \ rS rSrSrS\4S jrS\S\S\4S jrS	r	g
)Ú_SysImporteré¯   z;An importer that implements the default behavior of Python.r#   c                 ó.   • [         R                  " U5      $ rZ   )Ú	importlibr(   r&   s     r   r(   Ú_SysImporter.import_module²   s   € Ü×&Ò& {Ó3Ð3r   r*   r+   r$   c                 ó<   • [        USS 5      nUb  U$ [        X5      $ )Nr   )r;   Ú_pickle_whichmodule)r'   r*   r+   r#   s       r   r   Ú_SysImporter.whichmoduleµ   s)   € ô ˜c <°Ó6ˆØÑ"ØÐÜ" 3Ó-Ð-r   r   N)
r   r   r   r   r   r=   r(   r	   r   r   r   r   r   r_   r_   ¯   s+   † ÙEð4¨ô 4ð.˜sð .¨#ð .°#÷ .r   r_   c            	       óv   • \ rS rSrSrS rS rSS\S\S-  S\	\\4   4S	 jjr
S
\S\4S jrS\S\S\4S jrSrg)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                 ó$   • [        U5      U l        g rZ   )ÚlistÚ
_importers)r'   Úargss     r   Ú__init__ÚOrderedImporter.__init__È   s   € Ü*.¨t«*ˆ�r   c                 óŒ   • [        USS5      (       d  g[        US5      (       d  g[        US5      (       d  gUR                  SL $ )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)r;   Úhasattrrr   )r'   rH   s     r   Ú_is_torchpackage_dummyÚ&OrderedImporter._is_torchpackage_dummyË   sF   € ô �vÐ2°E×:Ñ:ØÜ�v˜z×*Ñ*ØÜ�v˜z×*Ñ*ØØ�‰ $Ð&Ð&r   Nr*   r+   r$   c           
      ó
  • U R                    H  n UR                  X5      s  $    [        SU SU SU R                    35      e! [        [        4 a.  nSU SU SU SU 3n[        R                  U5         S nAMp  S nAff = f)Nz Tried to call get_name with obj z, and name z on z	 and got zCould not find obj z
 and name z in any of the importers )rk   rR   r   r   ÚlogÚwarning)r'   r*   r+   ÚimporterÚeÚwarning_messages         r   rR   ÚOrderedImporter.get_nameÝ   s¥   € ØŸœˆHð-Ø×(Ñ(¨Ó3Ò3ñ (ô Ø! #  j°°Ð6OÐPT×P_ÑP_ÐO`Ðaó
ð 	
øô %Ô&6Ð7ó -à6°s°eð < Ø $˜v T¨(¨°9¸Q¸CðAð  ô —‘˜O×,Ò,ûð-ús   ‘AÁBÁ#A=Á=Br#   c                 ó  • S nU R                    HR  n[        U[        5      (       d  [        U S35      e UR	                  U5      nU R                  U5      (       a  MP  Us  $    Ub  Ue[        U5      e! [         a  nUn S nAMx  S nAff = f)NzP is not a Importer. All importers in OrderedImporter must inherit from Importer.)rk   r<   r   Ú	TypeErrorr(   rt   ÚModuleNotFoundError)r'   r#   Úlast_errry   rH   Úerrs         r   r(   ÚOrderedImporter.import_moduleë   s�   € ØˆØŸœˆHÜ˜h¬×1Ñ1ÜØ�jð !Sð Sóð ðØ!×/Ñ/°Ó<�Ø×.Ñ.¨v×6Ñ6ÙØ’ñ (ð ÑØˆNä% kÓ2Ð2øô 'ó Ø–ûðús   ¶'A5ÁA5Á5
BÁ?BÂBc                 ó`   • U R                    H  nUR                  X5      nUS:w  d  M  Us  $    g)NrU   )rk   r   )r'   r*   r+   ry   r#   s        r   r   ÚOrderedImporter.whichmodule   s3   € ØŸœˆHØ"×.Ñ.¨sÓ9ˆKØ˜jÕ(Ø"Ò"ñ (ð
 r   )rk   rZ   )r   r   r   r   r   rm   rt   r	   r=   r]   rR   r   r(   r   r   r   r   r   r   r   Â   sd   † ñò
5ò'ñ$
˜Cð 
 s¨T¡zð 
¸UÀ3ÈÀ8¹_õ 
ð3¨ð 3°ô 3ð*˜sð ¨#ð °#÷ r   r   )rb   Úloggingr?   Úabcr   r   Úpickler   r   r   re   Útypesr   Útypingr	   Ú	_manglingr   r   r   Ú__all__Ú	getLoggerr   rw   r>   r   r   r   r_   Úsys_importerr   r   r   r   Ú<module>rŽ      s�   ðÛ Û Û 
ß #÷ñ õ
 Ý ç >Ñ >ò R€Ø×Ò˜Ó!€ôS�yô Sôh�yô hôPˆsô Pôf.�8ô .ñ  ‹~€ôD�hõ Dr   