
    sg                        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 ee      D  cg c]  } | j)                  d      s| d	vr|  c} Zd
Zd Ze	 dddddddddd	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 dd       Ze	 ddddddddd	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 dd       Ze	 	 	 ddddddddd	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 dd       ZeD ]  Z eee      Z ee       e       e<    d Zeg dz   Z ee      D  cg c]  } | j)                  d      s| dk7  r|  c} Z g dZ!d Z"e D ]  Z eee      Z e"e       e       e<    ee z   Z#yc c} w c c} w )    )annotations)OptionalN   )_binary_ufuncs_impl_dtypes_impl_unary_ufuncs_impl_util)	ArrayLikeArrayLikeOrScalarCastingModes	DTypeLike
normalizerNotImplementedTypeOutArrayc                    |Kt        j                  | |j                  j                  |      } t	        j
                  | |j                        } | S N)r	   typecast_tensordtypetorch_dtypetorchbroadcast_toshape)resultoutcastings      G/var/www/html/venv/lib/python3.12/site-packages/torch/_numpy/_ufuncs.py_ufunc_postprocessr      s@    
&&vsyy/D/DgN##FCII6M    _)r   matmuldivmodldexp)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         	 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extobjc                 |fd}
 |
| |      }  |
||      }nt        | t        j                        rMt        |t        j                        r3t        j                  | |      }t        j                  | |f|      \  } }n5t        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[   s7    a. 00E7CC ??1E::r   )rI   r   rJ   r   result_type_implr	   typecast_tensorsnep50_to_tensors__name__NEP50_FUNCSr   )x1x2r   rA   r   rB   r   rC   rD   rE   rM   r   
torch_funcs       `       r   wrappedz"deco_binary_ufunc.<locals>.wrappedJ   s     ; b%Bb%BELL)jU\\.J 11"b9E++RHeWEFB!22B
++{:J<O<OFB B#!&#w77r   r   r   Optional[OutArray]rS   r   rT   r   rA   r   r   Optional[CastingModes]rB   r   r   Optional[DTypeLike]rC   r   rD   r   rE   r   r   rQ   __qualname__rU   rV   s   ` r   deco_binary_ufuncr^   C   s     
 #'	"8 %)*5$'%)$)(,%)"8  	"8"8"8 ""8 ("8 ""8 #"8 ""8 &"8 #"8 "8H &..G!**GNr   r>   r?   F)r   rB   r   rC   rD   rE   axesaxisc                  |t        j                  | |      }t        j                  | |f||      \  } }t	        j
                  | |      }t        |||      }|S r   )r   rN   r	   rO   r   r    r   )rS   rT   r   r   rB   r   rC   rD   rE   r_   r`   r   s               r   r    r    y   s\      }--b"5##RHeW=FB ''B/FW5FMr   Tr@   c              d   |Jt        | t        j                        rt        j                  | ||      } n\t        j
                  | |      } nDt        | t        j                        s*t        j
                  |       } t        j                  |       } t        j
                  |      }t        j                  |j                        dk7  rt        d      t        j                  | |      }
| j                  t        j                  k(  r|
j                  t        j                        }
t        |
||      S )NrH   r   zldexp 2nd arg must be integer)rI   r   rJ   r	   r   rK   cast_int_to_floatr   	_categoryr   
ValueErrorr   r"   float16tor   )rS   rT   r   rA   r   rB   r   rC   rD   rE   r   s              r   r"   r"      s     b%,,'&&r5':B51B"ell+$B((,B		Bbhh'1,899 &&r2.F	xx5== 5==)fc733r   c              \   t        d ||fD              }|dk(  rt        d      |dk(  r|\  }}||t        d      |\  }}|t        j                  | |      }t        j                  | |f||      \  } }t        j                  | |      \  }}t        |||      }t        |||      }||fS )Nc              3  $   K   | ]  }|d u 
 y wr    ).0rL   s     r   	<genexpr>zdivmod.<locals>.<genexpr>   s     7Q1D=7s   r   z&both out1 and out2 need to be provided   z>cannot specify 'out' as both a positional and keyword argument)
sumre   	TypeErrorr   rN   r	   rO   r   r!   r   )rS   rT   out1out2r   rA   r   rB   r   rC   rD   rE   num_outso1o2quotrems                    r   r!   r!      s    & 74,77H1}ABB	QB>R^P  
d}--b"5##RHeW=FB#**2r2ID#dD'2D
S$
0C9r   c               0    t        | dg|i |\  }}||fS )Nr   )r!   )rL   argskwdsru   rv   s        r   modfrz      s&    q!+d+d+ID#9r   )r!   rz   r    r"   r   )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         	 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.
    NTr>   r?   Fr@   c                  |t        j                  | ||      } 
j                  t        v rt        j                  |       }  
|       }	t        |	||      }	|	S r   )r	   r   rQ   	_fp_unaryrc   r   )rL   r   rA   r   rB   r   rC   rD   rE   r   rU   s             r   rV   z!deco_unary_ufunc.<locals>.wrapped(  sY     %%a8A)+''*AA#FC9r   r   )
r   rX   rL   r
   r   rY   r   rZ   rC   r   r[   r]   s   ` r   deco_unary_ufuncr   !  s      #'
 *5%)$)   ( # " . &..G!**GNr   r   )r   rX   rS   r
   rT   r
   r   rY   rB   r   r   rZ   rC   r   rD   r   rE   r   r_   r   r`   r   rW   )NN)NN)r   z-tuple[Optional[OutArray], Optional[OutArray]]rS   r
   rT   r
   rp   rX   rq   rX   rA   r   r   rY   rB   r   r   rZ   rC   r   rD   r   rE   r   )$
__future__r   typingr   r    r   r   r   r	   _normalizationsr
   r   r   r   r   r   r   r   dir
startswith_binaryrR   r^   r    r"   r!   namegetattrufuncvarsrz   _unaryr   r   __all__)r   s   0r   <module>r      s   #   J J   '(??3D0V$V 	</l 
 #	 '2 #!% %$(!%## 
	 $    "    4 
 #	#4 !%&1 #!% %$(!%#4 
	#4#4#4 #4 $#4 #4 #4 #4 "#4 #4 #4N   $#9E& !%&1 #!% %$(!%& 
7&&& & 	& & $& & & & "& & &X  ,D'.E$U+DF4L,

 9
9 &'
??3DGO 	
	@"P  +D&-E#E*DF4L+
 F
a	v
s   E#E(