
    קg                        d dl mZ d dlmZ d dlZddlmZmZmZm	Z	 ddl
mZmZmZmZmZmZmZ d Zd  ee          D             Zd	Zd
 Ze	 d/dddddddddd0d            Ze	 d/d ddddddd!d1d$            Ze	 	 	 d2d ddddddd!d3d)            ZeD ]$Z eee          Z ee           e            e<   %d* Zeg d+z   Zd,  ee          D             Zg d-Z d. Z!eD ]$Z eee          Z e!e           e            e<   %eez   Z"dS )4    )annotations)OptionalN   )_binary_ufuncs_impl_dtypes_impl_unary_ufuncs_impl_util)	ArrayLikeArrayLikeOrScalarCastingModes	DTypeLike
normalizerNotImplementedTypeOutArrayc                ~    |:t          j        | |j        j        |          } t	          j        | |j                  } | S N)r	   typecast_tensordtypetorch_dtypetorchbroadcast_toshape)resultoutcastings      P/var/www/html/ai-engine/env/lib/python3.11/site-packages/torch/_numpy/_ufuncs.py_ufunc_postprocessr      s9    
&vsy/DgNN#FCI66M    c                D    g | ]}|                     d           s|dv|S )_)r   matmuldivmodldexp
startswith.0names     r   
<listcomp>r)      sD       ??3 %)0V$V$V 	$V$V$Vr   )addsubtractmultiplyfloor_dividetrue_dividedivide	remainderbitwise_and
bitwise_orbitwise_xorbitwise_left_shiftbitwise_right_shifthypotarctan2	logaddexp
logaddexp2	heavisidecopysignfmaxminimumfminmaximumfmodgcdlcmpowc           
     t     t           	 dddddddddd fd            } j        |_         j        |_        |S )zCommon infra for binary ufuncs.

    Normalize arguments, sort out type casting, broadcasting and delegate to
    the pytorch functions for the actual work.
    NT	same_kindKFwherer   orderr   subok	signatureextobjr   Optional[OutArray]x1r   x2rH   r   r   Optional[CastingModes]rI   r   Optional[DTypeLike]rJ   rK   rL   c                 |fd}
 |
| |          }  |
||          }nt          | t          j                  rKt          |t          j                  r1t          j        | |          }t          j        | |f|          \  } }n+t          j        | |j        t          v j                  \  } } | |          }t          ||          S )Nc                    t          | t          j                  rt          j        | |          S t          j        | |          S )Nr   )
isinstancer   Tensorr	   r   	as_tensor)xr   r   s     r   castz0deco_binary_ufunc.<locals>.wrapped.<locals>.cast[   sA    a.. ; 0E7CCC ?1E::::r   )rU   r   rV   r   result_type_implr	   typecast_tensorsnep50_to_tensors__name__NEP50_FUNCSr   )rN   rO   r   rH   r   rI   r   rJ   rK   rL   rY   r   
torch_funcs       `       r   wrappedz"deco_binary_ufunc.<locals>.wrappedJ   s     ; ; ; ; ; b%Bb%BBEL)) 	jU\.J.J 	 1"b99E+RHeWEEFB!2B
+{:J<O FB B##!&#w777r   r   r   rM   rN   r   rO   r   rH   r   r   rP   rI   r   r   rQ   rJ   r   rK   r   rL   r   r   r]   __qualname__r_   r`   s   ` r   deco_binary_ufuncre   C   sv     
 #'	"8 %)*5$'%)$)(,%)"8 "8 "8 "8 "8 "8 "8 Z"8H &.G!*GNr   rE   rF   F)r   rI   r   rJ   rK   rL   axesaxisr   rM   rN   r
   rO   r   rP   rI   r   r   rQ   rJ   rK   rL   rf   rg   c                  |t          j        | |          }t          j        | |f||          \  } }t	          j        | |          }t          |||          }|S r   )r   rZ   r	   r[   r   r!   r   )rN   rO   r   r   rI   r   rJ   rK   rL   rf   rg   r   s               r   r!   r!   y   s_      }-b"55#RHeW==FB 'B//FW55FMr   TrG   r   rH   c              N   |Ht          | t          j                  rt          j        | ||          } nYt          j        | |          } nBt          | t          j                  s(t          j        |           } t          j        |           } t          j        |          }t          j        |j	                  dk    rt          d          t          j        | |          }
| j	        t          j        k    r|
                    t          j                  }
t          |
||          S )NrT   r   zldexp 2nd arg must be integer)rU   r   rV   r	   r   rW   cast_int_to_floatr   	_categoryr   
ValueErrorr   r#   float16tor   )rN   rO   r   rH   r   rI   r   rJ   rK   rL   r   s              r   r#   r#      s     b%,'' 	2&r5'::BB5111BB"el++ 	-$$B(,,B			Bbh''1,,8999 &r2..F	x5=  5=))fc7333r   NN-tuple[Optional[OutArray], Optional[OutArray]]out1out2c                 t          d ||fD                       }|dk    rt          d          |dk    r|\  }}||t          d          n|\  }}|t          j        | |          }t          j        | |f||          \  } }t          j        | |          \  }}t          |||          }t          |||          }||fS )Nc              3     K   | ]}|d uV  	d S r    )r'   rX   s     r   	<genexpr>zdivmod.<locals>.<genexpr>   s&      77Q1D=777777r   r   z&both out1 and out2 need to be provided   z>cannot specify 'out' as both a positional and keyword argument)
sumrl   	TypeErrorr   rZ   r	   r[   r   r"   r   )rN   rO   rq   rr   r   rH   r   rI   r   rJ   rK   rL   num_outso1o2quotrems                    r   r"   r"      s    & 774,77777H1}}ABBB	QB>R^P   ,
 
d}-b"55#RHeW==FB#*2r22ID#dD'22D
S$
0
0C9r   c               2    t          | dg|R i |\  }}||fS )Nr   )r"   )rX   argskwdsr}   r~   s        r   modfr      s/    q!+d+++d++ID#9r   )r"   r   r!   r#   c                H    g | ]}|                     d           s|dk    | S )r    r   r$   r&   s     r   r)   r)      s?     
 
 
??3
 %)GOO 	$3OOr   )arccosarccosharcsinarcsinharctanarctanhcbrtcoscoshdeg2raddegreesexpexp2expm1loglog10log1plog2rad2degradians
reciprocalsinsinhsqrtsquaretantanhtruncc           
     t     t           	 dddddddddd fd            } j        |_         j        |_        |S )zCommon infra for unary ufuncs.

    Normalize arguments, sort out type casting, broadcasting and delegate to
    the pytorch functions for the actual work.
    NTrE   rF   FrG   r   rM   rX   r
   r   rP   r   rQ   rJ   r   c                  |t          j        | ||          } 
j        t          v rt          j        |           }  
|           }	t          |	||          }	|	S r   )r	   r   r]   	_fp_unaryrj   r   )rX   r   rH   r   rI   r   rJ   rK   rL   r   r_   s             r   r`   z!deco_unary_ufunc.<locals>.wrapped(  s`     %a88A)++'**AA#FC99r   r   )
r   rM   rX   r
   r   rP   r   rQ   rJ   r   rb   rd   s   ` r   deco_unary_ufuncr   !  su      #'
 *5%)$)       Z. &.G!*GNr   r   )r   rM   rN   r
   rO   r
   r   rP   rI   r   r   rQ   rJ   r   rK   r   rL   r   rf   r   rg   r   ra   )NNro   )r   rp   rN   r
   rO   r
   rq   rM   rr   rM   rH   r   r   rP   rI   r   r   rQ   rJ   r   rK   r   rL   r   )#
__future__r   typingr   r    r   r   r   r	   _normalizationsr
   r   r   r   r   r   r   r   dir_binaryr^   re   r!   r#   r"   r(   getattrufuncvarsr   _unaryr   r   __all__ru   r   r   <module>r      s   # " " " " "        J J J J J J J J J J J J                    '((  </ / /l 
 #	 '2 #!% %$(!%##     4 
 #	#4 !%&1 #!% %$(!%#4 #4 #4 #4 #4 #4N   $#9E& !%&1 #!% %$(!%& & & & & &X  , ,DG'..E$$U++DDFF4LL  
 999
9
 
&''
 
 
  	@" " "P  + +DG&--E##E**DDFF4LL F
r   