U
    Mh                     @   s2   d dl Z d dlZddlmZ G dd dejZdS )    N   )Importerc                       s.   e Zd ZdZed fddZdd Z  ZS )PackageUnpicklerzPackage-aware unpickler.

    This behaves the same as a normal unpickler, except it uses `importer` to
    find any global names that it encounters while unpickling.
    )importerc                    s   t  j|| || _d S )N)super__init__	_importer)selfr   argskwargs	__class__ R/var/www/html/venv/lib/python3.8/site-packages/torch/package/_package_unpickler.pyr      s    zPackageUnpickler.__init__c                 C   s\   | j dk rF| jrF||ftjkr2tj||f \}}n|tjkrFtj| }| j|}t||S )N   )protofix_imports_compat_pickleNAME_MAPPINGIMPORT_MAPPINGr   import_modulegetattr)r	   modulenamemodr   r   r   
find_class   s    

zPackageUnpickler.find_class)__name__
__module____qualname____doc__r   r   r   __classcell__r   r   r   r   r      s   r   )r   pickler   r   
_Unpicklerr   r   r   r   r   <module>   s   