o
    wZh                     @   sB   d dl Z d dlZd dlmZ dZdee dededefdd	ZdS )
    N)CallablezMUsage of '{old_location}' is deprecated; please use '{new_location}' instead.all
old_module
new_modulereturnc                    s,   t j|ddtddf 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_locationnamer   Nc                    s>   |  v rt t t}t|| S tdd| d)NzModule z has no attribute .)warningswarnRuntimeWarning	importlibimport_modulegetattrAttributeError)r   packager   r   Zwarning_message P/var/www/auris/lib/python3.10/site-packages/torch/nn/utils/_deprecation_utils.pygetattr_dunder,   s
   

z.lazy_deprecated_import.<locals>.getattr_dunder)_MESSAGE_TEMPLATEformatstr)r   r   r   r   r   r   r   lazy_deprecated_import   s
   	r   )r   r	   typingr   r   listr   r   r   r   r   r   <module>   s    