
    rh}                         U d dl Z d dlmZ d dlZd dlmZ d dlmZmZm	Z	 d dl
mZ daeej                     ed<    e j                  d      d        Z G d	 d
e	      Zd Zd Zy)    N)Optional)_len_torch_function_stack)	_pop_mode
_push_modeTorchFunctionModecontext_decorator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&                  j(                  t         j*                  t         j,                  t         j.                  t         j0                  t         j2                  t         j4                  t         j6                  t         j8                  t         j:                  t         j<                  t         j>                  t         j@                  t         jB                  t         jD                  t         jF                  t         jH                  t         jJ                  t         jL                  S N)'torchemptyempty_permutedempty_stridedempty_quantizedonesarangebartlett_windowblackman_windoweyefftfftfreqrfftfreqfull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zerosasarraytensor	as_tensorscalar_tensor     f/var/www/html/ai-insurance-compliance-backend/venv/lib/python3.12/site-packages/torch/utils/_device.py_device_constructorsr8      sF   )) 	) 		)
 	) 	

) 	) 	) 	) 			) 			) 			) 	

) 	) 	)  	!)" 	#)$ 	%)& 	""'), 	

-). 	/)0 	1)2 	3)4 	5)6 	7)8 	&&9): 	;)< 	=)> 	?)@ 	A)B 	C)D 	E)F 	G)H 	I)L 	M)N 	O)P 	Q) )r6   c                   &    e Zd Zd Zd Zd ZddZy)DeviceContextc                 8    t        j                  |      | _        y r   )r   device)selfr<   s     r7   __init__zDeviceContext.__init__>   s    ll6*r6   c                     t         | _        | j                  a t        t	                     D cg c]  }t                }}t        |        t        |      D ]  }t        |        y c c}w r   )r
   
old_devicer<   r'   r   r   r   reversed)r=   _	cur_stackmodes       r7   	__enter__zDeviceContext.__enter__A   s\    (
 +00I0K*LMQY[M	M4Y' 	Dt		 Ns   A'c                 8   | j                   ag }t        t               dz
        D ]/  }t	               }t        |t              rJ |j                  |       1 t               dkD  rt	               }t        |t              sJ t        |      D ]  }t        |        y )Nr   r   )
r@   r
   r'   r   r   
isinstancer:   appendrA   r   )r=   exc_typeexc_valexc_tbrC   rB   rD   s          r7   __exit__zDeviceContext.__exit__P   s    	 02Q67 	#A;D!$666T"	#
 %&*;DdM222Y' 	Dt	r6   Nc                 v    |xs i }|t               v r |j                  d      | j                  |d<    ||i |S )Nr<   )r8   getr<   )r=   functypesargskwargss        r7   __torch_function__z DeviceContext.__torch_function__c   sC    2'))fjj.B.J#{{F8T$V$$r6   )r5   N)__name__
__module____qualname__r>   rE   rL   rS   r5   r6   r7   r:   r:   =   s    +&%r6   r:   c                 "     t         fd|      S )Nc                       S r   r5   r<   s   r7   <lambda>z"device_decorator.<locals>.<lambda>l   s    V r6   r   )r<   rO   s   ` r7   device_decoratorr[   k   s    ^T22r6   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                 B    t        t        j                        |       S r   )r[   r   r<   )rO   r<   s    r7   rZ   zset_device.<locals>.<lambda>v   s    (f)=tD r6   r5   rY   s   `r7   
set_devicer^   o   s     EDr6   )	functoolstypingr   r   torch._Cr   torch.overridesr   r   r   torch.utils._contextlibr	   r
   r<   __annotations__	lru_cacher8   r:   r[   r^   r5   r6   r7   <module>rf      sj       . D D 5 *.& - Q* *\*%% *%\3Er6   