
    9j[                        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 )    )annotationsN   )_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      T/media/conek/DATA/Code/OCR/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>.castY   s7    a. 00E7CC ??1E::r   )rH   r   rI   r   result_type_implr   typecast_tensorsnep50_to_tensors__name__NEP50_FUNCSr   )x1x2r   r@   r   rA   r   rB   rC   rD   rL   r   
torch_funcs       `       r   wrappedz"deco_binary_ufunc.<locals>.wrappedH   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   OutArray | NonerR   r
   rS   r
   r@   r   r   CastingModes | NonerA   r   r   DTypeLike | NonerB   r   rC   r   rD   r   r   rP   __qualname__rT   rU   s   ` r   deco_binary_ufuncr]   A   s     
  $	"8 %)'2$'"&$)(,%)"8 	"8"8"8 ""8 %"8 ""8  "8 ""8 &"8 #"8 "8H &..G!**GNr   r=   r>   F)r   rA   r   rB   rC   rD   axesaxisc                  |t        j                  | |      }t        j                  | |f||      \  } }t	        j
                  | |      }t        |||      }|S r   )r   rM   r   rN   r   r   r   )rR   rS   r   r   rA   r   rB   rC   rD   r^   r_   r   s               r   r   r   w   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 )NrG   r   zldexp 2nd arg must be integer)rH   r   rI   r   r   rJ   cast_int_to_floatr   	_categoryr   
ValueErrorr   r!   float16tor   )rR   rS   r   r@   r   rA   r   rB   rC   rD   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    ).0rK   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)
sumrd   	TypeErrorr   rM   r   rN   r   r    r   )rR   rS   out1out2r   r@   r   rA   r   rB   rC   rD   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    )rK   argskwdsrt   ru   s        r   modfry      s&    q!+d+d+ID#9r   )r    ry   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   rP   	_fp_unaryrb   r   )rK   r   r@   r   rA   r   rB   rC   rD   r   rT   s             r   rU   z!deco_unary_ufunc.<locals>.wrapped&  sY     %%a8A)+''*AA#FC9r   r   )
r   rW   rK   r	   r   rX   r   rY   rB   r   rZ   r\   s   ` r   deco_unary_ufuncr     s       $
 '2"&$)  %   " . &..G!**GNr   r   )r   rW   rR   r	   rS   r	   r   rX   rA   r   r   rY   rB   r   rC   r   rD   r   r^   r   r_   r   rV   )NN)NN)r   z'tuple[OutArray | None, OutArray | None]rR   r	   rS   r	   ro   rW   rp   rW   r@   r   r   rX   rA   r   r   rY   rB   r   rC   r   rD   r   )"
__future__r   r    r   r   r   r   _normalizationsr	   r
   r   r   r   r   r   r   dir
startswith_binaryrQ   r]   r   r!   r    namegetattrufuncvarsry   _unaryr   r   __all__)r   s   0r   <module>r      s   #  J J   '(??3D0V$V 	</l 
  	 $/ #" %$(!%## 
	 !    "    4 
  	#4 !%#. #" %$(!%#4 
	#4#4#4 #4 !#4 #4 #4 #4 "#4 #4 #4N  ! 3?& !%#. #" %$(!%& 
1&&& & 	& & !& & & & "& & &X  ,D'.E$U+DF4L,

 9
9 &'
??3DGO 	
	@"P  +D&-E#E*DF4L+
 F
a	v
s   EE"