§
    �Štjÿ'  ã                   ó6  — d dl Z d dlZ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 ddlmZmZmZ g d¢Z ej        e¦  «        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é   )Ú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__© ó    úT/var/www/html/CA-Chatbot/venv/lib/python3.11/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dz  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_module3   s   € € € r   NÚobjÚnamec                 ó6  ‡ ‡— ‰€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          j        dk    r$t          |‰                     d¦  «        ¦  «        }n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                 óÌ   •— ‰€t          d¦  «        ‚‰                     | ‰¦  «        }t          |¦  «        }|rt          |¦  «        nd}|rdt          |¦  «        › �nd}|||fS )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_infoz'Importer.get_name.<locals>.get_obj_infou   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#   ÚsysÚversion_infor   ÚsplitÚImportErrorÚKeyErrorÚAttributeErrorr   r   )r"   r$   r%   ÚreduceÚrvÚorig_module_namer   ÚmoduleÚobj2Ú_r0   Úobj_module_nameÚobj_locationÚobj_importer_nameÚobj2_module_nameÚobj2_locationÚobj2_importer_nameÚmsgs   ` `               r   Úget_namezImporter.get_name:   s_  øø€ ð& ˆ<˜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ÝÔ 7Ò*Ð*õ % V¨T¯ZªZ¸©_¬_Ñ=Ô=��å'¨°Ñ5Ô5‘��aøøÝ�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Â;AD Ä0E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   )r4   r   ÚcopyÚitemsr   r=   )r"   r$   r%   r   rA   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   Údictr6   r   Ú__annotations__r   r#   r	   ÚtuplerK   r   r   r   r   r   r      sÏ   € € € € € € ðð ð( �#�z�/Ô"Ð"Ð"Ñ"àð¨ð °ð ð ð ñ „^ððU$ð U$˜Cð U$ s¨T¡zð U$¸UÀ3ÈÀ8¼_ð U$ð U$ð U$ð U$ðn˜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 rQ   )Ú	importlibr#   r!   s     r   r#   z_SysImporter.import_module²   s   € ÝÔ& {Ñ3Ô3Ð3r   r$   r%   r   c                 óL   — t          |dd ¦  «        }|�|S t          ||¦  «        S )Nr   )r4   Ú_pickle_whichmodule)r"   r$   r%   r   s       r   r   z_SysImporter.whichmoduleµ   s1   € õ ˜c <°Ñ6Ô6ˆØÐ"ØÐÝ" 3¨Ñ-Ô-Ð-r   N)r   r   r   r   r6   r#   r	   r   r   r   r   rV   rV   ¯   s^   € € € € € ØEÐEð4¨ð 4ð 4ð 4ð 4ð.˜sð .¨#ð .°#ð .ð .ð .ð .ð .ð .r   rV   c            	       ón   — e Zd ZdZd„ Zd„ Zddededz  deeef         f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 rQ   )Ú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)r4   Úhasattrrd   )r"   rA   s     r   Ú_is_torchpackage_dummyz&OrderedImporter._is_torchpackage_dummyË   sY   € õ �vÐ2°EÑ:Ô:ð 	Ø�5Ý�v˜zÑ*Ô*ð 	Ø�5Ý�v˜zÑ*Ô*ð 	Ø�4ØŒ $Ð&Ð&r   Nr$   r%   r   c           
      ó  — | j         D ]`}	 |                     ||¦  «        c S # t          t          f$ r2}d|› d|› d|› d|› �}t                               |¦  «         Y d }~ŒYd }~ww xY wt          d|› d|› d| j         › �¦  «        ‚)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 )r^   rK   r   r   ÚlogÚwarning)r"   r$   r%   ÚimporterÚeÚwarning_messages         r   rK   zOrderedImporter.get_nameÝ   sõ   € Øœð 	-ð 	-ˆHð-Ø×(Ò(¨¨dÑ3Ô3Ð3Ð3Ð3øÝ$Õ&6Ð7ð -ð -ð -ðA°sð Að AØ $ðAð AØ*2ðAð AØ=>ðAð Að  õ —’˜OÑ,Ô,Ð,Ð,Ð,Ð,Ð,Ð,øøøøð-øøøõ Øa #ÐaÐa°ÐaÐaÐPTÔP_ÐaÐañ
ô 
ð 	
s   ‹#£A&´(A!Á!A&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.)r^   r5   r   Ú	TypeErrorr#   rf   ÚModuleNotFoundError)r"   r   Úlast_errrj   rA   Ú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c                 óZ   — | j         D ]"}|                     ||¦  «        }|dk    r|c S Œ#dS )NrM   )r^   r   )r"   r$   r%   rj   r   s        r   r   zOrderedImporter.whichmodule   sK   € Øœð 	#ð 	#ˆHØ"×.Ò.¨s°DÑ9Ô9ˆKØ˜jÒ(Ð(Ø"Ð"Ð"Ð"ð )ð ˆzr   rQ   )r   r   r   r   r`   rf   r	   r6   rT   rK   r   r#   r   r   r   r   r   r   Â   sÁ   € € € € € ðð ð
5ð 5ð 5ð'ð 'ð 'ð$
ð 
˜Cð 
 s¨T¡zð 
¸UÀ3ÈÀ8¼_ð 
ð 
ð 
ð 
ð3¨ð 3°ð 3ð 3ð 3ð 3ð*˜sð ¨#ð °#ð ð ð ð ð ð r   r   )rX   Úloggingr8   Úabcr   r   Úpickler   r   r   rZ   Útypesr   Útypingr	   Ú	_manglingr   r   r   Ú__all__Ú	getLoggerr   rh   r7   r   r   r   rV   Úsys_importerr   r   r   r   ú<module>r|      sÝ  ðØ Ð Ð Ð Ø €€€Ø 
€
€
€
Ø #Ð #Ð #Ð #Ð #Ð #Ð #Ð #ðð ð ð ð ð ð ð ð ð ð
 Ð Ð Ð Ð Ð Ø Ð Ð Ð Ð Ð à >Ð >Ð >Ð >Ð >Ð >Ð >Ð >Ð >Ð >ð RÐ
QÐ
Q€Ø€gÔ˜Ñ!Ô!€ðSð Sð Sð Sð S�yñ Sô Sð Sðhð hð hð hð h�yñ hô hð hðPð Pð Pð Pð Pˆsñ Pô Pð Pðf.ð .ð .ð .ð .�8ñ .ô .ð .ð  ˆ|‰~Œ~€ðDð Dð Dð Dð D�hñ Dô Dð Dð Dð Dr   