
    3j                         % S SK r S SKrS SKJr  S SKJrJrJr  S SKJ	r	  Sq
\R                  S-  \S'   \ R                  " S5      S 5       r " S S	\5      rS
 rS rg)    N)_len_torch_function_stack)	_pop_mode
_push_modeTorchFunctionModecontext_decoratorCURRENT_DEVICE   c                     1 [         R                  i[         R                  i[         R                  i[         R                  i[         R
                  i[         R                  i[         R                  i[         R                  i[         R                  i[         R                  R                  i[         R                  R                  i[         R                  i[         R                  i[         R                  i[         R                   i[         R"                  i[         R$                  i[         R&                  R(                  i[         R*                  i[         R,                  i[         R.                  i[         R0                  i[         R2                  i[         R4                  i[         R6                  i[         R8                  i[         R:                  i[         R<                  i[         R>                  i[         R@                  i[         RB                  i[         RD                  i[         RF                  i[         RH                  i[         RJ                  i[         RL                  i$ 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     M/home/wildlama/miniconda3/lib/python3.13/site-packages/torch/utils/_device.py_device_constructorsr7      sF   11 	1 		1
 	1 	

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

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

-1. 	/10 	112 	314 	516 	718 	&&91: 	;1< 	=1> 	?1@ 	A1B 	C1D 	E1F 	G1H 	I1L 	M1N 	O1P 	Q1 1r5   c                   4    \ rS rSrSS jrS rS rS	S jrSrg)
DeviceContextD   Nc                 H    [         R                  " U5      U l        S U l        g r   )r   device	prev_mode)selfr<   s     r6   __init__DeviceContext.__init__E   s    ll6*/3r5   c                    [         U l        U R                  q [        [	        5       5       Vs/ s H  n[        5       PM     nn[        U 5        [        U5       H+  n[        U[        5      (       a  X0l
        M   [        U5        M-     g s  snf r   )r	   
old_devicer<   r&   r   r   r   reversed
isinstancer9   r=   )r>   _	cur_stackmodes       r6   	__enter__DeviceContext.__enter__I   sl    (
 +00I0K*LM*LQY[*L	M4Y'D$..!%4 	 (	 Ns   B	c                    U R                   q/ n[        [        5       S-
  5       H>  n[	        5       n[        U[        5      (       a  [        S5      eUR                  U5        M@     [        5       S:  a*  [	        5       n[        U[        5      (       d  [        S5      eU R                  b  [        U R                  5        [        U5       H  n[        U5        M     g )Nr
   z@Found nested DeviceContext on the mode stack where none expectedr   z8Expected a DeviceContext at the bottom of the mode stack)rB   r	   r&   r   r   rD   r9   AssertionErrorappendr=   r   rC   )r>   exc_typeexc_valexc_tbrF   rE   rG   s          r6   __exit__DeviceContext.__exit__[   s    	 02Q67A;D$..$V  T" 8 %&*;DdM22$N  >>%t~~&Y'Dt (r5   c                     U=(       d    0 nU[        5       ;   a!  UR                  S5      c  U R                  US'   U" U0 UD6$ )Nr<   )r7   getr<   )r>   functypesargskwargss        r6   __torch_function__ DeviceContext.__torch_function__v   sC    2'))fjj.B.J#{{F8T$V$$r5   )r<   rB   r=   )returnN)r4   N)	__name__
__module____qualname____firstlineno__r?   rH   rP   rX   __static_attributes__r4   r5   r6   r9   r9   D   s    4!$6%r5   r9   c                 $   ^  [        U 4S jU5      $ )Nc                     > T $ r   r4   r<   s   r6   <lambda>"device_decorator.<locals>.<lambda>   s    Vr5   r   )r<   rT   s   ` r6   device_decoratorre   ~   s    ^T22r5   c                    ^  U 4S j$ )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                 D   > [        [        R                  " T5      U 5      $ r   )re   r   r<   )rT   r<   s    r6   rc   set_device.<locals>.<lambda>   s    (f)=tDr5   r4   rb   s   `r6   
set_deviceri      s     EDr5   )	functoolsr   torch._Cr   torch.overridesr   r   r   torch.utils._contextlibr   r	   r<   __annotations__	lru_cacher7   r9   re   ri   r4   r5   r6   <module>rp      se      . D D 5 '+t# * Q2 2l6%% 6%t3Er5   