U
    Mh                     @   s@   d dl mZmZ d dlZd dlZdZee eeedddZdS )    )ListCallableNzMUsage of '{old_location}' is deprecated; please use '{new_location}' instead.)all
old_module
new_modulereturnc                    s"   t j|d fdd}|S )a@  Import utility to lazily import deprecated packages / modules / functional.

    The old_module and new_module are also used in the deprecation warning defined
    by the `_MESSAGE_TEMPLATE`.

    Args:
        all: The list of the functions that are imported. Generally, the module's
            __all__ list of the module.
        old_module: Old module location
        new_module: New module location / Migrated location

    Returns:
        Callable to assign to the `__getattr__`

    Usage:

        # In the `torch/nn/quantized/functional.py`
        from torch.nn.utils._deprecation_utils import lazy_deprecated_import
        _MIGRATED_TO = "torch.ao.nn.quantized.functional"
        __getattr__ = lazy_deprecated_import(
            all=__all__,
            old_module=__name__,
            new_module=_MIGRATED_TO)
    )Zold_locationZnew_locationc                    sB   |  kr(t t t}t|| S tdd| dd S )NzModule z has no attribute .)warningswarnRuntimeWarning	importlibimport_modulegetattrAttributeError)namepackager   r   Zwarning_message S/var/www/html/venv/lib/python3.8/site-packages/torch/nn/utils/_deprecation_utils.pygetattr_dunder&   s
    

z.lazy_deprecated_import.<locals>.getattr_dunder)_MESSAGE_TEMPLATEformat)r   r   r   r   r   r   r   lazy_deprecated_import	   s    r   )typingr   r   r   r	   r   strr   r   r   r   r   <module>   s   