o
    ðÇhÍ  ã                   @   s’   U d dl mZ d dlZd dlmZmZm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Ú	_pop_modeÚ
_push_mode©Úcontext_decorator)Ú_len_torch_function_stackÚCURRENT_DEVICEé   c                   C   sú   h 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%’S ©N))ÚtorchÚemptyÚempty_permutedÚempty_stridedÚempty_quantizedÚonesÚarangeÚbartlett_windowÚblackman_windowÚeyeÚfftÚfftfreqÚrfftfreqÚfullÚfillÚhamming_windowÚhann_windowÚkaiser_windowÚlinspaceÚlogspaceÚnestedÚnested_tensorÚrandÚrandnÚrandintÚrandpermÚrangeÚsparse_coo_tensorÚsparse_compressed_tensorÚsparse_csr_tensorÚsparse_csc_tensorÚsparse_bsr_tensorÚsparse_bsc_tensorÚtril_indicesÚtriu_indicesÚvanderÚzerosÚasarrayÚtensorÚ	as_tensorÚscalar_tensor© r5   r5   úg/var/www/html/construction_image-detection-poc/venv/lib/python3.10/site-packages/torch/utils/_device.pyÚ_device_constructors   s¢   þýüûúùø	÷
öõôóòñðïîíìéèçæåäãâá à!ß"Þ#Ý$Ü%Û&Ú'Ù)×*Ö+Õ,Ôr7   c                   @   s.   e Zd Zdd„ Zdd„ Zdd„ Zdd	d
„ZdS )ÚDeviceContextc                 C   s   t  |¡| _d S r   )r   Údevice)Úselfr9   r5   r5   r6   Ú__init__>   s   zDeviceContext.__init__c                 C   sB   t | _| ja dd„ ttƒ ƒD ƒ}t| ƒ t|ƒD ]}t|ƒ qd S )Nc                 S   s   g | ]}t ƒ ‘qS r5   )r   )Ú.0Ú_r5   r5   r6   Ú
<listcomp>I   s    z+DeviceContext.__enter__.<locals>.<listcomp>)r	   Ú
old_devicer9   r&   r   r   Úreversed)r:   Ú	cur_stackÚmoder5   r5   r6   Ú	__enter__A   s   
ÿzDeviceContext.__enter__c                 C   st   | j ag }ttƒ d ƒD ]}tƒ }t|tƒrJ ‚| |¡ qtƒ dkr-tƒ }t|tƒs-J ‚t|ƒD ]}t	|ƒ q1d S )Nr
   r   )
r?   r	   r&   r   r   Ú
isinstancer8   Úappendr@   r   )r:   Úexc_typeÚexc_valÚexc_tbrA   r=   rB   r5   r5   r6   Ú__exit__Q   s   

ÿzDeviceContext.__exit__r5   Nc                 C   s8   |pi }|t ƒ v r| d¡d u r| j|d< ||i |¤ŽS )Nr9   )r7   Úgetr9   )r:   ÚfuncÚtypesÚargsÚkwargsr5   r5   r6   Ú__torch_function__d   s   
z DeviceContext.__torch_function__)r5   N)Ú__name__Ú
__module__Ú__qualname__r;   rC   rI   rO   r5   r5   r5   r6   r8   =   s
    r8   c                    s   t ‡ fdd„|ƒS )Nc                      s   ˆ S r   r5   r5   ©r9   r5   r6   Ú<lambda>l   s    z"device_decorator.<locals>.<lambda>r   )r9   rK   r5   rS   r6   Údevice_decoratork   s   rU   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   )rU   r   r9   )rK   rS   r5   r6   rT   u   s    zset_device.<locals>.<lambda>r5   rS   r5   rS   r6   Ú
set_devicen   s   rV   )Útypingr   r   Útorch.overridesr   r   r   Útorch.utils._contextlibr   Útorch._Cr   Ú	functoolsr	   r9   Ú__annotations__Ú	lru_cacher7   r8   rU   rV   r5   r5   r5   r6   Ú<module>   s   
1.