+
    i|)                         ^ RI HtHt ^ RIHt ^ RIHt ^ RIHt ^ RI	H
t
 ^ RIHt ^ RIHt ^ RIHt ^ R	It]
! R
4      t ! R R]]4      tRR ltR	# )    )AbstractPythonCodePrinterArrayPrinter)
MatrixExpr)Mul)
PRECEDENCE)import_module)Sqrt)S)IntegerNtorchc                   8  a a ] tR t^t oRt/ ]P                  Rb]P                  Rb]P                  Rb]P                  Rb]P                  Rb]P                  Rb]Rb]P                  R	b]P                  R
b]P                  Rb]P                   Rb]P"                  Rb]P$                  Rb]P&                  Rb]P(                  Rb]P*                  Rb]P,                  Rb/ ]P.                  Rb]P0                  Rb]P2                  Rb]P4                  Rb]P6                  Rb]P8                  Rb]P:                  Rb]P<                  Rb]P>                  Rb]P@                  Rb]PB                  Rb]PD                  Rb]PF                  Rb]PH                  R b]PJ                  R!b]PL                  R"b]PN                  R#bC]PP                  R$]PR                  R%]PT                  R&]PV                  R']PX                  R(]PZ                  R)]P\                  R*/Ct/]0! ]1Pd                  R+R,R-R.7      t2RKV 3R/ llt3V 3R0 lt4]4t5]4t6]4t7]4t8]4t9]4t:]4t;]4t<]4t=]4t>R1 t?R2 t@R3 tAR4 tBR5 tCR6 tDR7 tER8 tFR9 tGR: tHR; tIR< tJR= tKR> tLR? tMR@ tNRA tORB tPRC tQRDtRREtSRFtTRGtURHtVRItWRJtXVtYV ;tZ# )LTorchPrinter
_torchcodez	torch.absz
torch.signz
torch.ceilztorch.floorz	torch.logz	torch.exp
torch.sqrtz	torch.cosz
torch.acosz	torch.sinz
torch.asinz	torch.tanz
torch.atanztorch.atan2z
torch.coshztorch.acoshz
torch.sinhztorch.asinhz
torch.tanhztorch.atanh	torch.powz
torch.realz
torch.imagztorch.anglez	torch.erfztorch.lgammaztorch.eqztorch.neztorch.gtztorch.ltztorch.leztorch.geztorch.logical_andztorch.logical_orztorch.logical_notz	torch.maxz	torch.minz	torch.addz	torch.mulztorch.tracez	torch.detNFtorch.float64)torch_versionrequires_graddtypec                   < \         SV `  V4       V P                  R ,          pV P                  R,          V n        V P                  R,          V n        Vf   \
        '       d   \
        P                  pW n        R# )r   r   r   N)super__init__	_settingsr   r   r   __version__r   )selfsettingsversion	__class__s   && v/Users/tonyclaw/.openclaw/workspace/skills/math-calculator/venv/lib/python3.14/site-packages/sympy/printing/pytorch.pyr   TorchPrinter.__init__S   sY    "..1!^^O<^^G,
?uu''G$    c                R  < V P                   P                  \        V4      R 4      pVf   \        SV `  V4      # VP
                   Uu. uF  q0P                  V4      NK  	  pp\        V4      ^8X  d!   V P                  V4      : RV^ ,          : R2# V P                  W$4      # u upi )N())
mappinggettyper   _print_Basicargs_printlen_module_format_expand_fold_binary_op)r   expropargchildrenr   s   &&   r   _print_FunctionTorchPrinter._print_Function]   s    \\d4j$/:7'--04		:	KK$	:x=A##B' 
 ..r<< ;s   B$c                    R P                  V P                  R4      V P                  VP                  ^ ,          4      4      # ){}({})ztorch.linalg.inv)formatr,   r*   r)   r   r.   s   &&r   _print_InverseTorchPrinter._print_Inversew   s5    t223EF#{{499Q<8: 	:r!   c                   VP                   P                  '       di   VP                   P                  ^ ,          VP                   P                  ^,          8X  d,   RP                  RV P	                  VP                   4      4      # RP                  V P	                  VP                   4      RP                  \        \        VP                   P                  4      4       Uu. uF  p\        V4      NK  	  up4      RRR1,          4      # u upi )r   z
{}({}).t()ztorch.transposez{}.permute({}), N)	r0   	is_Matrixshaper6   r*   joinranger+   str)r   r.   is   && r   _print_TransposeTorchPrinter._print_Transpose{   s    88$((.."3txx~~a7H"H&&'8$++dhh:OPP $**DHH%		5TXX^^1D+EF+Ea3q6+EFG"M Fs   Dc                    V P                  VP                  4      : R RP                  R VP                  P                   4       4      : R2# )z	.permute(r;   c              3   8   "   T F  p\        V4      x  K  	  R # 5iN)rA   ).0rB   s   & r   	<genexpr>2TorchPrinter._print_PermuteDims.<locals>.<genexpr>   s     B&Ac!ff&A   r$   )r*   r.   r?   permutation
array_formr7   s   &&r   _print_PermuteDimsTorchPrinter._print_PermuteDims   s:    KK		"IIBd&6&6&A&ABB
 	
r!   c                0   VP                   pVP                  p\        V4      ^8  gK   \        V4      ^8X  d   \        V^ ,          \        4      '       g   VP                  V^ ,          4      ^8  d   V P                  V4      p/ pV FU  p\        V\        4      '       d"   Vw  rxVP                  V^ 4      V,           WW&   K:  VP                  V^ 4      ^,           WV&   KW  	  VP                  4        F7  w  rh\        V4       F#  p	RP                  W@P                  V4      4      pK%  	  K9  	  V# \        V4      ^8X  d   V^ ,          p
\        V
\        4      '       d{   \        V
4      ^8X  dk   V
w  rx\        V\        4      '       g   \        R4      hV P                  V4      p\        V4       F#  p	RP                  W@P                  V4      4      pK%  	  V# RP                  V P                  V4      V P                  V
4      4      # V P                  V4      # )   z1torch.autograd.grad({}, {}, create_graph=True)[0]z!Only integer orders are supportedztorch.autograd.grad({}, {})[0])	variablesr.   r+   
isinstancetuplecountr*   r&   itemsr@   r6   r   NotImplementedError)r   r.   rR   expr_argresult
var_groupsvarbase_varorder_variables   &&         r   _print_DerivativeTorchPrinter._print_Derivative   s   NN	99 y>A	Na
9Q<(G(GIOO\efg\hLilmLm[[*FJ !c5))&)OH+5>>(A+F+NJ(&0nnS!&<q&@JO ! )..0
uAPWWX^`k`klo`pqF & 1 M y>Q |H(E**s8}/A"*!%119LMp9q3qX.uAPWWX^`k`klt`uvF &3::4;;x;PRVR]R]^fRghh{{8$$r!   c                   ^ RI Hp VP                  ^ ,          P                  w  r4\        VP                  4      ^8X  dB   RP	                  V P                  R4      V P                  V4      V P                  V4      ^ 4      # RP	                  V P                  R4      V P                  V4      V P                  V4      V P                  V! VP                  R,          !  4      4      # )r   )	Piecewisez{}({}, {}, {})ztorch.where:rQ   NN)sympyrc   r)   r+   r6   r,   r*   )r   r.   rc   econds   &&   r   _print_PiecewiseTorchPrinter._print_Piecewise   s    #))A,##tyy>Q#**##M2D!A	   &&.KKKKNKK	499R=12	4 	4r!   c                <   VP                   w  r#VP                  \        P                  8X  d1   R P	                  V P                  R4      V P                  V4      4      # RP	                  V P                  R4      V P                  V4      V P                  V4      4      # )r5   r   
{}({}, {})r   )r)   expr
   Halfr6   r,   r*   )r   r.   baserk   s   &&  r   
_print_PowTorchPrinter._print_Pow   s     II	88qvv??##L14;;t3DF F"",KKt{{3/1 	1r!   c                   VP                    Uu. uF  p\        V\        4      '       g   K  VNK  	  ppVP                    Uu. uF  q"V9  g   K  VNK  	  ppV'       dI   V P                  \        P
                  ! V4      \        R ,          4      : RV P                  RV4      : 2# V P                  RV4      # u upi u upi )r   *ztorch.matmul)r)   rS   r   parenthesizer   fromiterr   r-   )r   r.   r0   mat_argsr)   s   &&   r   _print_MatMulTorchPrinter._print_MatMul   s    #'99L9C
3
0KCC9L#yy@yx,?y@!!#,,t"4j6GH++NHE 
 ..~xHH M@s   B9B9B>B>c                ^    V P                  R VP                  .VP                  ,          4      # )ztorch.mm)r-   rm   rk   r7   s   &&r   _print_MatPowTorchPrinter._print_MatPow   s$    **:		{4887KLLr!   c                   R RP                  VP                  4        UUu. uF@  pR RP                  V Uu. uF  q0P                  V4      NK  	  up4      ,           R,           NKB  	  upp4      ,           R,           p\        V4      .pVP	                  RV P
                   24       V P                  '       d   VP	                  R4       RP                  V P                  R4      RP                  V4      4      # u upi u uppi )[r;   ]zdtype=zrequires_grad=Truer5   ztorch.tensor)	r?   tolistr*   rA   appendr   r   r6   r,   )r   r.   rB   jdataparamss   &&    r   _print_MatrixBaseTorchPrinter._print_MatrixBase   s    TYY\`\g\g\ij\iWXdii0KAQ0K&L Ls R R\ijkknqqd)tzzl+,MM.//IIf
 	
 1Ljs   C=C8C=8C=c                N    R V P                  VP                  ^ ,          4       R2# )ztorch.isnan(r$   r*   r)   r7   s   &&r   _print_isnanTorchPrinter._print_isnan   #    dkk$))A,78::r!   c                N    R V P                  VP                  ^ ,          4       R2# )ztorch.isinf(r$   r   r7   s   &&r   _print_isinfTorchPrinter._print_isinf   r   r!   c                   \         ;QJ d&    R  VP                   4       F  '       d   K   RM	  RM! R  VP                   4       4      '       dB   RP                  V P                  R4      V P	                  VP                  ^ ,          4      4      # RP                  V P                  R4      V P	                  VP                  ^ ,          4      V P	                  VP                  ^,          4      4      # )c              3   8   "   T F  qP                   x  K  	  R # 5irG   )
is_Integer)rH   dims   & r   rI   /TorchPrinter._print_Identity.<locals>.<genexpr>   s     4#~~rK   FTr5   z	torch.eyerj   )allr>   r6   r,   r*   r7   s   &&r   _print_IdentityTorchPrinter._print_Identity   s    3443334444??##K0DJJqM*   &&##K0DJJqM*DJJqM* r!   c                v    R P                  V P                  R4      V P                  VP                  4      4      # )r5   ztorch.zerosr6   r,   r*   r>   r7   s   &&r   _print_ZeroMatrixTorchPrinter._print_ZeroMatrix   s1    .KK

#
 	
r!   c                v    R P                  V P                  R4      V P                  VP                  4      4      # )r5   z
torch.onesr   r7   s   &&r   _print_OneMatrixTorchPrinter._print_OneMatrix  s1    -KK

#
 	
r!   c                p    V P                  R 4       RV P                  VP                  ^ ,          4       R2# )z
torch.conjr#   r$   r,   r*   r)   r7   s   &&r   _print_conjugateTorchPrinter._print_conjugate  s4    %%l34Adkk$))A,6O5PPQRRr!   c                    R # )1j r7   s   &&r   _print_ImaginaryUnit!TorchPrinter._print_ImaginaryUnit  s    r!   c                   V P                  VP                  ^ ,          4      R.p\        VP                  4      ^8  d&   V P                  VP                  ^,          4      V^&   V P                  R4       RV^ ,           RV^,           R2# )r   z0.5ztorch.heavisider#   r;   r$   )r*   r)   r+   r,   )r   r.   r)   s   && r   _print_HeavisideTorchPrinter._print_Heaviside  su    DIIaL)51tyy>Akk$))A,/DG%%&78947)2d1gYaPPr!   c                p    V P                  R 4       RV P                  VP                  ^ ,          4       R2# )ztorch.special.gammar#   r$   r   r7   s   &&r   _print_gammaTorchPrinter._print_gamma  s6    %%&;<=Qt{{499UV<?X>YYZ[[r!   c                    VP                   ^ ,          \        P                  8X  d8   V P                  R4       RV P	                  VP                   ^,          4       R2# \        R4      h)r   ztorch.special.digammar#   r$   z3PyTorch only supports digamma (0th order polygamma))r)   r
   Zeror,   r*   rW   r7   s   &&r   _print_polygammaTorchPrinter._print_polygamma  sZ    99Q<166!))*ABC1T[[QUQZQZ[\Q]E^D__`aa%&[\\r!   r   einsumaddtoneszeros)r   r   r   rG   )[__name__
__module____qualname____firstlineno__printmethodrd   Abssignceilingfloorlogrk   r	   cosacossinasintanatanatan2coshacoshsinhasinhtanhatanhPowreimr0   erfloggammaEqNeStrictGreaterThanStrictLessThanLessThanGreaterThanAndOrNotMaxMinMatAddHadamardProductTraceDeterminantr%   dictr   _default_settingsr   r2   _print_Expr_print_Application_print_MatrixExpr_print_Relational
_print_Not
_print_And	_print_Or_print_HadamardProduct_print_Trace_print_Determinantr8   rC   rN   r`   rg   rn   ru   rx   r   r   r   r   r   r   r   r   r   r   r   _module_einsum_add
_transpose_ones_zeros__static_attributes____classdictcell____classcell__)r   __classdict__s   @@r   r   r      s    K6		;6

L6
 	|6 	]6 			;6 			;6 	l6 			;6 	

L6 			;6 	

L6 			;6 	

L6  	]!6$ 	

L%6& 	]'6( 	

L)6* 	]+6, 	

L-6. 	]/60 			;164 	,566 	,768 			=96> 			;?6@ 	A6D 	*E6F 	*G6H 	I6J 	jK6L 	
M6N 	:O6R 			&S6T 	$U6V 			&		;		; 	k{] 	;k6Gp !33	%= "K('' J JI,"L(:

%%N4 	1IM

;;

SQ\] GGDJEFFr!   r   c                 H    \        R VRV/R7      pVP                  ! V 3/ VB # )r   r   )r   )r   doprint)r.   r   r   r   printers   &&&, r   
torch_coder   '  s)    _mWe$TUG??4,8,,r!   )Fr   )sympy.printing.pycoder   r   sympy.matrices.expressionsr   sympy.core.mulr   sympy.printing.precedencer   sympy.externalr   sympy.codegen.cfunctionsr	   rd   r
   r   r   r   r   r   r!   r   <module>r      sA    I 1  0 ( )   gU<!: Un-r!   