
    Yh              
         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
 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rd dl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'dS )#    )annotationsN)AnyCallableOptionalTYPE_CHECKINGTypeVarUnion)BackendIndexDispatchKeyNativeFunctionNativeFunctionsGroupNativeFunctionsViewGroup)contextST)IteratorFF2F3g@NativeFunctionsGroup | NativeFunctionsViewGroup | NativeFunctionreturnIterator[None]c              #  R  K   t          | t                    r| j        nt          | t                    r| j        n| t          fd          5  t          j        j        j	                  5  d V  d d d            n# 1 swxY w Y   d d d            d S # 1 swxY w Y   d S )Nc                 (    d j          d j         S )Nzin native_functions.yaml line z:
  )locfunc)fs   b/var/www/tools.fuzzalab.pt/emblema-extractor/venv/lib/python3.11/site-packages/torchgen/context.py<lambda>z)native_function_manager.<locals>.<lambda><   s    N!%NNafNN     )!use_const_ref_for_mutable_tensorsuse_ilistref_for_tensor_lists)

isinstancer   outr   viewr   localparametrizer"   part_of_structured_group)r   r   s    @r   native_function_managerr*   -   sH      !)** 

 E	A/	0	0 F	NNNN	O	O  ./.Q*+*D
 
 
 	 	 EEE		 	 	 	 	 	 	 	 	 	 	 	 	 	 	                 s6   !B3B8BB	BB	BB #B r   Callable[[F], T]c                H     t          j                   d fd            }|S )Nr   r   r   r   c                l    t          |           5   |           cd d d            S # 1 swxY w Y   d S Nr*   )r   r   s    r   wrapperz%with_native_function.<locals>.wrapperJ   s    $Q'' 	 	477	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	s   )--)r   r   r   r   	functoolswrapsr   r0   s   ` r   with_native_functionr5   I   s=    _T      Nr!   Callable[[F, F2], T]c                H     t          j                   d fd            }|S )	Nr   r   f2r   r   r   c                n    t          |           5   | |          cd d d            S # 1 swxY w Y   d S r.   r/   )r   r8   r   s     r   r0   z)with_native_function_and.<locals>.wrapperS   s     %Q'' 	 	42;;	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	   *..)r   r   r8   r   r   r   r1   r4   s   ` r   with_native_function_andr;   R   s=    _T     
 Nr!   Callable[[S, F], T]c                H     t          j                   d fd            }|S )	Nslfr   r   r   r   r   c                n    t          |          5   | |          cd d d            S # 1 swxY w Y   d S r.   r/   r>   r   r   s     r   r0   z,method_with_native_function.<locals>.wrapper]   s    $Q'' 	  	 4Q<<	  	  	  	  	  	  	  	  	  	  	  	  	  	  	  	  	  	 r:   )r>   r   r   r   r   r   r1   r4   s   ` r   method_with_native_functionrA   \   s=    _T            Nr!   Callable[[S, F3], T]c                H     t          j                   d fd            }|S )	Nr>   r   r   r   r   r   c                z    t          |d                   5   | |          cd d d            S # 1 swxY w Y   d S )Nr   r/   r@   s     r   r0   z3method_with_nested_native_function.<locals>.wrapperh   s    $QqT** 	  	 4Q<<	  	  	  	  	  	  	  	  	  	  	  	  	  	  	  	  	  	 s   044)r>   r   r   r   r   r   r1   r4   s   ` r   "method_with_nested_native_functionrE   e   s?     _T            Nr!   Callable[[F, BackendIndex], T]c                H     t          j                   d fd            }|S )	Nr   r   backend_indexr
   r   r   c                n    t          |           5   | |          cd d d            S # 1 swxY w Y   d S r.   r/   )r   rH   r   s     r   r0   z/with_native_function_and_index.<locals>.wrapperu   s    $Q'' 	* 	*4=))	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	*r:   )r   r   rH   r
   r   r   r1   r4   s   ` r   with_native_function_and_indexrJ   r   s?     _T* * * * * * Nr!   1Callable[[F, dict[DispatchKey, BackendIndex]], T]c                H     t          j                   d fd            }|S )	Nr   r   backend_indicesdict[DispatchKey, BackendIndex]r   r   c                n    t          |           5   | |          cd d d            S # 1 swxY w Y   d S r.   r/   )r   rM   r   s     r   r0   z1with_native_function_and_indices.<locals>.wrapper   s    $Q'' 	, 	,4?++	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	,r:   )r   r   rM   rN   r   r   r1   r4   s   ` r    with_native_function_and_indicesrP   ~   s?     _T, , , , , , Nr!   )r   r   r   r   )r   r+   r   r+   )r   r6   r   r6   )r   r<   r   r<   )r   rB   r   rB   )r   rF   r   rF   )r   rK   r   rK   )(
__future__r   
contextlibr2   typingr   r   r   r   r   r	   torchgen.localr'   torchgen.modelr
   r   r   r   r   torchgen.utilsr   r   r   collections.abcr   r   boolstrr   tuplelistr   contextmanagerr*   r5   r;   rA   rE   rJ   rP    r!   r   <module>r^      s"   " " " " " "         I I I I I I I I I I I I I I I I                    ) ( ( ( ( ( ( ( ( (  )((((((
 G	..
./	.2
23  W^  WT5,-tN/CDD    6                    r!   