
    <Цiu                        S SK r S SKrS SKrS SKrS SKJrJrJrJrJ	r	J
r
JrJrJr  S SKrS SKJr  S SKJr  S SKJr  S SKJr  S SKJrJrJr  S SKJr  S S	KJrJr  S S
KJ r   S SK!J"r"  S SK#J$r$  S SK%J&r&  SSK'J(r(  \" S\
S9r)/ SQr*S\R&                  S\+4S jr,S\S\)4   S\S\\)\RZ                  4   4   4S jr.S\	\+   S\	\+   S\	\+   4S jr/S\R`                  S\R`                  S\R`                  4S jr1 " S S \Rd                  5      r3 " S! S"\Rd                  5      r4 " S# S$\Rd                  5      r5 " S% S&\Rd                  5      r6 " S' S(\Rd                  5      r7 " S) S*\35      r8 " S+ S,\Rd                  5      r9 " S- S.\Rd                  5      r: " S/ S0\Rd                  5      r; " S1 S2\Rd                  5      r< " S3 S4\Rd                  5      r= " S5 S6\\5      r> " S7 S8\>\5      r? " S9 S:\>\5      r@S; rAS< rB " S= S>\Rd                  5      rC " S? S@\Rd                  5      rD " SA SB\Rd                  5      rE " SC SD\Rd                  5      rF " SE SF\Rd                  5      rG " SG SH\Rd                  5      rH " SI SJ\Rd                  5      rI " SK SL\Rd                  5      rJ " SM SN\Rd                  5      rK " SO SP\Rd                  5      rL " SQ SR\Rd                  5      rMSS rN\N" ST5      rO\N" SU5      rP\N" SV5      rQ\N" SW5      rR\N" SX5      rS\N" SY5      rT\N" SZ5      rU\N" S[5      rV\N" S\5      rW\N" S]5      rX\N" S^5      rY\N" S_5      rZ\N" S`5      r[\N" Sa5      r\Sb r]\]" ScSd5      r^\]" SeSf5      r_g)g    N)	AnyCallableIterableListOptionalSupportsFloatTupleTypeVarUnion)Ssympify)Expr)Application)_torf	fuzzy_andfuzzy_or)equal_valued)	LatticeOpShortCircuit)ordered)walk)
PRECEDENCE)sift   )int_oo_T)bound)FloorDivModularIndexingWhere	PythonModModCleanDiv	CeilToInt
FloorToIntCeilDiv
IntTrueDivFloatTrueDivLShiftRShift!IsNonOverlappingAndDenseIndicatorTruncToFloat
TruncToInt
RoundToIntRoundDecimalToFloatFloatPowPowByNaturalIdentityexprreturnc                 "   U R                   =(       a}    [        U R                  5      S:H  =(       a^    U R                  S   R                  =(       a>    U R                  S   R                  =(       a    U R                  S   U R                  S   L$ )N   r   r   )is_Addlen_args	is_symbol)r5   s    [/var/www/html/ai-image-ml/venv/lib/python3.13/site-packages/torch/utils/_sympy/functions.py_is_symbols_binary_summationr>   ]   sr     	 	/

Oq 	/JJqM##	/ JJqM##	/ JJqMA.    f.c                    ^  [         R                  " T 5      S[        S[        [        [
        R                  4   4U 4S jj5       nU$ )Nargsr6   c                     > T" U 6 n[        S U  5       5      (       a>  [        U[        R                  5      (       d  [        R                  " [	        U5      5      nU$ )Nc              3   V   #    U  H  n[        U[        R                  5      v   M!     g 7fN)
isinstancesympyFloat.0as     r=   	<genexpr>-_keep_float.<locals>.inner.<locals>.<genexpr>l   s     84az!U[[))4   '))anyrF   rG   rH   float)rB   rr@   s     r=   inner_keep_float.<locals>.inneri   sM    $%tH84888u{{B
 B
 E!H%Ar?   )	functoolswrapsr   r   r   rG   rH   )r@   rR   s   ` r=   _keep_floatrV   h   s@    __QS U2u{{?3   Lr?   xyc                     S X4;   a  g X:H  $ rE    )rW   rX   s     r=   fuzzy_eqr[   u   s    v~6Mr?   pqc                   ^^ S[         R                  S[        4S jmS[         R                  S[        4U4S jjn[        R                  " U" U 5      U" U5      5      nX-  X-  p[        [        [         R                  R                  [         R                  R                  U 5      5      5      n[         R                  R                  U5      nU H$  m[        U4S jU 5       5      (       d  M  UT-  nM&     U$ )a  
Fast path for sympy.gcd, using a simple factoring strategy.

We try to rewrite p and q in the form n*e*p1 + n*e*p2 and n*e*q0,
where n is the greatest common integer factor and e is the largest
syntactic common factor (i.e., common sub-expression) in p and q.
Then the gcd returned is n*e, cancelling which we would be left with
p1 + p2 and q0.

Note that further factoring of p1 + p2 and q0 might be possible with
sympy.factor (which uses domain-specific theories). E.g., we are unable
to find that x*y + x + y + 1 is divisible by x + 1. More generally,
when q is of the form q1 + q2 (instead of being already factored) it
might be necessary to fall back on sympy.gcd.
rW   r6   c                    [         R                  R                  U 5       Vs/ s H>  n[        U[        [         R
                  45      (       d  M*  [        [	        U5      5      PM@     nn[        R                  " U5      $ s  snf rE   )	rG   Mul	make_argsrF   intIntegerabsmathprod)rW   arginteger_coefficientss      r=   integer_coefficient0simple_floordiv_gcd.<locals>.integer_coefficient   sg     yy**1-+
-#U]]34 CCM- 	 +

 yy-..+
s   )A?A?r5   c                    > [        T[        R                  R                  U 5      5      n[        R
                  " [        R                  U5      $ rE   )maprG   Addra   rT   reducere   gcd)r5   integer_factorsri   s     r=   integer_factor+simple_floordiv_gcd.<locals>.integer_factor   s:    ),!4!4T!:*
 /::r?   c              3   .   >#    U  H
  nTU;   v   M     g 7frE   rZ   )rJ   
base_splitrW   s     r=   rL   &simple_floordiv_gcd.<locals>.<genexpr>   s     =:qJs   )rG   Basicrb   re   ro   listrl   r`   ra   rm   all)r\   r]   rq   ro   base_splitsdivisor_splitri   rW   s         @@r=   simple_floordiv_gcdr{   {   s    "/u{{ /s /;U[[ ;S ; xxq)>!+<=C7AGq15EII!4!4Q!782K .3YY-@-@-CM===='C  Jr?   c            	       F   \ rS rSr% SrSr\\S4   \S'   Sr	\\S'   Sr
\\S	'   \S
\R                  4S j5       r\S
\R                  4S j5       rS\R"                  R$                  S
\4S jr\S\R,                  S\R,                  S
\\R                  S4   4S j5       rSrg)r      z
We maintain this so that:
1. We can use divisibility guards to simplify FloorDiv(a, b) to a / b.
2. Printing out the expression is nicer (compared to say, representing a//b as (a - a % b) / b)

NB: This is Python-style floor division, round to -Inf
r8   .nargs#   
precedenceT
is_integerr6   c                      U R                   S   $ Nr   rB   selfs    r=   baseFloorDiv.base       yy|r?   c                      U R                   S   $ Nr   r   r   s    r=   divisorFloorDiv.divisor   r   r?   printerc                     UR                  U R                  [        S   S-
  5      nUR                  U R                  [        S   S-
  5      nSU SU S3$ )NAtomg      ?(z//))parenthesizer   r   r   )r   r   r   r   s       r=   	_sympystrFloorDiv._sympystr   sW    ##DIIz&/AC/GH&&t||Z5G#5MN4&7)1%%r?   r   r   Nc                 *	   UR                   (       a  [        S5      eU[        [        * [        R                  [        R                  * 4;   a@  U[        [        * [        R                  [        R                  * 4;   a  [        R
                  $ U[        R
                  L d  U[        R
                  L a  [        R
                  $ UR                   (       a  [        R                  R                  $ UR                  (       a  [        US5      (       a  U$ UR                  (       a(  [        US5      (       a  [        R                  " US5      $ [        U[        R                  5      (       Ga"  [        U[        R                  5      (       Ga  U[        [        * [        R                  [        R                  * 4;   d0  U[        [        * [        R                  [        R                  * 4;   a  [        U5      [        U5      -  nU[        R                  :X  a  [        $ U[        R                  * :X  a  [        * $ [        R                   " U5      (       a  [        R
                  $ [        R"                  " [        R$                  " U5      5      $ [        U[        R"                  5      (       aJ  [        U[        R"                  5      (       a+  [        R"                  " ['        U5      ['        U5      -  5      $ [        U[(        5      (       a)  [)        UR*                  S   UR*                  S   U-  5      $ [        U[        R"                  5      (       a  Sn/ n[        R,                  R/                  U5       H/  nXb-  nUR                  (       d  M  UR1                  U5        XG-  nM1     [3        U5      S:w  a&  [)        U[        R,                  " USS06-
  U5      U-   $  [5        X5      n[        US5      (       a5  [        U[        R,                  5      (       a  [        R6                  " X5      n[        US5      (       d8  [)        [        R8                  " X-  5      [        R8                  " X(-  5      5      $  g ! [        R:                   a     g f = f)Ndivision by zeror   r   evaluateF)is_zeroZeroDivisionErrorr   rG   oonanr   Zeror   r   r`   rF   NumberrP   re   infisnanrc   floorrb   r   rB   rm   ra   appendr:   r{   ro   simplifyPolynomialError)	clsr   r   rQ   	quotientstermstermquotientro   s	            r=   evalFloorDiv.eval   s1    ??#$677FVGUXXy99gGHHXXI	J
 ?
 99599599 499<<77<<??|GQ77K??|GR8899T2&&tU\\**7ELL11&%((UXXI>>vw588)DD deGn,ADHH}txxiwAyy }}TZZ]33dEMM**z'5==/Q/Q==Tc'l!:;;dH%%DIIaL$))A,*@AA gu}}--IE		++D1>&&&LL&)I 2 5zQ TEIIu$Eu$EEwO 
		%d4CC##
7EII(F(Fii.Q''NN4:.w}0M  (  $$ 		s   BQ; ;RRrZ   )__name__
__module____qualname____firstlineno____doc__r   r	   rb   __annotations__r   r   boolpropertyrG   rv   r   r   printing
StrPrinterstrr   classmethodrc   r   r   __static_attributes__rZ   r?   r=   r   r      s     "E5c?!JJekk     &!:!: &s & P==P+0==P	u{{D 	!P Pr?   r   c            
           \ rS rSr% SrSr\\S4   \S'   Sr	\
\S'   Sr\\S	'   \S
\R                  S\R                  S\R                  S\\R                      4S j5       rS\\
   4S jrS\\
   4S jrSrg)r    i)  zC
ModularIndexing(a, b, c) => (a // b) % c where % is the C modulus
   .r   Tr   r   r   r   r   modulusr6   c                    US:X  d  US:X  a  [         R                  R                  $ [        U[         R                  5      (       aE  [        U[         R                  5      (       a&  [        U[         R                  5      (       a  X-  U-  $  US:w  aU  [         R
                  " X5      nUS:w  a9  [        [         R                  " X-  5      [         R                  " X$-  5      U5      $ [        U[         R                  5      (       Ga  / nSnUR                   H  n[         R
                  " XsU-  5      X2-  :w  d  M$  [        U[         R                  5      (       a  US:  d^  [        U[         R                  5      (       aC  [        UR                  S   [         R                  5      (       a  UR                  S   S:  a  Sn  OUR                  U5        M     [        U5      [        UR                  5      :w  a  U(       a  [        [        U5      X#5      $ [        U[        5      (       a*  [        UR                  S   UR                  S   U-  U5      $ g ! [         R                   a     GNf = f)Nr   r   TF)rG   r   r   rF   rc   ro   r    r   r   rm   rB   r`   r   r:   sumr   )r   r   r   r   ro   	new_termsall_positiver   s           r=   r   ModularIndexing.eval2  s    19177<< tU]]++7EMM227EMM22Ow..
	!|ii.!8*tz2w}5  dEII&&-/I!%L		99TW#459JJ"477D1H"433&tyy|U]]CC IIaL1, (-!((. "  9~TYY/L&s9~wHHdH%%"499Q<11GQQ9 $$ 		s   AI I-,I-c                 d    U R                   S S u  p[        UR                  UR                  5      $ Nr8   )rB   r[   is_nonnegativer   r\   r]   s      r=   _eval_is_nonnegative$ModularIndexing._eval_is_nonnegativeg  s,    yy!}((!*:*:;;r?   c                 d    U R                   S S u  p[        UR                  UR                  5      $ r   )rB   r[   is_positiver   s      r=   _eval_is_positive!ModularIndexing._eval_is_positivek  s(    yy!}q}}55r?   rZ   N)r   r   r   r   r   r   r	   rb   r   r   r   r   r   rG   rc   r   rv   r   r   r   r   rZ   r?   r=   r    r    )  s     "E5c?!JJ2==2+0==2CH==2	%++	2 2h<htn <68D> 6r?   r    c            
           \ rS rSr% SrSr\\S4   \S'   Sr	\\S'   S\
\   4S	 jrS\
\   4S
 jrS\
\   4S jr\S\R"                  S\R"                  S\R"                  S\
\R"                     4S j5       rSrg)r!   ip  z
Good ol' ternary operator
r   .r   r   r   r6   c                     U R                   S   R                  (       a   U R                   S   R                  (       a  S$ S $ Nr   r8   TrB   r   r   s    r=   _eval_is_integerWhere._eval_is_integerx  s.    yy|..499Q<3J3JtTPTTr?   c                     U R                   S   R                  (       a   U R                   S   R                  (       a  S$ S $ r   )rB   r   r   s    r=   r   Where._eval_is_nonnegative{  s9     yy|**tyy|/J/J 	
 	
r?   c                     U R                   S   R                  (       a   U R                   S   R                  (       a  S$ S $ r   rB   r   r   s    r=   r   Where._eval_is_positive  s.    yy|//DIIaL4L4LtVRVVr?   cr\   r]   c                 \    U[         R                  :X  a  U$ U[         R                  :X  a  U$ g rE   )rG   truefalse)r   r   r\   r]   s       r=   r   
Where.eval  s(     

?H%++Hr?   rZ   N)r   r   r   r   r   r   r	   rb   r   r   r   r   r   r   r   r   rG   rv   r   r   rZ   r?   r=   r!   r!   p  s     "E5c?!JU(4. U
htn 
W8D> W  %05	%++	 r?   r!   c                       \ rS rSr% Sr\\S4   \S'   Sr\\S'   Sr	\
\S'   \S	\R                  S
\R                  S\\R                     4S j5       rS\\
   4S jrS\\
   4S jrSrg)r"   i  r~   .r   r   r   Tr   r\   r]   r6   c                    UR                   (       a  [        S5      eU[        R                  L d  XU* 4;   d  US:X  a  [        R                  $ UR                  (       a  UR                  (       a  X-  $ UR                  (       aH  US:X  aB  UR
                  (       a  [        R                  $ UR                  (       a  [        R                  $ X-  nUR                  (       a  [        R                  $ X:  nUR                  (       a#  [        U5      (       a  UR                  (       a  U$ [        R                  " X5      S:X  a  [        R                  $ g )NModulo by zeror   r8   r   )r   r   r   r   	is_Numberis_evenis_oddOner   
is_Booleanr   r   rG   r#   r   r\   r]   rQ   lesss        r=   r   PythonMod.eval  s     99#$455 ;!A2w,!q&66M ;;1;;5L ;;16yyvvxxuu E<<66M
 u??tDzzammH99Q?a66Mr?   c                 F    U R                   S   R                  (       a  S$ S $ Nr   Tr   r   s    r=   r   PythonMod._eval_is_nonnegative      yy|//t9T9r?   c                 F    U R                   S   R                  (       a  S$ S $ r   )rB   is_negativer   s    r=   _eval_is_nonpositivePythonMod._eval_is_nonpositive  r   r?   rZ   N)r   r   r   r   r   r	   rb   r   r   r   r   r   rG   r   r   r   r   r   r   rZ   r?   r=   r"   r"     s    !E5c?!JJ*UZZ *EJJ *8EJJ3G * *Z:htn ::htn :r?   r"   c                   @    \ rS rSr% SrSr\\S'   SrSr	\
S 5       rSrg)	r#   i  r~   r   r   Tc                    UR                   (       a  [        S5      eU[        R                  L d  XU* 4;   d  US:X  a  [        R                  $ UR                  (       a/  UR                  (       a  US:  d   U5       eUS:  d   U5       eX-  $ UR                  (       aH  US:X  aB  UR
                  (       a  [        R                  $ UR                  (       a  [        R                  $ X-  nUR                  (       a  [        R                  $ X:  nUR                  (       a%  [        U5      (       a  UR                  (       a  U$ g g g )Nr   r   r   r8   )r   r   r   r   r   r   r   r   r   r   r   r   r   s        r=   r   Mod.eval  s     99#$455 ;!A2w,!q&66M ;;1;;6166165L ;;16yyvvxxuu E<<66M
 u??tDzzammH /<z?r?   rZ   N)r   r   r   r   r   r   rb   r   r   r   r   r   r   rZ   r?   r=   r#   r#     s-    EJJN) )r?   r#   c                       \ rS rSrSrSrg)r$   i  zN
Div where we can assume no rounding.
This is to enable future optimizations.
rZ   N)r   r   r   r   r   r   rZ   r?   r=   r$   r$     s    r?   r$   c                   (    \ rS rSrSr\S 5       rSrg)r%   i
  Tc                 .   U[         R                  [        4;   a  [        $ U[         R                  * [        * 4;   a  [        * $ [        U[         R                  5      (       a3  [         R
                  " [        R                  " [        U5      5      5      $ g rE   )	rG   r   r   rF   r   rc   re   ceilrP   r   numbers     r=   r   CeilToInt.eval  sh     ehh''Muxxi&))7Nfell++==5=!9:: ,r?   rZ   Nr   r   r   r   r   r   r   r   rZ   r?   r=   r%   r%   
  s    J; ;r?   r%   c                   (    \ rS rSrSr\S 5       rSrg)r&   i  Tc                 ,   U[         R                  [        4;   a  [        $ U[         R                  * [        4;   a  [        * $ [        U[         R                  5      (       a3  [         R
                  " [        R                  " [        U5      5      5      $ g rE   )	rG   r   r   rF   r   rc   re   r   rP   r   s     r=   r   FloorToInt.eval  sf     ehh''Muxxi((7Nfell++==E&M!:;; ,r?   rZ   Nr   rZ   r?   r=   r&   r&         J< <r?   r&   c                   "    \ rS rSrSrSrS rSrg)r'   i&  z&
Div used in indexing that rounds up.
Tc                     [         R                  " U5      n[         R                  " U5      n[         R                  " X5      U:X  a  [        X5      $ [	        XS-
  -   U5      $ r   )rG   r   ro   r$   r   r   r   r   s      r=   __new__CeilDiv.__new__-  sN    }}T"--(99T#w.D**DaK0'::r?   rZ   N)r   r   r   r   r   r   r  r   rZ   r?   r=   r'   r'   &  s     J;r?   r'   c                   (    \ rS rSrSr\S 5       rSrg)r*   i6  Tc                 4    US:  a  [        S5      eUSU-  -  $ Nr   znegative shift countr8   
ValueErrorr   r   shifts      r=   r   LShift.eval9  s#    19344ahr?   rZ   Nr   rZ   r?   r=   r*   r*   6  s    J r?   r*   c                   (    \ rS rSrSr\S 5       rSrg)r+   i@  Tc                 4    US:  a  [        S5      eUSU-  -  $ r  r  r
  s      r=   r   RShift.evalC  s$    19344q%xr?   rZ   Nr   rZ   r?   r=   r+   r+   @  s    J   r?   r+   c                      \ rS rSrS r\S\\\R                  R                  R                        4S j5       r\ S&S\\\R                  R                  R                        S\\\R                  R                  R                        4S jj5       r\S 5       r\S	 5       r\S
 5       rS rS rS rS rS rS rS rS rS rS rS rS rS rS rS rS r S r!S r"S r#S r$S r%S  r&S! r'S" r(S# r)S$ r*S%r+g)'
MinMaxBaseiJ  c                 H   SSK Jn  UR                  SUR                  5      nS U 5       nU(       d  S OU R	                  U5      nU(       aD   [        U R                  U5      5      nUc&  U R                  " U40 UD6nU R                  " U40 UD6n[        U5      nU(       d  U R                  $ [        U5      S:X  a  [        U5      R                  5       $ [        R                  " U /[!        U5      Q70 UD6nXWl        Xgl        U$ ! [         a    U R                  s $ f = f)Nr   )global_parametersr   c              3   8   #    U  H  n[        U5      v   M     g 7frE   r   )rJ   rg   s     r=   rL   %MinMaxBase.__new__.<locals>.<genexpr>O  s     6   r   )sympy.core.parametersr  popr   "_satisfy_unique_summations_symbols	frozenset_new_args_filterr   zero_collapse_arguments_find_localzerosidentityr:   rw   r   r  r   _argsetunique_summations_symbols)r   original_argsassumptionsr  r   rB   r!  objs           r=   r  MinMaxBase.__new__K  s   ;??:/@/I/IJ66
  77F 	"   !!5!5d!;< )0..tC{C ++D@K@<<t9>:>>## ll3>>+>(A%
3    xx s   D D! D!r6   c                 T   [        U5      S:w  a  g[        US   [        5      (       a
  US   US   4O	US   US   4u  p#[        U5      (       d  g[        U5      (       a  U R	                  U5      $ [        U[        5      (       a#  [        USS5      nUb  U R	                  U/U5      $ g)au  
One common case in some models is building expressions of the form
max(max(max(a+b...), c+d), e+f) which is simplified to max(a+b, c+d, e+f, ...).
For such expressions, we call the Max constructor X times (once for each nested
max) and the expression gets flattened.

An expensive cost in constructing those expressions is running _collapse_arguments
and _find_localzeros. However, those two optimizations are unnecessary when the args
to max are all of the form a+b, c+d, ..etc where each term uses a unique set of symbols.

This function is used to detect such properties of the expressions we are building
and if so inform that we do not need to run those optimizations. To detect those,
we store a property in the expression that tells that this expression is a min/max
operation over terms that use unique symbols "unique_summations_symbols". This property
also memoize the set of symbols used in all the terms to make it faster to detect this
property inductively.

When we apply max to add a new term, all we need to do is check if the new term uses
unique symbols (with respect to existing terms and itself).
Example:
t = Max(a+b, c+d) ==> satisfies the property
Max(t, h+j)       ==> h,j not in [a,b,c,d] => satisfy the property.

The function returns None if the new expression does not satisfy the unique_summations_symbols
property. Otherwise, it returns a new set of unique symbols.
r8   Nr   r   r!  )r:   rF   r  r>   _unique_symbolsgetattr)r   rB   lhsrhslhs_unique_summations_symbolss        r=   r  -MinMaxBase._satisfy_unique_summations_symbolsx  s    < t9> $q':.. !Wd1gq'47# 	 ,C00 (,,&&t,, c:&&,30$-) -8**C52OPPr?   Ninitial_setc                    Uc
  [        5       OUnU Hi  nUR                  5        HR  n[        U[        R                  R
                  R                  5      (       d      gXS;   a      gUR                  U5        MT     Mk     U$ )z
Return seen_symbols if all atoms in all args are all unique symbols,
else returns None. initial_set can be used to represent initial value for seen_symbols
N)setatomsrF   rG   coresymbolSymboladd)r   rB   r-  seen_symbolsrg   elements         r=   r'  MinMaxBase._unique_symbols  sk     !, 3suC99;!'5::+<+<+C+CDD, $$W- '  r?   c                 |  ^ ^^ U(       d  U$ [        [        U5      5      nT [        L a  [        mO[        mUS   R                  (       Ga  / / 4=nu  pEU Ha  n[        U[        [        5       HE  nUR                  S   R                  (       d  M#  U[        U[        5         R                  U5        MG     Mc     [        R                  nU H1  nUR                  S   nUR                  (       d  M%  Xx:  S:X  d  M/  UnM3     [        R                  n	U H1  nUR                  S   nUR                  (       d  M%  Xy:  S:X  d  M/  Un	M3     T [        L a)  U H"  n
U
R                  (       d    OCX:  S:X  d  M   U
nM$     O2T [        :X  a(  U H"  n
U
R                  (       d    OX:  S:X  d  M   U
n	M$     SnT [        L a  U[        R                  :w  a  [        mUnOU	[        R                  :w  a  [        mU	nUbg  [        [        U5      5       HO  nX   n[        UT5      (       d  M  UR                  S   nT[        :X  a  X:  OX:  S:X  d  MA  T R                  X'   MQ     U U4S jm[        U5       H(  u  plXS-   S  Vs/ s H  nT" X5      PM     snXS-   S& M*     U U4S jn[        U5      S:  a  U" U5      nU$ s  snf )a  Remove redundant args.

Examples
========

>>> from sympy import Min, Max
>>> from sympy.abc import a, b, c, d, e

Any arg in parent that appears in any
parent-like function in any of the flat args
of parent can be removed from that sub-arg:

>>> Min(a, Max(b, Min(a, c, d)))
Min(a, Max(b, Min(c, d)))

If the arg of parent appears in an opposite-than parent
function in any of the flat args of parent that function
can be replaced with the arg:

>>> Min(a, Max(b, Min(c, d, Max(a, e))))
Min(a, Max(b, Min(a, c, d)))
r   TNc           	      |  > [        U [        [        45      (       d  U $ XR                  ;   nU(       d3  U R                  " U R                   Vs/ s H  nT" X15      PM     snSS06$ [        U T5      (       a:  U R                  " U R                   Vs/ s H  o3U:w  d  M
  T" X15      PM     snSS06$ U$ s  snf s  snf )Nr   F)rF   MinMaxrB   func)airK   condir   dos       r=   r@  *MinMaxBase._collapse_arguments.<locals>.do  s    b3*--	<Dww277 ;7aA7 ;LeLL"c""ww277 E7a1fA7 EVPUVVH !< Es   B4	B9B9r   c                   > U4S jn[        XSS9u  p#U(       d  U $ U Vs/ s H  n[        UR                  5      PM     nn[        R                  " U6 nU(       d  U $ [	        U5      nU Vs/ s H  oU-
  PM	     n	n[        U	5      (       a/  U	 V
s/ s H  n
T" U
SS06PM     nn
UR                  T" USS065        T" USS06nX</-   $ s  snf s  snf s  sn
f )Nc                    > [        U T5      $ rE   )rF   )rg   others    r=   <lambda>GMinMaxBase._collapse_arguments.<locals>.factor_minmax.<locals>.<lambda>/  s    :c5#9r?   T)binaryr   F)r   r/  rB   intersectionrw   rx   r   )rB   is_other
other_argsremaining_argsrg   arg_setscommonnew_other_argsarg_setarg_sets_diffsother_args_diffother_args_factoredr   rD  s                r=   factor_minmax5MinMaxBase._collapse_arguments.<locals>.factor_minmax.  s    9H)-dT)J&J 2<<#CHHH<%%x0F!&\N=EFX'v-XMF =!!FS"Tm5!#<e#<m"T%%c?&KU&KL"'"H%"H!$999 = G
 #Us   C	-CC)rw   r   r:  r;  	is_numberr   rB   is_comparablerF   r   r  ranger:   	enumerate)r   rB   r#  siftedminsmaxsr?  vsmallbigrg   TrK   a0r=  rT  r@  rD  s   `               @@r=   r  MinMaxBase._collapse_arguments  sb   0 KGDM"#:EE
 7"$b&(FZTac*Avvay...z!S1299!< +  LLEFF1I;;;AI$#6E  ,,CFF1I;;;AG#4C  czC==, #	  
 C==	d*!	  
 AczCLL(EA$}s4y)AA!!U++VVAY(-RV26!" '*llDG *	 dODA15!eg?2RY?DQM $	:0 t9q= &DI @s   ;J9c              #   v  #    U H  n[        U[        5      (       a1  UR                  SL d"  UR                  (       a   UR                  (       d  [        SU S35      eX R                  :X  a  [        U5      eX R                  :X  a  M  UR                  U :X  a  UR                   Sh  vN   M  Uv   M     g N7f)z
Generator filtering args.

first standard filter, for cls.zero and cls.identity.
Also reshape ``Max(a, Max(b, c))`` to ``Max(a, b, c)``,
and check arguments for comparability
FzThe argument 'z' is not comparable.N)rF   r   is_extended_realrV  rW  r	  r  r   r  r<  rB   )r   arg_sequencerg   s      r=   r  MinMaxBase._new_args_filterK  s       C sD))''50MM#*;*; >#6J!KLLhh"3''$S88##	!   $s   B%B9'B7(B9c                     [        5       nSnU Hf  nUR                  (       aA  Uc  UnM  U [        L a  [        XE5      nM1  U [        L a  [        XE5      nMG  [        SU  35      eUR                  U5        Mh     Uc  U$ [        U5      S:X  a  U1$ [        U5      S:X  a^  [        [        U5      5      nUS;   a  UR                  (       a  U [        L a  U$ U1$ US:X  a  UR                  (       a  U [        L a  U$ U1$ UR                  U5        U$ )aV  
Sequentially allocate values to localzeros.

When a value is identified as being more extreme than another member it
replaces that member; if this is never true, then the value is simply
appended to the localzeros.

Unlike the sympy implementation, we only look for zero and one, we don't
do generic is connected test pairwise which is slow
Nzimpossible r   r   )g        r   )r/  r   r;  maxr:  minAssertionErrorr4  r:   nextiterr   r   )r   valuesoptionsother_values	num_valuerg   other_values          r=   r  MinMaxBase._find_localzerosf  s    u	C}}$ #Icz$'	$7	$'	$7	,{3%-@AA  %  |!;|!tL12KH$)C)C'*cz|B	{BA~+"9"9'*cz|B	{B#r?   c                 :    [        S U R                   5       5      $ )Nc              3   8   #    U  H  oR                   v   M     g 7frE   )is_algebraicrJ   r?  s     r=   rL   &MinMaxBase.<lambda>.<locals>.<genexpr>       (HAr  r   rB   rQ  s    r=   rE  MinMaxBase.<lambda>      5(H(H#Hr?   c                 :    [        S U R                   5       5      $ )Nc              3   8   #    U  H  oR                   v   M     g 7frE   )is_antihermitianrv  s     r=   rL   rw          -$*qFr  ry  rz  s    r=   rE  r{        u -$%FF- (r?   c                 :    [        S U R                   5       5      $ )Nc              3   8   #    U  H  oR                   v   M     g 7frE   )is_commutativerv  s     r=   rL   rw          +"(Q&r  ry  rz  s    r=   rE  r{        U +"#&&+ &r?   c                 :    [        S U R                   5       5      $ )Nc              3   8   #    U  H  oR                   v   M     g 7frE   )
is_complexrv  s     r=   rL   rw         &DV||Vr  ry  rz  s    r=   rE  r{        &DQVV&D!Dr?   c                 :    [        S U R                   5       5      $ )Nc              3   8   #    U  H  oR                   v   M     g 7frE   )is_compositerv  s     r=   rL   rw    rx  r  ry  rz  s    r=   rE  r{    r|  r?   c                 :    [        S U R                   5       5      $ )Nc              3   8   #    U  H  oR                   v   M     g 7frE   )r   rv  s     r=   rL   rw         #>v!IIvr  ry  rz  s    r=   rE  r{        e#>qvv#>>r?   c                 :    [        S U R                   5       5      $ )Nc              3   8   #    U  H  oR                   v   M     g 7frE   )	is_finiterv  s     r=   rL   rw    s     %B6akk6r  ry  rz  s    r=   rE  r{    s    %B166%B Br?   c                 :    [        S U R                   5       5      $ )Nc              3   8   #    U  H  oR                   v   M     g 7frE   )is_hermitianrv  s     r=   rL   rw    rx  r  ry  rz  s    r=   rE  r{    r|  r?   c                 :    [        S U R                   5       5      $ )Nc              3   8   #    U  H  oR                   v   M     g 7frE   )is_imaginaryrv  s     r=   rL   rw    rx  r  ry  rz  s    r=   rE  r{    r|  r?   c                 :    [        S U R                   5       5      $ )Nc              3   8   #    U  H  oR                   v   M     g 7frE   )is_infiniterv  s     r=   rL   rw         'Fv!vr  ry  rz  s    r=   rE  r{        %'Fqvv'F"Fr?   c                 :    [        S U R                   5       5      $ )Nc              3   8   #    U  H  oR                   v   M     g 7frE   )r   rv  s     r=   rL   rw    r  r  ry  rz  s    r=   rE  r{    r  r?   c                 :    [        S U R                   5       5      $ )Nc              3   8   #    U  H  oR                   v   M     g 7frE   )is_irrationalrv  s     r=   rL   rw         )J6a//6r  ry  rz  s    r=   rE  r{        E)J166)J$Jr?   c                 :    [        S U R                   5       5      $ )Nc              3   8   #    U  H  oR                   v   M     g 7frE   r   rv  s     r=   rL   rw    r  r  ry  rz  s    r=   rE  r{    r  r?   c                 :    [        S U R                   5       5      $ )Nc              3   8   #    U  H  oR                   v   M     g 7frE   )is_nonintegerrv  s     r=   rL   rw    r  r  ry  rz  s    r=   rE  r{    r  r?   c                 :    [        S U R                   5       5      $ )Nc              3   8   #    U  H  oR                   v   M     g 7frE   r   rv  s     r=   rL   rw    r  r  ry  rz  s    r=   rE  r{    r  r?   c                 :    [        S U R                   5       5      $ )Nc              3   8   #    U  H  oR                   v   M     g 7frE   )is_nonpositiverv  s     r=   rL   rw    r  r  ry  rz  s    r=   rE  r{    r  r?   c                 :    [        S U R                   5       5      $ )Nc              3   8   #    U  H  oR                   v   M     g 7frE   )
is_nonzerorv  s     r=   rL   rw    r  r  ry  rz  s    r=   rE  r{    r  r?   c                 :    [        S U R                   5       5      $ )Nc              3   8   #    U  H  oR                   v   M     g 7frE   )r   rv  s     r=   rL   rw    s     "<V88Vr  ry  rz  s    r=   rE  r{    s    U"<QVV"<<r?   c                 :    [        S U R                   5       5      $ )Nc              3   8   #    U  H  oR                   v   M     g 7frE   )is_polarrv  s     r=   rL   rw         $@AZZr  ry  rz  s    r=   rE  r{        u$@$@@r?   c                 :    [        S U R                   5       5      $ )Nc              3   8   #    U  H  oR                   v   M     g 7frE   r   rv  s     r=   rL   rw    r  r  ry  rz  s    r=   rE  r{    r  r?   c                 :    [        S U R                   5       5      $ )Nc              3   8   #    U  H  oR                   v   M     g 7frE   )is_primerv  s     r=   rL   rw    r  r  ry  rz  s    r=   rE  r{    r  r?   c                 :    [        S U R                   5       5      $ )Nc              3   8   #    U  H  oR                   v   M     g 7frE   )is_rationalrv  s     r=   rL   rw    r  r  ry  rz  s    r=   rE  r{    r  r?   c                 :    [        S U R                   5       5      $ )Nc              3   8   #    U  H  oR                   v   M     g 7frE   )is_realrv  s     r=   rL   rw    r  r  ry  rz  s    r=   rE  r{    r  r?   c                 :    [        S U R                   5       5      $ )Nc              3   8   #    U  H  oR                   v   M     g 7frE   )rd  rv  s     r=   rL   rw    r  r  ry  rz  s    r=   rE  r{    r  r?   c                 :    [        S U R                   5       5      $ )Nc              3   8   #    U  H  oR                   v   M     g 7frE   )is_transcendentalrv  s     r=   rL   rw    s      .%+Vr  ry  rz  s    r=   rE  r{    s     .%&VV. )r?   c                 :    [        S U R                   5       5      $ )Nc              3   8   #    U  H  oR                   v   M     g 7frE   )r   rv  s     r=   rL   rw    r  r  ry  rz  s    r=   rE  r{    r  r?   rZ   rE   ),r   r   r   r   r  r   r   r/  rG   r1  r2  r3  r  r'  r  r  r  _eval_is_algebraic_eval_is_antihermitian_eval_is_commutative_eval_is_complex_eval_is_composite_eval_is_even_eval_is_finite_eval_is_hermitian_eval_is_imaginary_eval_is_infiniter   _eval_is_irrational_eval_is_negative_eval_is_nonintegerr   r   _eval_is_nonzero_eval_is_odd_eval_is_polarr   _eval_is_prime_eval_is_rational_eval_is_real_eval_is_extended_real_eval_is_transcendental_eval_is_zeror   rZ   r?   r=   r  r  J  s   +Z 5	#ejj''../	05 5n JN (UZZ->->-E-E)F G	#ejj''../	0 $ E EN  4 , ,\ I EH>MBOHHFDJFJ E<L@NF@NF>M ?Mr?   r  c                   Z    \ rS rSrSr\R                  r\R                  r	S r
S rS rSrg)r;  i  z5
Return, if possible, the maximum value of the list.
c                 :    [        S U R                   5       5      $ )Nc              3   8   #    U  H  oR                   v   M     g 7frE   r  rI   s     r=   rL   (Max._eval_is_positive.<locals>.<genexpr>       9y!yr  r   rB   r   s    r=   r   Max._eval_is_positive      9tyy999r?   c                 :    [        S U R                   5       5      $ )Nc              3   8   #    U  H  oR                   v   M     g 7frE   r  rI   s     r=   rL   +Max._eval_is_nonnegative.<locals>.<genexpr>  s     <)Q(()r  r  r   s    r=   r   Max._eval_is_nonnegative  s    <$))<<<r?   c                 :    [        S U R                   5       5      $ )Nc              3   8   #    U  H  oR                   v   M     g 7frE   r  rI   s     r=   rL   (Max._eval_is_negative.<locals>.<genexpr>       :	1	r  r   rB   r   s    r=   r  Max._eval_is_negative      :		:::r?   rZ   N)r   r   r   r   r   r   Infinityr  NegativeInfinityr  r   r   r  r   rZ   r?   r=   r;  r;    s,     ::D!!H:=;r?   r;  c                   Z    \ rS rSrSr\R                  r\R                  r	S r
S rS rSrg)r:  i  z5
Return, if possible, the minimum value of the list.
c                 :    [        S U R                   5       5      $ )Nc              3   8   #    U  H  oR                   v   M     g 7frE   r  rI   s     r=   rL   (Min._eval_is_positive.<locals>.<genexpr>  r  r  r  r   s    r=   r   Min._eval_is_positive  r  r?   c                 :    [        S U R                   5       5      $ )Nc              3   8   #    U  H  oR                   v   M     g 7frE   r  rI   s     r=   rL   +Min._eval_is_nonnegative.<locals>.<genexpr>  s     =9a))9r  r  r   s    r=   r   Min._eval_is_nonnegative  s    =499===r?   c                 :    [        S U R                   5       5      $ )Nc              3   8   #    U  H  oR                   v   M     g 7frE   r  rI   s     r=   rL   (Min._eval_is_negative.<locals>.<genexpr>  r  r  r  r   s    r=   r  Min._eval_is_negative  r  r?   rZ   N)r   r   r   r   r   r   r  r  r  r  r   r   r  r   rZ   r?   r=   r:  r:    s,     DzzH;>:r?   r:  c                 N    SnU S:  a  U * n US-  S:X  a  SOSnU[        X5      -  $ )Nr   r   r8   r   )	_safe_pow)r   expsigns      r=   safe_powr    s6    Daxu!GqLqb)D&&&r?   c                     US:  a  [        S5      eUS:X  a  g[        XS-  5      nU[        L a  [        $ X"-  nU[        R                  :  a  [        $ US-  S:X  a  X0-  nU[        R                  :  a  [        $ U$ )Nr   zExponent must be non-negative.r   r8   )r	  r  r   sysmaxsize)r   exponenthalf_expresults       r=   r
  r
    s~    !|9::1}!m,H6
  F!|qCKKMMr?   c                   8    \ rS rSr% SrSr\\S'   \S 5       r	Sr
g)r3   i  T2   r   c                    [        U[        R                  5      (       aS  [        U[        R                  5      (       a4  [        X5      nU[        * [        4;   a  U$ [        R                  " U5      $ [        U[        R                  5      (       a  [        R
                  " X5      $ U[        [        R                  4;   a9  UR                  (       a  [        $ UR                  (       a  [        R                  $ g g rE   )
rF   rG   rc   r  r   Powr   r   r   zoo)r   r   r  rQ   s       r=   r   PowByNatural.eval	  s    dEMM**z#u}}/M/M#AfWf%%==##c5==)) 99T''6588$$""!!yy  " %r?   rZ   N)r   r   r   r   r   r   rb   r   r   r   r   rZ   r?   r=   r3   r3     s#    JJ! !r?   r3   c                   8    \ rS rSr% SrSr\\S'   \S 5       r	Sr
g)r2   i  T<   r   c                     [        U[        R                  5      (       aK  [        U[        R                  5      (       a+  [        R                  " [	        U5      [	        U5      -  5      $ g g rE   )rF   rG   r   rH   rP   )r   r   r  s      r=   r   FloatPow.eval$  sJ     dELL))jell.K.K;;uT{eCj899 /L)r?   rZ   Nr   r   r   r   r  r   rb   r   r   r   r   rZ   r?   r=   r2   r2     s#    GJ: :r?   r2   c                   8    \ rS rSr% SrSr\\S'   \S 5       r	Sr
g)r)   i5  Tr   r   c                    UR                   (       a  [        S5      e[        U[        R                  5      (       aK  [        U[        R                  5      (       a+  [        R
                  " [        U5      [        U5      -  5      $ g g Nr   )r   r   rF   rG   r   rH   rP   r  s      r=   r   FloatTrueDiv.eval:  s]    
 ??#$677dELL))j%,,.O.O;;uT{U7^;<< /P)r?   rZ   Nr  rZ   r?   r=   r)   r)   5  s#    GJ= =r?   r)   c                   8    \ rS rSr% SrSr\\S'   \S 5       r	Sr
g)r(   iN  Tr   r   c                    UR                   (       a  [        S5      e[        U[        R                  5      (       a  [        U[        R                  5      (       a  U[
        [
        * [        R                  [        R                  * 4;   d0  U[
        [
        * [        R                  [        R                  * 4;   a+  [        R                  " [        U5      [        U5      -  5      $ [        U[        R                  5      (       aK  [        U[        R                  5      (       a+  [        R                  " [        U5      [        U5      -  5      $ g g r!  )r   r   rF   rG   r   r   r   rH   rP   rc   rb   r  s      r=   r   IntTrueDiv.evalS  s    ??#$677 tU\\**7ELL11&%((UXXI>>vw588)DD
 ;;uT{U7^;<<dEMM**z'5==/Q/Q;;s4y3w<788 0R*r?   rZ   Nr  rZ   r?   r=   r(   r(   N  s#    GJ9 9r?   r(   c                   (    \ rS rSrSr\S 5       rSrg)r,   im  Tc           	         [        U5      S-  S:X  d   e[        U5      S-  nUSU nXS  nSSKJn  [        S U 5       5      (       a=  U" U Vs/ s H  n[	        U5      PM     snU Vs/ s H  n[	        U5      PM     sn5      $ US:X  a<  US   R
                  (       a
  US   S:X  a  gUS   R
                  (       a
  US   S:  a  g[        S U 5       5      (       a  US:w  d   e[        [        [        X45      [        R                  " S5      S96 u  px[        S US S	  5       5      (       aE  US S	 S
-   nU" U Vs/ s H  n[	        U5      PM     snU Vs/ s H  n[	        U5      PM     sn5      $ g s  snf s  snf s  snf s  snf )Nr8   r   )!eval_is_non_overlapping_and_densec              3   V   #    U  H  n[        U[        R                  5      v   M!     g 7frE   rF   rG   rc   rI   s     r=   rL   9IsNonOverlappingAndDenseIndicator.eval.<locals>.<genexpr>|  s     :Tz!U]]++TrN   r   c              3   V   #    U  H  n[        U[        R                  5      v   M!     g 7frE   r*  rI   s     r=   rL   r+    s     =Wz!U]]++WrN   )keyc              3   V   #    U  H  n[        U[        R                  5      v   M!     g 7frE   r*  rI   s     r=   rL   r+    s     FA:a//rN   r   )*   )
r:   %torch.fx.experimental.symbolic_shapesr(  rx   rb   r   zipsortedoperator
itemgetter)	r   rB   dimsizesstridesr(  rK   s_sizes	s_stridess	            r=   r   &IsNonOverlappingAndDenseIndicator.evalp  s   4y1}!!!$i1nQst*	
 :T:::4!&'AQ'')B'Q#a&')B  !8qz##
aQx!!eAhl =W===!8O8 "%E+1D1DQ1GH"G F"FFF!#2,. 9%,-WSVW-	/J	1A	/J  G ()B@ ./Js   E6*E;
>F F
rZ   Nr   rZ   r?   r=   r,   r,   m  s    J0 0r?   r,   c                   (    \ rS rSrSr\S 5       rSrg)r-   i  Tc                     [        U[        R                  5      (       a3  [        R                  " [        R
                  " [        U5      5      5      $ g rE   )rF   rG   r   rH   re   truncrP   r   s     r=   r   TruncToFloat.eval  s8     fell++ ;;tzz%-899	 ,r?   rZ   Nr   r   r   r   r  r   r   r   rZ   r?   r=   r-   r-     s    G: :r?   r-   c                   (    \ rS rSrSr\S 5       rSrg)r.   i  Tc                 .   U[         R                  [        4;   a  [        $ U[         R                  * [        * 4;   a  [        * $ [        U[         R                  5      (       a3  [         R
                  " [        R                  " [        U5      5      5      $ g rE   )	rG   r   r   rF   r   rc   re   r=  rP   r   s     r=   r   TruncToInt.eval  sh     ehh''Muxxi&))7Nfell++==E&M!:;; ,r?   rZ   Nr   rZ   r?   r=   r.   r.     r   r?   r.   c                   (    \ rS rSrSr\S 5       rSrg)r/   i  Tc                     U[         R                  L a  [        $ U[         R                  * L a  [        * $ [        U[         R                  5      (       a)  [         R
                  " [        [        U5      S5      5      $ g r   )rG   r   r   rF   r   rc   roundrP   r   s     r=   r   RoundToInt.eval  sZ     UXXMehhY7Nfell++==uV}a!899 ,r?   rZ   Nr   rZ   r?   r=   r/   r/     s    J: :r?   r/   c                   (    \ rS rSrSr\S 5       rSrg)r0   i  Tc                     [        U[        R                  5      (       aR  [        U[        R                  5      (       a2  [        R                  " [        [        U5      [        U5      5      5      $ g g rE   )rF   rG   r   rc   rH   rE  rP   rb   )r   r   ndigitss      r=   r   RoundDecimal.eval  sL     fell++
7EMM0R0R;;uU6]CLABB 1S+r?   rZ   Nr?  rZ   r?   r=   r0   r0     s    GC Cr?   r0   c                   (    \ rS rSrSr\S 5       rSrg)r1   i  Tc                 6   U[         R                  [         R                  * 4;   a  U$ [        U[         R                  5      (       a  [         R                  " [        U5      5      $ U[        L a  [         R                  $ U[        * L a  [         R                  * $ g rE   )rG   r   rF   rc   rH   rb   r   r   s     r=   r   ToFloat.eval  sn    ehh	**Mfemm,,;;s6{++V88OfWHH9 r?   rZ   Nr?  rZ   r?   r=   r1   r1     s    G	 	r?   r1   c                   .    \ rS rSrSrSrS rS rS rSr	g)	r4   i  z,
Prevents expansion and other optimizations

   c                 (    SU R                   S    S3$ )Nz	Identity(r   r   r   r   s    r=   __repr__Identity.__repr__  s    499Q<.**r?   c                 4    U R                   S   R                  $ r   )rB   r  r   s    r=   r  Identity._eval_is_real  s    yy|###r?   c                 4    U R                   S   R                  $ r   r   r   s    r=   r   Identity._eval_is_integer  s    yy|&&&r?   rZ   N)
r   r   r   r   r   r   rQ  r  r   r   rZ   r?   r=   r4   r4     s     J+$'r?   r4   c                 b   ^   " U 4S jS[         R                  5      nST -   nX!l        X!l        U$ )Nc                   6   > \ rS rSrSr Y r\U 4S j5       rSrg)+make_opaque_unary_fn.<locals>.OpaqueUnaryFni  a  
Unlike the builtin sympy functions on real numbers like sympy.sqrt,
these equivalents do not do any nontrivial reasoning besides
constant propagation.  This helps avoid performing transformations
that are valid for real numbers but are invalid for floating point;
in particular, while we are willing to make optimizations that change
numerics for Tensor compute, we are NOT willing to make optimziations
that change numerics for size compute.
c                   > [        U[        R                  [        R                  45      (       a4   [        R                  " [	        [
        T5      " [        U5      5      5      $ U[        R                  [        R                  * [        R                  [        R                  * [        [        * 4;   ag  U[        L a  [        R                  nU[        * L a  [        R                  * nTS:X  a  [        R                  " US5      $ [	        [        T5      " U5      $ g ! [         a    [	        [        T5      " U5      s $ f = f)Nlog2r8   )rF   rG   rc   rH   r(  re   rP   OverflowErrorr   r  r   log)r   rK   names     r=   r   0make_opaque_unary_fn.<locals>.OpaqueUnaryFn.eval  s    !emmU[[9::3 ;;wtT':58'DEE
 uxx%((EII		z6F7SS;A<	A6> 99Q?*ud+A.. % 3"5$/223s   2D  D?>D?rZ   N)	r   r   r   r   r   _torch_handler_namer   r   r   )r^  s   r=   OpaqueUnaryFnrY    s"    	 #		 
	r?   ra  OpaqueUnaryFn_)rG   Functionr   r   )r^  ra  nms   `  r=   make_opaque_unary_fnre    s2    # #J 
D	 B!#r?   sqrtcoscoshsinsinhtantanhasinacosatanr  r]  asinhr[  c                    ^ ^^ T S:X  a
  [         S   mOT S:X  a
  [         S   mO[        ST  35      e " U UU4S jS[        R                  5      nST -   Ul        U$ )	Nbitwise_and
BitwiseAnd
bitwise_or	BitwiseOrzunrecognized c                   D   > \ rS rSr%  Y r Yr\\S'   \U4S j5       r	Sr
g))make_opaque_bitwise_fn.<locals>.BitwiseFniQ  r   c                 D  > UR                   (       a'  UR                   (       a  [        [        T5      " X5      $ UR                   (       a  [        R                  " U(       a  SOS5      nUR                   (       a  [        R                  " U(       a  SOS5      n[        U[        R                  [        45      (       ab  [        U[        R                  [        45      (       a=  [        R                  " [        [        T5      " [        U5      [        U5      5      5      $ g )Nr   r   )r   r(  r3  rG   rc   rF   rb   )r   rK   breal_op_names      r=   r   .make_opaque_bitwise_fn.<locals>.BitwiseFn.evalU  s    ||x6q<<||MMq!a0||MMq!a0!emmS122zEMM3'8 8 }}WX|%DSVSQRV%TUUr?   rZ   N)r   r   r   r   r`  r   rb   r   r   r   r   )r^  precrz  s   r=   	BitwiseFnrw  Q  s%    "
C		 
	r?   r}  
BitwiseFn_)r   rj  rG   rc  r   )r^  rz  r}  r|  s   `` @r=   make_opaque_bitwise_fnr  I  sc    },'		+&}TF344 ENN $ &,Ir?   rr  and_rt  or_)`rT   re   r3  r  typingr   r   r   r   r   r   r	   r
   r   rG   r   
sympy.corer   sympy.core.exprr   sympy.core.functionr   sympy.core.logicr   r   r   sympy.core.numbersr   sympy.core.operationsr   r   sympy.core.sortingr   sympy.core.traversalr   sympy.printing.precedencer   sympy.utilities.iterablesr   numbersr   r   __all__r   r>   rH   rV   r[   rv   r{   rc  r   r    r!   r"   r#   r$   r%   r&   r'   r*   r+   r  r;  r:  r  r
  r3   r2   r)   r(   r,   r-   r.   r/   r0   r1   r4   re  OpaqueUnaryFn_sqrtOpaqueUnaryFn_cosOpaqueUnaryFn_coshOpaqueUnaryFn_sinOpaqueUnaryFn_sinhOpaqueUnaryFn_tanOpaqueUnaryFn_tanhOpaqueUnaryFn_asinOpaqueUnaryFn_acosOpaqueUnaryFn_atanOpaqueUnaryFn_expOpaqueUnaryFn_logOpaqueUnaryFn_asinhOpaqueUnaryFn_log2r  BitwiseFn_bitwise_andBitwiseFn_bitwise_orrZ   r?   r=   <module>r     s[      

 
 
      + 7 7 + 9 & % 0 *  T'B4uzz d 
8CG$ 
#uR_7M2M)N 
 8D> htn )5;; )5;; )5;; )|mu~~ m`D6enn D6NENN B8: 8:x1%.. 1hx ; ;< <;enn ; U^^  U^^  p?y p?f;*k ;$:*k :$'4!5>> !6:u~~ :,=5>> =29 9>4 4p
:5>> 
:< <: :<C5>> Cenn  'u~~ '"*\ *&1 (/ )&1 (/ )&1 (/ )&1 )&1 )&1 )&1 (/ (/ *73 )&1 < /}fE -lEB r?   