
    sg              
      l   d dl mZ d dlZd dlZd dlmZmZmZmZm	Z	m
Z
mZmZ d dlmZ d dlmZmZmZmZmZ d dlmZmZmZ  edeeeeeef   eeef         Z edeee	e   ee      Z ede
eef   ee         Zej<                  	 	 	 	 dd	       Zdd
Z ddZ!ddZ"	 	 	 	 ddZ#	 	 	 	 ddZ$	 	 	 	 ddZ%y)    )annotationsN)AnyCallableIteratorListOptionalTupleTypeVarUnion)BackendIndexDispatchKeyNativeFunctionNativeFunctionsGroupNativeFunctionsViewGroup)contextSTFF2F3c              #  T  K   t        | t              r| j                  nt        | t              r| j                  n| t        fd      5  t        j                  j                  j                        5  d  d d d        d d d        y # 1 sw Y   xY w# 1 sw Y   y xY ww)Nc                 <    d j                    d j                   S )Nzin native_functions.yaml line z:
  )locfunc)fs   C/var/www/html/venv/lib/python3.12/site-packages/torchgen/context.py<lambda>z)native_function_manager.<locals>.<lambda>8   s    9!%%affXN     )!use_const_ref_for_mutable_tensorsuse_ilistref_for_tensor_lists)

isinstancer   outr   viewr   localparametrizer   part_of_structured_group)gr   s    @r   native_function_managerr(   )   s      !)*
 EE	A/	0FF	N	O ./.Q.Q*+*D*D
 	 		 	 	 s6   AB(,B:B?B	B(B	BB%!B(c                D     t        j                         d fd       }|S )Nc                V    t        |       5   |       cd d d        S # 1 sw Y   y xY wNr(   )r   r   s    r   wrapperz%with_native_function.<locals>.wrapperF   s'    $Q' 	7	 	 	s   ()r   r   returnr   	functoolswrapsr   r-   s   ` r   with_native_functionr3   E   s%    __T  Nr   c                D     t        j                         d fd       }|S )Nc                X    t        |       5   | |      cd d d        S # 1 sw Y   y xY wr+   r,   )r   f2r   s     r   r-   z)with_native_function_and.<locals>.wrapperO   s+     %Q' 	2;	 	 	   	 ))r   r   r6   r   r.   r   r/   r2   s   ` r   with_native_function_andr8   N   s%    __T 
 Nr   c                D     t        j                         d fd       }|S )Nc                X    t        |      5   | |      cd d d        S # 1 sw Y   y xY wr+   r,   slfr   r   s     r   r-   z,method_with_native_function.<locals>.wrapperY   s)    $Q' 	 Q<	  	  	 r7   )r<   r   r   r   r.   r   r/   r2   s   ` r   method_with_native_functionr=   X   s%    __T    Nr   c                D     t        j                         d fd       }|S )Nc                ^    t        |d         5   | |      cd d d        S # 1 sw Y   y xY w)Nr   r,   r;   s     r   r-   z3method_with_nested_native_function.<locals>.wrapperd   s-    $QqT* 	 Q<	  	  	 s   	#,)r<   r   r   r   r.   r   r/   r2   s   ` r   "method_with_nested_native_functionr@   a   s'     __T    Nr   c                D     t        j                         d fd       }|S )Nc                X    t        |       5   | |      cd d d        S # 1 sw Y   y xY wr+   r,   )r   backend_indexr   s     r   r-   z/with_native_function_and_index.<locals>.wrapperq   s*    $Q' 	*=)	* 	* 	*r7   )r   r   rC   r   r.   r   r/   r2   s   ` r   with_native_function_and_indexrD   n   s'     __T* * Nr   c                D     t        j                         d fd       }|S )Nc                X    t        |       5   | |      cd d d        S # 1 sw Y   y xY wr+   r,   )r   backend_indicesr   s     r   r-   z1with_native_function_and_indices.<locals>.wrapper}   s*    $Q' 	,?+	, 	, 	,r7   )r   r   rG   zdict[DispatchKey, BackendIndex]r.   r   r/   r2   s   ` r    with_native_function_and_indicesrH   z   s'     __T, , Nr   )r'   z@NativeFunctionsGroup | NativeFunctionsViewGroup | NativeFunctionr.   zIterator[None])r   Callable[[F], T]r.   rI   )r   Callable[[F, F2], T]r.   rJ   )r   Callable[[S, F], T]r.   rK   )r   Callable[[S, F3], T]r.   rL   )r   Callable[[F, BackendIndex], T]r.   rM   )r   1Callable[[F, dict[DispatchKey, BackendIndex]], T]r.   rN   )&
__future__r   
contextlibr0   typingr   r   r   r   r   r	   r
   r   torchgen.localr$   torchgen.modelr   r   r   r   r   torchgen.utilsr   r   r   r   boolstrr   r   contextmanagerr(   r3   r8   r=   r@   rD   rH    r   r   <module>rY      s   "   Q Q Q   ) (
 	..
./	.2
23 ^ T5,-tN/CD G 6

(#
;6r   