U
    9%e                  	   @   s  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
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eeeef ed dd	d
Zeegef eegef dddZeeegef eeegef dddZ eeegef eeegef dddZ!eeegef eeegef dddZ"eeegef eeegef dddZ#eeeeef gef eeeeef gef dddZ$dS )    N)	AnyCallableDictIteratorListOptionalTupleTypeVarUnion)BackendIndexDispatchKeyNativeFunctionNativeFunctionsGroupNativeFunctionsViewGroup)contextSTFF2F3)greturnc              
   #   sl   t | tr| j nt | tr$| j n|  t fdd* tj j j	d d V  W 5 Q R X W 5 Q R X d S )Nc                      s   d j  d j S )Nzin native_functions.yaml line z:
  )locfunc fr   O/var/www/html/Darija-Ai-API/env/lib/python3.8/site-packages/torchgen/context.py<lambda>6       z)native_function_manager.<locals>.<lambda>)!use_const_ref_for_mutable_tensorsZuse_ilistref_for_tensor_lists)

isinstancer   outr   viewr   localZparametrizer    Zpart_of_structured_group)r   r   r   r   native_function_manager'   s    

r%   )r   r   c                    s"   t  ttd fdd}|S )N)r   r   c              
      s(   t |   | W  5 Q R  S Q R X d S Nr%   r   r   r   r   wrapperD   s    
z%with_native_function.<locals>.wrapper)	functoolswrapsr   r   r   r)   r   r(   r   with_native_functionC   s    r-   c                    s$   t  tttd fdd}|S )N)r   f2r   c              
      s*   t |   | |W  5 Q R  S Q R X d S r&   r'   )r   r.   r(   r   r   r)   M   s    
z)with_native_function_and.<locals>.wrapper)r*   r+   r   r   r   r,   r   r(   r   with_native_function_andL   s    r/   c                    s$   t  tttd fdd}|S )Nslfr   r   c              
      s*   t |  | |W  5 Q R  S Q R X d S r&   r'   r1   r   r(   r   r   r)   W   s    
z,method_with_native_function.<locals>.wrapper)r*   r+   r   r   r   r,   r   r(   r   method_with_native_functionV   s    r3   c                    s$   t  tttd fdd}|S )Nr0   c              
      s.   t |d   | |W  5 Q R  S Q R X d S )Nr   r'   r2   r(   r   r   r)   b   s    z3method_with_nested_native_function.<locals>.wrapper)r*   r+   r   r   r   r,   r   r(   r   "method_with_nested_native_function_   s    r4   c                    s$   t  tttd fdd}|S )N)r   backend_indexr   c              
      s*   t |   | |W  5 Q R  S Q R X d S r&   r'   )r   r5   r(   r   r   r)   o   s    
z/with_native_function_and_index.<locals>.wrapper)r*   r+   r   r   r   r,   r   r(   r   with_native_function_and_indexl   s    r6   c                    s,   t  ttttf td fdd}|S )N)r   backend_indicesr   c              
      s*   t |   | |W  5 Q R  S Q R X d S r&   r'   )r   r7   r(   r   r   r)   {   s    
z1with_native_function_and_indices.<locals>.wrapper)r*   r+   r   r   r   r   r   r,   r   r(   r    with_native_function_and_indicesx   s     r8   )%
contextlibr*   typingr   r   r   r   r   r   r   r	   r
   Ztorchgen.localr$   Ztorchgen.modelr   r   r   r   r   Ztorchgen.utilsr   r   r   r   boolstrr   r   contextmanagerr%   r-   r/   r3   r4   r6   r8   r   r   r   r   <module>   sL   ,

		$	(
(
