U
    Mh
                     @   s~   U d dl mZ d dlZd dlmZ d dlmZ d dlZdaeej	 e
d< eddd ZG d	d
 d
eZdd Zdd ZdS )    )OptionalN)TorchFunctionModecontext_decoratorCURRENT_DEVICE   c                (   C   s   t jt jt jt jt jt jt jt jt j	t j
jt j
jt jt jt jt jt jt jt jt jjt jt jt jt jt jt jt jt jt jt jt jt j t j!t j"t j#t j$t j%t j&t j't j(t j%h(S N))torchemptyZempty_permutedZempty_stridedZempty_quantizedZonesZarangeZbartlett_windowZblackman_windoweyeZfftZfftfreqZrfftfreqfullfillZhamming_windowZhann_windowZkaiser_windowZlinspaceZlogspacenestedZnested_tensorZrandZrandnrandintZrandpermrangeZsparse_coo_tensorZsparse_compressed_tensorZsparse_csr_tensorZsparse_csc_tensorZsparse_bsr_tensorZsparse_bsc_tensorZtril_indicesZtriu_indicesZvanderZzerosZasarrayZtensorZ	as_tensorZscalar_tensor r   r   E/var/www/html/venv/lib/python3.8/site-packages/torch/utils/_device.py_device_constructors
   sR    r   c                       s:   e Zd Zdd Z fddZ fddZdd	d
Z  ZS )DeviceContextc                 C   s   t || _d S r   )r	   device)selfr   r   r   r   __init__=   s    zDeviceContext.__init__c                    s   t | _| ja t  S r   )r   
old_devicer   super	__enter__)r   	__class__r   r   r   @   s    zDeviceContext.__enter__c                    s   | j at |||S r   )r   r   r   __exit__)r   exc_typeexc_valexc_tbr   r   r   r   F   s    zDeviceContext.__exit__r   Nc                 C   s4   |pi }|t  kr*|dd kr*| j|d< |||S )Nr   )r   getr   )r   functypesargskwargsr   r   r   __torch_function__K   s    
z DeviceContext.__torch_function__)r   N)__name__
__module____qualname__r   r   r   r&   __classcell__r   r   r   r   r   <   s   r   c                    s   t  fdd|S )Nc                      s    S r   r   r   r   r   r   <lambda>S       z"device_decorator.<locals>.<lambda>r   )r   r"   r   r+   r   device_decoratorR   s    r.   c                    s    fddS )z
    Set the default device inside of the wrapped function by decorating it with this function.

    If you would like to use this as a context manager, use device as a
    context manager directly, e.g., ``with torch.device(device)``.
    c                    s   t t | S r   )r.   r	   r   )r"   r+   r   r   r,   \   r-   zset_device.<locals>.<lambda>r   r+   r   r+   r   
set_deviceU   s    r/   )typingr   r	   Ztorch.overridesr   Ztorch.utils._contextlibr   	functoolsr   r   __annotations__	lru_cacher   r   r.   r/   r   r   r   r   <module>   s    
1