
    Χg                         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j        d          d             Z G d	 d
e          Zd Zd ZdS )    )OptionalN)TorchFunctionMode	_pop_mode
_push_modecontext_decorator)_len_torch_function_stackCURRENT_DEVICE   c                     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     O/var/www/html/ai-engine/env/lib/python3.11/site-packages/torch/utils/_device.py_device_constructorsr:      s   -- 	- 		-
 	- 	
- 	- 	- 	- 		- 		- 		- 	
- 	
- 	-  	!-" 	#-$ 	%-& 	'-( 	")-. 	
/-0 	
1-2 	3-4 	5-6 	7-8 	9-: 	;-< 	&=-> 	?-@ 	A-B 	C-D 	E-F 	G-H 	I-J 	K-L 	M-N 	O-R 	S-T 	U-V 	W-X 	Y- -r8   c                   (    e Zd Zd Zd Zd ZddZdS )DeviceContextc                 8    t          j        |          | _        d S r   )r   device)selfr>   s     r9   __init__zDeviceContext.__init__>   s    l6**r8   c                    t           | _        | j        a g }t          t	                                D ]#}|                    t                                 $t          |            t          |          D ]}t          |           d S r   )	r
   
old_devicer>   r(   r	   appendr   r   reversed)r?   	cur_stack_modes       r9   	__enter__zDeviceContext.__enter__A   s    (
 	02233 	* 	*AY[[))))4Y'' 	 	Dt	 	r8   c                 ~   | j         ag }t          t                      dz
            D ]<}t	                      }t          |t                    rJ |                    |           =t                      dk    r%t	                      }t          |t                    sJ t          |          D ]}t          |           d S )Nr   r   )
rB   r
   r(   r	   r   
isinstancer<   rC   rD   r   )r?   exc_typeexc_valexc_tbrE   rF   rG   s          r9   __exit__zDeviceContext.__exit__S   s    	 022Q677 	# 	#A;;D!$66666T""""$&&**;;DdM22222Y'' 	 	Dt	 	r8   r7   Nc                 x    |pi }|t                      v r|                    d          
| j        |d<    ||i |S )Nr>   )r:   getr>   )r?   functypesargskwargss        r9   __torch_function__z DeviceContext.__torch_function__f   sO    2'))))fjj.B.B.J#{F8tT$V$$$r8   )r7   N)__name__
__module____qualname__r@   rH   rN   rU   r7   r8   r9   r<   r<   =   sU        + + +  $  &% % % % % %r8   r<   c                 *     t           fd|          S )Nc                       S r   r7   r>   s   r9   <lambda>z"device_decorator.<locals>.<lambda>n   s    V r8   r   )r>   rQ   s   ` r9   device_decoratorr]   m   s    ^^^^T222r8   c                       f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                 H    t          t          j                  |           S r   )r]   r   r>   )rQ   r>   s    r9   r\   zset_device.<locals>.<lambda>w   s    (f)=)=tDD r8   r7   r[   s   `r9   
set_devicer`   p   s     EDDDDr8   )typingr   r   torch.overridesr   r   r   torch.utils._contextlibr   torch._Cr	   	functoolsr
   r>   __annotations__	lru_cacher:   r<   r]   r`   r7   r8   r9   <module>rh      s	           D D D D D D D D D D 5 5 5 5 5 5 . . . . . .    )-& - - -Q. . .b-% -% -% -% -%% -% -% -%`3 3 3E E E E Er8   