
    [Th                       % S r SSKrSSKrSSKrSSKrSSKrSSKrSSKr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  SSKJr  \(       a  SSKJ r   S\RB                  4S jr"SS	K#J$r%J&r&J'r'  SS
K(J)r)J*r*J+r+J,r,  \"" 5       (       a!  Sr-\(       d  SSKr\R\                  r/\/\l0        OSSKJ0r/  SSK1J-r-  / SQr2\2\3" \25      :X  d   e\	R                  S:X  a  SS jr4\4" 5         C4S\5S\5S\5S\6\5   4S jr7S\5S\5SS4S jr8SS jr9\,(       d  \Rt                  " S5      (       at  \"" 5       (       d  \Rv                  " 5       S:w  aS  \	Rx                  " 5       r=\	R|                  " \R~                  \R                  -  5        SSKA7  \	R|                  " \=5        C=O\+(       a  \9" 5         SSKA7   " S S5      rB " S S5      rC " S S5      rDS  rES! rFS" rGS# rHS\I\I\JS$4   \I\JS$4   4   4S% jrKS& rLS' rMS( rNS)u  rOrPrQS* H(  rPS+\P 3rQ\N" \P5      rO\Q=\OlR        \OlS        \O\T" 5       \Q'   M*     COCPCQCN\T" 5       S,   rU\2R                  S-5        S. rWS/ rX SS0KAJYrY  SS2K`J[r[  S3u  rPra\b" \[5       H  rP\PS   S4:w  ay  \PR                  S55      (       dc  \2R                  \P5        \d" \[\P5      ra\e" \a5      (       d  \R                  " \a5      (       a#  \aR                  \S:w  a  \PS6;  a	  \S\alg        M  M  M  M  \PS7:X  d  M  \h" \	R                  \S   \P5        M     CPCa\(       d  SS8 jrj\j" \[5        CjS9\S\54S: jrkS9\S\/S;   4S< jrlS9\S\/\S=      4S> jrm\R                  " 5       qoSS@ jrpSA\\S?\5\R                  4      SS4SB jrrSC\\JS;   \54   SS4SD jrsSSE jrtSFSG.SH\RB                  SI\RB                  SS4SJ jjruS\RB                  4SK jrvS\RB                  4SL jrwSM\\R                  \54   SS4SN jrxS\R                  4SO jryS\54SP jrzSQ\5SS4SR jr{SS\RB                  SS4ST jr|S\RB                  4SU jr}SV\\RB                  \D4   SW\/ \54   4SX jr~SSY jrSSSZ.S[ jjrSS\ jrSS] jrSS^ jrSS_ jrSS` jrSSa jrSSbKJrJrJrJr  SrS\Sc'   \2GR                  / SdQ5        SSeKJr  SSfK`Jr  SSgKJrJrJrJrJr   " Sh Si\5      r " Sj Sk\5      r " Sl Sm\5      r " Sn So\5      r " Sp Sq\5      r " Sr Ss\5      r " St Su\5      r " Sv Sw\5      r " Sx Sy\5      r " Sz S{\5      r " S| S}\5      r " S~ S\5      r " S S\5      r " S S\5      r " S S\5      r " S S\5      r " S S\5      r\\\\\\\\\\\\\\\\\\\1r\\J\\\4         \S'   \" 5       r\\JS;      \S'   SSK`JrJrJr  SSKJr  SSKJrJr  SSKJrJrJrJrJr  SSKJrJr  S r\[R                  " \" 5       5        C\(       a  SSK7  \rCSrS3u  rPra\b" \[GR                  5       H  rP\PGR                  S5      (       d  \P\;   a  M"  \d" \[GR                  \P5      ra\S\alg        \PS:X  a  \a\T" 5       \P'   S4\P-   rP\a\T" 5       \P'   \PGR                  S45      (       a  Mu  \2R                  \P5        M     CPCaSSK`r`\2GR                  S \b" \`5       5       5        SSKJr  SSK`JrJr  SSK7  CCS rSSKJrJrJrJr  SSK`JrJrJrJrJrJrJrJrJrJrJrJrJrJrJrJrJrJrJrJrJrJrJrJrJrJrJrJrJr  SSKJr  SSK`Jr  SSKr`SSKr`SSKr`SSKr`\[GR                  " \6" \5      5        SSK`JrJrJrJr  CCCCS\RB                  4S jrSSK`JrJr  SSKJr  SSKJr  \	R                  GR                  \S S3\5        \	R                  GR                  \S S3\5        SSK`Jr  SSK`Jr  G\ GrSSGKGJGr  G\" \`GR                  5        GCSSGKGJGr  \GR                  GR                  Gr\GR                  GR                  Gr	SSK`GJ
Gr
  SSGKGJGrGJGrGJGrGJGrGJGr  SSGKGJGrGJGr   " S S5      Gr " S S5      Gr\" S5      Gr\" S5      Gr\SFSSSSSFS.S\G\G\4   S\RB                  S\\RB                     S\\5\4   SH\\5S4   S\G\\5\\5\R                  \RB                  4   4      S\RB                  S\G\G\4   4S jj5       Gr\ SSFSSSSSFS.SSS\RB                  S\\RB                     S\\5\4   SH\\5S4   S\G\\5\\5\R                  \RB                  4   4      S\RB                  S\\G\G\4   /\G\G\4   4   4S jjj5       Gr SSFSSSSSFS.S\\   S\RB                  S\\RB                     S\\5\4   SH\\5S4   S\G\\5\\5\R                  \RB                  4   4      S\RB                  S\\\G\G\4   /\G\G\4   4   \G\G\4   4   4S jjjGrS GrSSK`GJGrGJGrGJGrGJGr  SSGK GJ!Gr!GJ"Gr"  SSGK#GJ$Gr$  \(       d  SSK`GJ%Gr%  S\GRL                  ;   a  SSGK'Js  GJ(Gr)  G\)GRT                  " 5         SSGK+r`SSK`GJ,Gr,  \`GR                  GR                  GR[                  5         \"" 5       (       d  SSK`GJ.Gr.   " S S5      Gr/\`GR                  GR                  GR`                  \`GR                  GR                  GR`                  \`GR                  GRb                  GRd                  \`GR                  GRf                  GRd                  S.Gr4\(       a  SSK`GJ5Gr5GJ6Gr6GJ7Gr7GJ8Gr8  O	1 SkGr9S Gr:SSA\\\`GRv                  \54      4S jjGr<  SS\\R                     S\\R                     4S jjGr=SSK`GJ>Gr>  G\>GR~                  " 5         S Gr@S\RB                  4S jGrAS GrBG\A" 5       (       a	  G\@" 5         gg! \Z a<    SSKAJ[r\  \\R                  c'  \Z" \
R                  " S15      R                  5       5      See f = f)a  
The torch package contains data structures for multi-dimensional
tensors and defines mathematical operations over these tensors.
Additionally, it provides many utilities for efficient serialization of
Tensors and arbitrary types, and other useful utilities.

It has a CUDA counterpart, that enables you to run your tensor computations
on an NVIDIA GPU with compute capability >= 3.0.
    N)AnyCallable
get_originOptionaloverloadTYPE_CHECKINGTypeVarUnion)	ParamSpec   )IntLikeTypereturnc                  N    [         R                  R                  SS 5      [        L $ )Nztorch._meta_registrations)sysmodulesgetobject     F/var/www/auris/envauris/lib/python3.13/site-packages/torch/__init__.py_running_with_deployr   ,   s    ;;??6=GGr   )_functionalize_sync_import_dotted_nameclassproperty)get_file_path#prepare_multiprocessing_environmentUSE_GLOBAL_DEPSUSE_RTLD_GLOBAL_WITH_LIBTORCHztorch-deploy-1.8)TypeIs)__version__)GBoolStorage
BoolTensorByteStorage
ByteTensorCharStorage
CharTensorDoubleStorageDoubleTensorFloatStorageFloatTensor
GradScaler
IntStorage	IntTensorLongStorage
LongTensorShortStorageShortTensorSymBoolSymFloatSymIntTensorTypedStorageUntypedStorage$are_deterministic_algorithms_enabledautocastchunkcompilecondenable_gradexportget_default_deviceget_deterministic_debug_modeget_device_moduleget_float32_matmul_precisionget_rng_stateinference_modeinitial_seed-is_deterministic_algorithms_warn_only_enabled
is_storage	is_tensoris_warn_always_enabledloadlobpcgmanual_seedmatmulno_gradrandrandnsaveseedset_default_deviceset_default_tensor_typeset_deterministic_debug_modeset_float32_matmul_precisionset_printoptionsset_rng_stateset_warn_alwayssplitstack	sym_floatsym_fresh_sizesym_intsym_itesym_maxsym_minsym_notsym_sumtypenameunravel_indexuse_deterministic_algorithmsvmapwin32c            
      .
   SS K n SSKJn  [        R                  " SS5      n[        R
                  R                  [        R                  SS5      n[        R
                  R                  [        R
                  R                  [        5      S5      n[        R
                  R                  U R                  S5      SS5      n[        R                  [        R                  :w  a0  [        R
                  R                  [        R                  SS5      nOS	nXCXe4 Vs/ s H+  n[        R
                  R                  U5      (       d  M)  UPM-     nn[        R                  " S
 U 5       5      (       dV  [        R
                  R                  [        R                  " S[        R
                  R                  USS5      5      SS5      n	OS	n	U(       a  [        R                   " S U 5       5      (       aq  UR#                  SS5      n
SU
-   n[        R
                  R                  USSSU 35      n[        R
                  R                  [        R                  " X5      S5      nOS	nUR%                  S X4 5       5        [&        R(                  " SSS9n[+        US5      nUR-                  S5      n[&        R.                  UR0                  l        U(       a  [&        R.                  UR4                  l        U H  n[        R6                  " U5        M      [&        R8                  " S5        [&        R8                  " S5        [:        R<                  " 5       S:w  a  [&        R8                  " S5        [H        RH                  " [        R
                  R                  US!5      5      nS"nU GH  nS"nU(       ag  UR5                  US S#5      n[&        RJ                  " 5       nUc7  US$:w  a1  [&        RL                  " U5      nU=RN                  S%U S&3-  sl'        UeUb  SnU(       a  M}  U(       d9  S'R                  U[        RP                  S(   /-   5      [        RP                  S('   SnUR1                  U5      nUb  M  [&        RL                  " [&        RJ                  " 5       5      nU=RN                  S%U S&3-  sl'        Ue   UR-                  U5        g s  snf ! [>         a1    [A        [B        RD                  " S 5      RG                  5       5         GNf = f))Nr   cudaProgramFileszC:\Program FilesLibrarybinlibuserbase c              3      #    U  HB  n[         R                  R                  [         R                  R                  US 5      5      v   MD     g7f)znvToolsExt64_1.dllN)ospathexistsjoin.0ps     r   	<genexpr>&_load_dll_libraries.<locals>.<genexpr>   s3      
KTaBGGNN277<<+?@AA9s   A
ANVTOOLSEXT_PATHzNVIDIA Corporation
NvToolsExtx64c              3      #    U  H>  n[         R                   " [        R                  R                  US 5      5      (       + v   M@     g7f)zcudart64*.dllNglobrs   rt   rv   rw   s     r   rz   r{      s1      )
EN		"'',,q/:;;;Ys   AA._CUDA_PATH_VzNVIDIA GPU Computing ToolkitCUDAvc              3   r   #    U  H-  n[         R                  R                  U5      (       d  M)  Uv   M/     g 7fN)rs   rt   ru   rw   s     r   rz   r{      s%      
7!277>>!;LAA7s   (7	7zkernel32.dllT)use_last_errorAddDllDirectoryr   zvcruntime140.dllzmsvcp140.dllARM64zvcruntime140_1.dllz
                    Microsoft Visual C++ Redistributable is not installed, this may lead to the DLL load failure.
                    It can be downloaded at https://aka.ms/vs/16/release/vc_redist.x64.exe
                    z*.dllFi   ~   z Error loading "z" or one of its dependencies.;PATH))	sysconfigtorch.versionrk   rs   getenvrt   rv   r   exec_prefixdirname__file__get_config_varbase_exec_prefixru   builtinsanyallreplaceextendctypesWinDLLhasattrSetErrorModec_void_pLoadLibraryWrestypeLoadLibraryExWadd_dll_directoryCDLLplatformmachineOSErrorprinttextwrapdedentstripr   get_last_errorWinErrorstrerrorenviron)r   cuda_versionpfiles_pathpy_dll_pathth_dll_pathusebase_pathbase_py_dll_pathry   	dll_pathsnvtoolsext_dll_pathcuda_version_1cuda_path_vardefault_path	cuda_pathkernel32with_load_library_flagsprev_error_modedll_pathdllspath_patcheddll	is_loadedres
last_errorerrs                            r   _load_dll_librariesr      s	   6ii0CDggll3??IuEggll277??8#<eDww||$$Z0)U
 ??c222!ww||C,@,@)US! "0@O
Oww~~a  O 	 
 || 
KT
 
 
 #%'',,		%GGLL.BLQ # #%HLL )
EN)
 
 
 *11#s;N)N:M77<<;VqEWL RYY}%KUSII 
+7
 	
 ==E")(4E"F"//7(.%".4ooH##+!H  * "	KK*+KK'!W,01 yyk7;<CI&--c4D#224
;:#4 //*5CLL*3%/LML I_ $I9#),)rzz&?Q>R2R)SBJJv&#'L++C0; //&*?*?*ABCLL*3%/LML I/ 2 	o.s
h  	
 %'	s   (SSAS 7TTrt   
lib_folderlib_namec           	          [         R                   " [        R                  R                  U SUSU5      5      n[         R                   " [        R                  R                  XSU5      5      nX4-   $ )Nnvidiaro   r   )rt   r   r   nvidia_lib_paths	lib_pathss        r   _get_cuda_dep_pathsr     sS    yy
T8ZA 		"'',,tIJI''r   c                     [         R                  " 5       S:X  d   S5       eSn[        R                   H  n[	        X0U5      nU(       d  M  US   n  O   U(       d  [        U S[        R                   35      e[        R                  " U5        g)z8Preloads cuda deps if they could not be found otherwise.LinuxzShould only be called on LinuxNr   z not found in the system path )r   systemr   rt   r   
ValueErrorr   r   )r   r   lib_pathrt   candidate_lib_pathss        r   _preload_cuda_depsr     s~     ??'I)II'H1$HM*1-H	 
 H:%CCHH:NOO
KKr   c                  Z   [        5       (       d  [        R                  " 5       S:X  a  g [        R                  " 5       S:X  a  SOSn SU  3n[        R                  R                  [        5      n[        R                  R                  [        R                  R                  U5      SU5      n [        R                  " U[        R                  S9   [        S5       nUR                  5       nS S S 5        S	W;  a  g [        S
S5        [        SS5        g ! , (       d  f       N.= f! [         a     g f = f! [          a  nSSKJn  SSSSSSSSSSSSSS.nUb*  UR'                  S5      n	[)        U	S   5      n
U
S:  a  SUS'   UR+                  5        Vs/ s H+  oR'                  S5      S   UR,                  S   ;   d  M)  UPM-     Os  snf nnU(       d  UeUR/                  5        H  u  p[        X5        M     [        R                  " U[        R                  S9   S nAg S nAff = f) NWindowsDarwinz.dylibz.solibtorch_global_depsro   )modez/proc/self/mapsz$nvidia/cuda_runtime/lib/libcudart.so
cuda_nvrtczlibnvrtc.so.*[0-9]	nvjitlinkzlibnvJitLink.so.*[0-9]r   rj   zlibcublas.so.*[0-9]zlibcudnn.so.*[0-9]zlibcudart.so.*[0-9]zlibcupti.so.*[0-9]zlibcufft.so.*[0-9]zlibcurand.so.*[0-9]zlibcusparse.so.*[0-9]zlibcusparseLt.so.*[0-9]zlibcusolver.so.*[0-9]zlibnccl.so.*[0-9]zlibnvToolsExt.so.*[0-9])cublascudnnr   cuda_runtime
cuda_cupticufftcurandr   cusparse
cusparseltcusolverncclnvtxr      zlibcufile.so.*[0-9]cufile)r   r   r   rs   rt   abspathr   rv   r   r   r   RTLD_GLOBALopenreadr   	Exceptionr   r   rk   rZ   intvaluesargsitems)lib_extr   hereglobal_deps_lib_pathf_mapsr   r   	cuda_libs	t_versiont_majorro   is_cuda_lib_errr   s                 r   _load_global_depsr   -  s   !2i!? #//+x7hUG%gY/H77??8$D77<<(=uhO8C(v/A/AB	'(A ) 6UB |-AB{,DE )(  		  #C 	7 ,).1.)+1/3/'-%
	" #$**3/I)A,'G"}&;	(# %++-
-C31Bchhqk1QC-
 
 I$-OO$5 Jz4 %6(v/A/ABG#Csh   .#D7 D' D.D' =D' 
D$ D' '
D41D7 3D44D7 7
H*AH%(G	G	AH%%H*TORCH_USE_RTLD_GLOBALr   )*c                   @   \ rS rSrSrS rS rS rS rS0S jr	S	 r
S
 rS rS rS rS rS\S\R$                  4S jrS\R$                  4S jrS\R$                  4S jrS\R$                  4S jrS\R$                  4S jrS1S jrS1S jrS1S jrS2S jrS1S jrS1S jrS1S jrS3S jrS3S jr S3S jr!S3S  jr"S! r#S" r$S# r%S$ r&S2S% jr'S2S& jr(S1S' jr)S1S( jr*S) r+S* r,S\RZ                  4S+ jr.S\/S \RZ                  4   4S, jr0S\RZ                  4S- jr1S1S. jr2S/r3g)4r4   i  z
Like an int (including magic methods), but redirects all operations on the
wrapped node. This is used in particular to symbolically record operations
in the symbolic shape workflow.
c                     Xl         g r   nodeselfr  s     r   __init__SymInt.__init__  	     	r   c                 4    [         R                  " U S:g  5      $ Nr   )r   boolr  s    r   __bool__SymInt.__bool__  s    }}TQY''r   c                 6    U R                   R                  5       $ r   r  int_r  s    r   __int__SymInt.__int__      yy~~r   c                 6    U R                   R                  5       $ r   r  r  s    r   	__index__SymInt.__index__  r  r   Nc                     U $ r   r   )r  ndigitss     r   	__round__SymInt.__round__      r   c                     [        U[        R                  [        45      (       a  [	        U 5      R                  U5      $ [        U[        R                  [        45      (       d  [        $ U R                  U5      $ r   )

isinstancer   floatr3   r\   __float_truediv__r   r4   NotImplemented__int_truediv__r  others     r   __truediv__SymInt.__truediv__  sZ    ehnnh788T?44U;;%(,,!788!!##E**r   c                     [        U[        R                  [        45      (       a  [	        U 5      R                  U5      $ [        U[        R                  [        45      (       d  [        $ U R                  U5      $ r   )
r  r   r  r3   r\   __rfloat_truediv__r   r4   r!  __rint_truediv__r#  s     r   __rtruediv__SymInt.__rtruediv__  sZ    ehnnh788T?55e<<%(,,!788!!$$U++r   c                    [        U[        R                  [        45      (       a+  [	        [
        R                  " [	        U 5      U-  5      5      $ [        U[        R                  [        45      (       d  [        $ U R                  U5      $ r   )r  r   r  r3   r\   mathfloorr   r4   r!  __int_floordiv__r#  s     r   __floordiv__SymInt.__floordiv__  sb    ehnnh788TZZ	$%(?@AA%(,,!788!!$$U++r   c                    [        U[        R                  [        45      (       a+  [	        [
        R                  " U[	        U 5      -  5      5      $ [        U[        R                  [        45      (       d  [        $ U R                  U5      $ r   )r  r   r  r3   r\   r-  r.  r   r4   r!  __rint_floordiv__r#  s     r   __rfloordiv__SymInt.__rfloordiv__  sb    ehnnh788TZZ	$(?@AA%(,,!788!!%%e,,r   c                 J   [        U[        R                  [        45      (       a  [	        U 5      R                  U5      $ [        U[        R                  [        45      (       d  [        $ US:  a  U R                  U5      $ [	        U 5      R                  [	        U5      5      $ r
  )
r  r   r  r3   r\   __pow__r   r4   r!  __pow_by_natural__r#  s     r   r7  SymInt.__pow__  s    ehnnh788T?**511%(,,!788!! A:**511 T?**9U+;<<r   c                 J   [        U[        R                  [        45      (       a  [	        U 5      R                  U5      $ [        U[        R                  [        45      (       d  [        $ U S:  a  U R                  U5      $ [	        U 5      R                  [	        U5      5      $ r
  )
r  r   r  r3   r\   __rpow__r   r4   r!  __rpow_by_natural__r#  s     r   r;  SymInt.__rpow__  s{    ehnnh788T?++E22%(,,!788!!19++E22T?++Ie,<==r   r$  r   c                     [        S5      eNtype stub not overridden	TypeErrorr#  s     r   __eq__SymInt.__eq__      233r   c                     [        S5      er?  rA  r#  s     r   __lt__SymInt.__lt__  rE  r   c                     [        S5      er?  rA  r#  s     r   __gt__SymInt.__gt__  rE  r   c                     [        S5      er?  rA  r#  s     r   __le__SymInt.__le__  rE  r   c                     [        S5      er?  rA  r#  s     r   __ge__SymInt.__ge__  rE  r   c                     [        S5      er?  rA  r#  s     r   __add__SymInt.__add__  rE  r   c                     [        S5      er?  rA  r#  s     r   __radd__SymInt.__radd__
  rE  r   c                     [        S5      er?  rA  r#  s     r   __rmul__SymInt.__rmul__  rE  r   c                     [        S5      er?  rA  r#  s     r   __mod__SymInt.__mod__  rE  r   c                     [        S5      er?  rA  r#  s     r   __mul__SymInt.__mul__  rE  r   c                     [        S5      er?  rA  r#  s     r   r8  SymInt.__pow_by_natural__  rE  r   c                     [        S5      er?  rA  r#  s     r   r<  SymInt.__rpow_by_natural__  rE  r   c                     [        S5      er?  rA  r#  s     r   r"  SymInt.__int_truediv__  rE  r   c                     [        S5      er?  rA  r#  s     r   r)  SymInt.__rint_truediv__  rE  r   c                     [        S5      er?  rA  r#  s     r   r/  SymInt.__int_floordiv__"  rE  r   c                     [        S5      er?  rA  r#  s     r   r3  SymInt.__rint_floordiv__%  rE  r   c                     [        S5      er?  rA  r#  s     r   __sym_max__SymInt.__sym_max__(  rE  r   c                     [        S5      er?  rA  r#  s     r   __sym_min__SymInt.__sym_min__+  rE  r   c                     [        S5      er?  rA  r  s    r   __sym_float__SymInt.__sym_float__.  rE  r   c                     [        S5      er?  rA  r  s    r   __neg__SymInt.__neg__1  rE  r   c                     [        S5      er?  rA  r#  s     r   __sub__SymInt.__sub__4  rE  r   c                     [        S5      er?  rA  r#  s     r   __rsub__SymInt.__rsub__7  rE  r   c                     [        S5      er?  rA  r#  s     r   __and__SymInt.__and__:  rE  r   c                     [        S5      er?  rA  r#  s     r   __or__SymInt.__or__=  rE  r   c                 6    U R                   R                  5       $ r   r  _graph_reprr  s    r   __repr__SymInt.__repr__@      yy$$&&r   c                 .    U R                   R                  $ r   r  exprr  s    r   _sympy_SymInt._sympy_C      yy~~r   c                     U R                   R                  5       (       a#  [        U R                   R                  5       5      $ [	        S5      e)Nz"unhashable type: non-nested SymInt)r  is_nested_inthash
nested_intrB  r  s    r   __hash__SymInt.__hash__F  s;    99""$$		,,.// @AAr   c                 
    U S4$ )z,Represent this int as an exact integer ratior   r   r  s    r   as_integer_ratioSymInt.as_integer_ratioR  s    Qwr   c                 J    [         R                  " U 5      R                  5       $ r   )r   r   
bit_lengthr  s    r   r  SymInt.bit_lengthV  s    
 ||D!,,..r   c                     U $ r   r   r  s    r   	conjugateSymInt.conjugate]  r  r   r  r   )r   r4   )r$  r   r   r4   r   r3   )4__name__
__module____qualname____firstlineno____doc__r  r  r  r  r  r%  r*  r0  r4  r7  r;  r   r   r  rC  rG  rJ  rM  rP  rS  rV  rY  r\  r_  r8  r<  r"  r)  r/  r3  rn  rq  rt  rw  rz  r}  r  r  r  r  r   r  tupler  r  r  __static_attributes__r   r   r   r4   r4     s?   
(  
+,,-=0>4F 4x}} 44x}} 44x}} 44x}} 44x}} 44444444444444444444'B(,, B%(,,(>"? /HLL /r   r4   c                      \ 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\S\R                   4S jrS\R                   4S jrS\R                   4S jrS\R                   4S jrS\R                   4S jrS$S jrS$S jrS$S jrS$S jrS rS rS rS rS rS\\R@                  \R@                  4   4S jr!S r"S r#S r$S$S  jr%S\&4S! jr'S"r(g#)%r3   ia  z
Like an float (including magic methods), but redirects all operations on the
wrapped node. This is used in particular to symbolically record operations
in the symbolic shape workflow.
c                     Xl         g r   r  r  s     r   r  SymFloat.__init__h  r  r   c                     [        U[        R                  [        R                  [        [
        45      (       d  [        $ U R                  [        U5      5      $ r   )	r  r   r   r  r4   r3   r!  r   r\   r#  s     r   r%  SymFloat.__truediv__m  s<    %(,,!QRR!!%%i&677r   c                     [        U[        R                  [        R                  [        [
        45      (       d  [        $ U R                  [        U5      5      $ r   )	r  r   r   r  r4   r3   r!  r(  r\   r#  s     r   r*  SymFloat.__rtruediv__r  s<    %(,,!QRR!!&&y'788r   c                     [        U[        R                  [        R                  [        [
        45      (       d  [        $ [        [        R                  " U [        U5      -  5      5      $ r   
r  r   r   r  r4   r3   r!  r\   r-  r.  r#  s     r   r0  SymFloat.__floordiv__w  sD    %(,,!QRR!!D9U+;$;<==r   c                     [        U[        R                  [        R                  [        [
        45      (       d  [        $ [        [        R                  " [        U5      U -  5      5      $ r   r  r#  s     r   r4  SymFloat.__rfloordiv__|  sD    %(,,!QRR!!Ie$4t$;<==r   c                 6    U R                   R                  5       $ r   r  bool_r  s    r   r  SymFloat.__bool__      yy  r   c                 :    U R                   R                  SS5      $ )Nrq   r   )r  guard_floatr  s    r   	__float__SymFloat.__float__  s    yy$$R++r   c                     [        U[        R                  [        R                  [        [
        45      (       d  [        $ [        R                  " U S:  5        U R                  U5      $ r
  )
r  r   r   r  r4   r3   r!  torch_check__float_pow__r#  s     r   r7  SymFloat.__pow__  sG    %(,,!QRR!!TQY!!%((r   c                     [        U[        R                  [        R                  [        [
        45      (       d  [        $ [        R                  " US:  5        U R                  U5      $ r
  )
r  r   r   r  r4   r3   r!  r  r  __rfloat_pow__r#  s     r   r;  SymFloat.__rpow__  sG    %(,,!QRR!!UaZ ""5))r   r$  r   c                     [        S5      er?  rA  r#  s     r   rC  SymFloat.__eq__  rE  r   c                     [        S5      er?  rA  r#  s     r   rG  SymFloat.__lt__  rE  r   c                     [        S5      er?  rA  r#  s     r   rJ  SymFloat.__gt__  rE  r   c                     [        S5      er?  rA  r#  s     r   rM  SymFloat.__le__  rE  r   c                     [        S5      er?  rA  r#  s     r   rP  SymFloat.__ge__  rE  r   c                     [        S5      er?  rA  r#  s     r   r  SymFloat.__float_pow__  rE  r   c                     [        S5      er?  rA  r#  s     r   r  SymFloat.__rfloat_pow__  rE  r   c                     [        S5      er?  rA  r#  s     r   r   SymFloat.__float_truediv__  rE  r   c                     [        S5      er?  rA  r#  s     r   r(  SymFloat.__rfloat_truediv__  rE  r   c                     [        S5      er?  rA  r  s    r   	__trunc__SymFloat.__trunc__  rE  r   c                     [        S5      er?  rA  r#  s     r   rn  SymFloat.__sym_max__  rE  r   c                     [        S5      er?  rA  r#  s     r   rq  SymFloat.__sym_min__  rE  r   c                     [        S5      er?  rA  r  s    r   __sym_int__SymFloat.__sym_int__  rE  r   c                     [        S5      e)z'Return True if the float is an integer.r@  rA  r  s    r   
is_integerSymFloat.is_integer  s    233r   c                 J    [         R                  " U 5      R                  5       $ )z.Represent this float as an exact integer ratio)r   r  r  r  s    r   r  SymFloat.as_integer_ratio  s    ~~d#4466r   c                 6    U R                   R                  5       $ r   r  r  s    r   r  SymFloat.__repr__  r  r   c                 .    U R                   R                  $ r   r  r  s    r   r  SymFloat._sympy_  r  r   c                 @    [        [        R                  " U 5      5      $ r   )r  r   r  r  s    r   r  SymFloat.__hash__  s    HNN4())r   c                     U $ )z+Returns the complex conjugate of the float.r   r  s    r   r  SymFloat.conjugate  s    r   c                 V    U R                   R                  SS5      R                  5       $ )z4Returns the hexadecimal representation of the float.rq   r   )r  r  hexr  s    r   r  SymFloat.hex  s"    yy$$R+//11r   r  Nr  ))r  r  r  r  r  r  r%  r*  r0  r4  r  r  r7  r;  r   r   r  rC  rG  rJ  rM  rP  r  r  r   r(  r  rn  rq  r  r  r  r   r  r  r  r  r  strr  r  r   r   r   r3   r3   a  s    
8
9
>
>
!,
)*4F 4x}} 44x}} 44x}} 44x}} 44x}} 44444444447%hll(B"C 7'*2S 2r   r3   c                       \ rS rSrSrS rS rS rSS jrSS jr	SS	 jr
S
 rS\R                  4S jrS rS rS rSrg)r2   i  aV  
Like an bool (including magic methods), but redirects all operations on the
wrapped node. This is used in particular to symbolically record operations
in the symbolic shape workflow.

Unlike regular bools, regular boolean operators will force extra guards instead
of symbolically evaluate.  Use the bitwise operators instead to handle this.
c                     Xl         g r   r  r  s     r   r  SymBool.__init__  r  r   c                 6    U R                   R                  5       $ r   r  r  s    r   r  SymBool.__bool__  r  r   c                 ^    [         R                  " U R                  R                  5       5      $ r   )r   r   r  r  r  s    r   r  SymBool.__int__  s    ||DIIOO-..r   r   c                     [        S5      er?  rA  r#  s     r   r  SymBool.__and__  rE  r   c                     [        S5      er?  rA  r#  s     r   r  SymBool.__or__  rE  r   c                     [        S5      er?  rA  r  s    r   __sym_not__SymBool.__sym_not__  rE  r   c                     [        S5      er?  rA  )r  then_valelse_vals      r   __sym_ite__SymBool.__sym_ite__  rE  r   c                     [        S5      er?  rA  r#  s     r   rC  SymBool.__eq__  rE  r   c                 6    U R                   R                  5       $ r   r  r  s    r   r  SymBool.__repr__  r  r   c                 .    U R                   R                  $ r   r  r  s    r   r  SymBool._sympy_  r  r   c                     U R                   R                  5       (       a#  [        U R                   R                  5       5      $ [        [        R
                  " U 5      5      $ r   )r  is_constantr  r  r   r  r  s    r   r  SymBool.__hash__  sA    99  ""		)** d+,,r   r  N)r   r2   )r  r  r  r  r  r  r  r  r  r  r  r  r   r  rC  r  r  r  r  r   r   r   r2   r2     sI    
!/44(444x}} 4'-r   r2   c                    SSK n[        R                  " U 5      (       a  [        R                  " [        U 4U 5      $ [        U S5      (       a  U R                  5       $ [        XR                  5      (       a  U ) $ U (       + $ )z\SymInt-aware utility for logical negation.

Args:
    a (SymBool or bool): Object to negate
r   Nr  )	sympy	overrideshas_torch_function_unaryhandle_torch_functionrb   r   r  r  Basic)ar  s     r   rb   rb     se     ))!,,..wa@@q-  }}![[!!r	5Lr   c                    [         R                  " U 5      (       a  [         R                  " [        U 4U 5      $ [	        U [
        5      (       a  U $ [        U S5      (       a  U R                  5       $ [        R                  " U 5      $ )zcSymInt-aware utility for float casting.

Args:
    a (SymInt, SymFloat, or object): Object to cast
rt  )
r  r  r  r\   r  r3   r   rt  r   r  r  s    r   r\   r\   -  sg     ))!,,..y1$BB!X	O	$	$  >>!r   c                 "   [         R                  " U 5      (       a  [         R                  " [        U 4U 5      $ [	        U [
        5      (       a  U $ [	        U [        5      (       a  [        R                  " U 5      $ [        R                  " U 5      $ )zaSymInt-aware utility for int casting.

Args:
    a (SymInt, SymFloat, or object): Object to cast
)r  r  r  r^   r  r4   r3   r-  truncr   r   r  s    r   r^   r^   <  sg     ))!,,..wa@@!V	Ax	 	 zz!}<<?r   c                 |   [         R                  " X45      (       a  [         R                  " [        X4X5      $ [	        U [
        [        45      (       a  U R                  U5      $ [	        U[
        [        45      (       a  UR                  U 5      $ [        5       u  p#[	        X5      (       d   [        U 5      5       e[	        X5      (       d   [        U5      5       e[	        X5      (       d  [	        X5      (       a*  [        R                  " [        R                  " X5      5      $ [        R                  " X5      $ )a  
SymInt-aware utility for max which avoids branching on a < b.
Unlike builtins.max(), this only works for int/float, and it always
promotes to float if any argument is float (unlike builtins.max, which
will faithfully preserve the type of the input argument).
)r  has_torch_functionr  r`   r  r4   r3   rn  __all_and_float_typestyper   r  maxr  b	all_typesfloat_typess       r   r`   r`   K  s     ##QF++..wEE!fh'((}}Q	A)	*	* }}Q 34Ia##,T!W,#a##,T!W,#!!!Z%?%?~~hll1011||A!!r   .c                  <    SS K n U R                  U R                  [        R                  [        R
                  4nU R                  [        R
                  4nX4$ ! [         a6    [        R                  [        R
                  4n[        R
                  4n X4$ f = fr
  )numpyintegerfloatingr   r   r  ModuleNotFoundError)npr   r!  s      r   r  r  f  s    ( JJKKLLNN	'
	 *,hnn(E
 !!	  (\\8>>2	~~'!!	(s   AA ;BBc                 |   [         R                  " X45      (       a  [         R                  " [        X4X5      $ [	        U [
        [        45      (       a  U R                  U5      $ [	        U[
        [        45      (       a  UR                  U 5      $ [        5       u  p#[	        X5      (       d   [        U 5      5       e[	        X5      (       d   [        U5      5       e[	        X5      (       d  [	        X5      (       a*  [        R                  " [        R                  " X5      5      $ [        R                  " X5      $ )zSymInt-aware utility for min().)r  r  r  ra   r  r4   r3   rq  r  r  r   r  minr  s       r   ra   ra   x  s    ##QF++..wEE!fh'((}}Q	A)	*	*}}Q24Ia##,T!W,#a##,T!W,#!!!Z%?%?~~hll1011||A!!r   c                   ^^ [         R                  " U 5      (       a  [         R                  " [        X 5      $ SmU  Hc  n[	        U[
        [        R                  45      (       d  [        R                  " U 5      s  $ [	        U[
        5      (       d  MW  UR                  mMe     Tc  [        R                  " U 5      $ SSK
JmJn  U" TR                  [        UU4S jU  5       5      5      5      $ )z
N-ary add which is faster to compute for long lists than iterated binary
addition.  Only does something special for integers.
Nr   )to_node	wrap_nodec              3   6   >#    U  H  nT" TU5      v   M     g 7fr   r   )rx   r  foundr+  s     r   rz   sym_sum.<locals>.<genexpr>  s     (IDq):):Ds   )r  r  r  rc   r  r4   r   r   sumr  torch.fx.experimental.sym_noder+  r,  r  )r   r  r,  r.  r+  s      @@r   rc   rc     s    
 ##D))..wCCE!fhll344<<%%a  FFE	 
 }||D!!AU]]5(ID(I#IJKKr   c                    ^ ^ UU 4S jmT$ )Nc                 B  > [         R                  " U 5      (       a  [         R                  " TU 4U 5      $ [        U [        5      (       a  [
        R                  " U 5      n [        U ST S35      (       a  [        U ST S35      " 5       $ [        [        T5      " U 5      $ )N__sym___)
r  r  r  r  r4   r  r\   r   getattrr-  )r  fnnames    r   r7  _get_sym_math_fn.<locals>.fn  s    --a00222tQ??a  "A1tfB'((1tfB/022tT"1%%r   r   )r8  r7  s   `@r   _get_sym_math_fnr:    s    & Ir   )Nrq   rq   )sqrtcoscoshsinsinhtantanhasinacosatanlog2_sym_	_sym_sqrtsym_sqrtc                 Z   [         R                  " XU45      (       a  [         R                  " [        XU4XU5      $ [	        U [
        [        R                  45      (       a  [        U5      [        U5      :X  d   e[	        U [
        5      (       a  U R                  X5      $ U (       a  U$ U$ r   )
r  r  r  r_   r  r2   r   r  r  r  )r  tr   s      r   r_   r_     s    ##Q1I....wq	1KKa'8==122tAw$q'7III!W}}Q""1qr   c                 J    [         R                  " U 5      R                  5       $ r   )r  tensoritem)r  s    r   r]   r]     s    <<""$$r   )_initExtensiona  
                Failed to load PyTorch C extensions:
                    It appears that PyTorch has loaded the `torch/_C` folder
                    of the PyTorch repository rather than the C extensions which
                    are expected in the `torch._C` namespace. This can occur when
                    using the `install` workflow. e.g.
                        $ python setup.py install && python -c "import torch"

                    This error can generally be solved using the `develop` workflow
                        $ python setup.py develop && python -c "import torch"  # This should succeed
                    or by running Python from a different directory.
                )_C)rq   Nr   Base>   	GeneratorDisableTorchFunctionDisableTorchFunctionSubclass
TensorBasec                 v   Uc
  [        5       nX;   a  g UR                  U 5        U R                  n[        U 5       Hz  n[	        X5      n[	        USS5      n[
        R                  " U5      (       d  M8  UR                  U5      (       d  MP  [        R                  R                  XT5        [        XA5        M|     g )Nr  rq   )setaddr  dirr6  inspectismodule
startswithr   r   
setdefault _import_extension_to_sys_modules)modulememomodule_namer8  membermember_names         r   r]  r]    s    <5D>ooKDV*F!&*b9K''K,B,B;,O,O&&{;0>  r   objc                   [        U [        R                  5      (       a  U R                  5       $ [	        U SS5      =(       d    SnSn[        U S5      (       a  U R                  nOS[        U S5      (       a  U R                  nO5U R                  R                  =(       d    SnU R                  R                  nUS;   a  U$ U SU 3$ )a  
String representation of the type of an object.

This function returns a fully qualified string representation of an object's type.
Args:
    obj (object): The object whose type to represent
Returns:
    str: the type of the object `o`
Example:
    >>> x = torch.tensor([1, 2, 3])
    >>> torch.typename(x)
    'torch.LongTensor'
    >>> torch.typename(torch.nn.Parameter)
    'torch.nn.parameter.Parameter'
r  rq   r  r  >   rq   r   r   )
r  r  r5   r  r6  r   r  r  	__class__r  )rc  r^  qualnames      r   rd   rd   )  s      #u||$$xxzS,+1rFHsN####	j	!	!<<))/R==--!!XQxj!!r   ztorch.Tensorc                6    [        U [        R                  5      $ )a  Returns True if `obj` is a PyTorch tensor.

Note that this function is simply doing ``isinstance(obj, Tensor)``.
Using that ``isinstance`` check is better for typechecking with mypy,
and more explicit - so it's recommended to use that instead of
``is_tensor``.

Args:
    obj (object): Object to test
Example::

    >>> x = torch.tensor([1, 2, 3])
    >>> torch.is_tensor(x)
    True

)r  r  r5   rc  s    r   rH   rH   L  s    " c5<<((r   )r6   r7   c                &    [        U 5      [        ;   $ )z[Returns True if `obj` is a PyTorch storage object.

Args:
    obj (Object): Object to test
)r  _storage_classesrh  s    r   rG   rG   `  s     9(((r   torch.devicec                      [        [        S5      (       aI  [        R                  R                  n U R                  b  U $ [
        R                  " / 5      R                  $ [
        R                  " S5      $ )z?Gets the default ``torch.Tensor`` to be allocated on ``device``device_contextcpu)r   _GLOBAL_DEVICE_CONTEXTrm  deviceindexr  rL  )rp  s    r   r?   r?   l  sY     %'788'66==<<#M <<#***||E""r   rp  c                     [        [        S5      (       a&  [        R                  nUb  UR                  SSS5        U c  SnOSSKJn  U" U 5      nUR                  5         U[        l        g)a  Sets the default ``torch.Tensor`` to be allocated on ``device``.  This
does not affect factory function calls which are called with an explicit
``device`` argument.  Factory calls will be performed as if they
were passed ``device`` as an argument.

To only temporarily change the default device instead of setting it
globally, use ``with torch.device(device):`` instead.

The default device is initially ``cpu``.  If you set the default tensor
device to another device (e.g., ``cuda``) without a device index, tensors
will be allocated on whatever the current device for the device type,
even after :func:`torch.cuda.set_device` is called.

.. warning::

    This function imposes a slight performance cost on every Python
    call to the torch API (not just factory functions).  If this
    is causing problems for you, please comment on
    https://github.com/pytorch/pytorch/issues/92701

.. note::

    This doesn't affect functions that create tensors that share the same memory as the input, like:
    :func:`torch.from_numpy` and :func:`torch.frombuffer`

Args:
    device (device or string): the device to set as default

Example::

    >>> # xdoctest: +SKIP("requires cuda, changes global state")
    >>> torch.get_default_device()
    device(type='cpu')
    >>> torch.set_default_device('cuda')  # current device is 0
    >>> torch.get_default_device()
    device(type='cuda', index=0)
    >>> torch.set_default_device('cuda')
    >>> torch.cuda.set_device('cuda:1')  # current device is 1
    >>> torch.get_default_device()
    device(type='cuda', index=1)
    >>> torch.set_default_device('cuda:1')
    >>> torch.get_default_device()
    device(type='cuda', index=1)

rm  Nr   )DeviceContext)r   ro  rm  __exit__torch.utils._devicers  	__enter__)rp  rm  rs  s      r   rS   rS   |  sc    b %'788/>>%##D$5~5&v.  ",:)r   rJ  c                p    [        U [        5      (       a  [        U 5      n [        R                  " U 5        g)aa  
.. warning::

    This function is deprecated as of PyTorch 2.1, please use :func:`torch.set_default_dtype()` and
    :func:`torch.set_default_device()` as alternatives.

Sets the default ``torch.Tensor`` type to floating point tensor type
``t``. This type will also be used as default floating point type for
type inference in :func:`torch.tensor`.

The default floating point tensor type is initially ``torch.FloatTensor``.

Args:
    t (type or string): the floating point tensor type or its name

Example::

    >>> # xdoctest: +SKIP("Other tests may have changed the default type. Can we reset it?")
    >>> torch.tensor([1.2, 3]).dtype    # initial default for floating point is torch.float32
    torch.float32
    >>> torch.set_default_tensor_type(torch.DoubleTensor)
    >>> torch.tensor([1.2, 3]).dtype    # a new floating point tensor
    torch.float64

N)r  r  r   rO  _set_default_tensor_type)rJ  s    r   rT   rT     s)    4 !S""r   c                0    [         R                  " U 5        g)ah  

Sets the default floating point dtype to :attr:`d`. Supports floating point dtype
as inputs. Other dtypes will cause torch to raise an exception.

When PyTorch is initialized its default floating point dtype is torch.float32,
and the intent of set_default_dtype(torch.float64) is to facilitate NumPy-like
type inference. The default floating point dtype is used to:

1. Implicitly determine the default complex dtype. When the default floating type is float16,
   the default complex dtype is complex32. For float32, the default complex dtype is complex64.
   For float64, it is complex128. For bfloat16, an exception will be raised because
   there is no corresponding complex type for bfloat16.
2. Infer the dtype for tensors constructed using Python floats or complex Python
   numbers. See examples below.
3. Determine the result of type promotion between bool and integer tensors and
   Python floats and complex Python numbers.

Args:
    d (:class:`torch.dtype`): the floating point dtype to make the default.

Example:
    >>> # xdoctest: +SKIP("Other tests may have changed the default type. Can we reset it?")
    >>> # initial default for floating point is torch.float32
    >>> # Python floats are interpreted as float32
    >>> torch.tensor([1.2, 3]).dtype
    torch.float32
    >>> # initial default for floating point is torch.complex64
    >>> # Complex Python numbers are interpreted as complex64
    >>> torch.tensor([1.2, 3j]).dtype
    torch.complex64

    >>> torch.set_default_dtype(torch.float64)
    >>> # Python floats are now interpreted as float64
    >>> torch.tensor([1.2, 3]).dtype  # a new floating point tensor
    torch.float64
    >>> # Complex Python numbers are now interpreted as complex128
    >>> torch.tensor([1.2, 3j]).dtype  # a new complex tensor
    torch.complex128

    >>> torch.set_default_dtype(torch.float16)
    >>> # Python floats are now interpreted as float16
    >>> torch.tensor([1.2, 3]).dtype  # a new floating point tensor
    torch.float16
    >>> # Complex Python numbers are now interpreted as complex128
    >>> torch.tensor([1.2, 3j]).dtype  # a new complex tensor
    torch.complex32

N)rO  _set_default_dtype)ds    r   set_default_dtyper|    s    d !r   F	warn_onlyr   r~  c                ,    [         R                  " XS9  g)aJ  Sets whether PyTorch operations must use "deterministic"
algorithms. That is, algorithms which, given the same input, and when
run on the same software and hardware, always produce the same output.
When enabled, operations will use deterministic algorithms when available,
and if only nondeterministic algorithms are available they will throw a
:class:`RuntimeError` when called.

.. note:: This setting alone is not always enough to make an application
    reproducible. Refer to :ref:`reproducibility` for more information.

.. note:: :func:`torch.set_deterministic_debug_mode` offers an alternative
    interface for this feature.

The following normally-nondeterministic operations will act
deterministically when ``mode=True``:

    * :class:`torch.nn.Conv1d` when called on CUDA tensor
    * :class:`torch.nn.Conv2d` when called on CUDA tensor
    * :class:`torch.nn.Conv3d` when called on CUDA tensor
    * :class:`torch.nn.ConvTranspose1d` when called on CUDA tensor
    * :class:`torch.nn.ConvTranspose2d` when called on CUDA tensor
    * :class:`torch.nn.ConvTranspose3d` when called on CUDA tensor
    * :class:`torch.nn.ReplicationPad2d` when attempting to differentiate a CUDA tensor
    * :func:`torch.bmm` when called on sparse-dense CUDA tensors
    * :func:`torch.Tensor.__getitem__` when attempting to differentiate a CPU tensor
      and the index is a list of tensors
    * :func:`torch.Tensor.index_put` with ``accumulate=False``
    * :func:`torch.Tensor.index_put` with ``accumulate=True`` when called on a CPU
      tensor
    * :func:`torch.Tensor.put_` with ``accumulate=True`` when called on a CPU
      tensor
    * :func:`torch.Tensor.scatter_add_` when called on a CUDA tensor
    * :func:`torch.gather` when called on a CUDA tensor that requires grad
    * :func:`torch.index_add` when called on CUDA tensor
    * :func:`torch.index_select` when attempting to differentiate a CUDA tensor
    * :func:`torch.repeat_interleave` when attempting to differentiate a CUDA tensor
    * :func:`torch.Tensor.index_copy` when called on a CPU or CUDA tensor
    * :func:`torch.Tensor.scatter` when `src` type is Tensor and called on CUDA tensor
    * :func:`torch.Tensor.scatter_reduce` when ``reduce='sum'`` or ``reduce='mean'`` and called on CUDA tensor

The following normally-nondeterministic operations will throw a
:class:`RuntimeError` when ``mode=True``:

    * :class:`torch.nn.AvgPool3d` when attempting to differentiate a CUDA tensor
    * :class:`torch.nn.AdaptiveAvgPool2d` when attempting to differentiate a CUDA tensor
    * :class:`torch.nn.AdaptiveAvgPool3d` when attempting to differentiate a CUDA tensor
    * :class:`torch.nn.MaxPool3d` when attempting to differentiate a CUDA tensor
    * :class:`torch.nn.AdaptiveMaxPool2d` when attempting to differentiate a CUDA tensor
    * :class:`torch.nn.FractionalMaxPool2d` when attempting to differentiate a CUDA tensor
    * :class:`torch.nn.FractionalMaxPool3d` when attempting to differentiate a CUDA tensor
    * :class:`torch.nn.MaxUnpool1d`
    * :class:`torch.nn.MaxUnpool2d`
    * :class:`torch.nn.MaxUnpool3d`
    * :func:`torch.nn.functional.interpolate` when attempting to differentiate a CUDA tensor
      and one of the following modes is used:

      - ``linear``
      - ``bilinear``
      - ``bicubic``
      - ``trilinear``

    * :class:`torch.nn.ReflectionPad1d` when attempting to differentiate a CUDA tensor
    * :class:`torch.nn.ReflectionPad2d` when attempting to differentiate a CUDA tensor
    * :class:`torch.nn.ReflectionPad3d` when attempting to differentiate a CUDA tensor
    * :class:`torch.nn.ReplicationPad1d` when attempting to differentiate a CUDA tensor
    * :class:`torch.nn.ReplicationPad3d` when attempting to differentiate a CUDA tensor
    * :class:`torch.nn.NLLLoss` when called on a CUDA tensor
    * :class:`torch.nn.CTCLoss` when attempting to differentiate a CUDA tensor
    * :class:`torch.nn.EmbeddingBag` when attempting to differentiate a CUDA tensor when
      ``mode='max'``
    * :func:`torch.Tensor.put_` when ``accumulate=False``
    * :func:`torch.Tensor.put_` when ``accumulate=True`` and called on a CUDA tensor
    * :func:`torch.histc` when called on a CUDA tensor
    * :func:`torch.bincount` when called on a CUDA tensor and ``weights``
      tensor is given
    * :func:`torch.kthvalue` with called on a CUDA tensor
    * :func:`torch.median` with indices output when called on a CUDA tensor
    * :func:`torch.nn.functional.grid_sample` when attempting to differentiate a CUDA tensor
    * :func:`torch.cumsum` when called on a CUDA tensor when dtype is floating point or complex
    * :func:`torch.Tensor.scatter_reduce` when ``reduce='prod'`` and called on CUDA tensor
    * :func:`torch.Tensor.resize_` when called with a quantized tensor

In addition, several operations fill uninitialized memory when this setting
is turned on and when
:attr:`torch.utils.deterministic.fill_uninitialized_memory` is turned on.
See the documentation for that attribute for more information.

A handful of CUDA operations are nondeterministic if the CUDA version is
10.2 or greater, unless the environment variable ``CUBLAS_WORKSPACE_CONFIG=:4096:8``
or ``CUBLAS_WORKSPACE_CONFIG=:16:8`` is set. See the CUDA documentation for more
details: `<https://docs.nvidia.com/cuda/cublas/index.html#results-reproducibility>`_
If one of these environment variable configurations is not set, a :class:`RuntimeError`
will be raised from these operations when called with CUDA tensors:

    * :func:`torch.mm`
    * :func:`torch.mv`
    * :func:`torch.bmm`

Note that deterministic operations tend to have worse performance than
nondeterministic operations.

.. note::

    This flag does not detect or prevent nondeterministic behavior caused
    by calling an inplace operation on a tensor with an internal memory
    overlap or by giving such a tensor as the :attr:`out` argument for an
    operation. In these cases, multiple writes of different data may target
    a single memory location, and the order of writes is not guaranteed.

Args:
    mode (:class:`bool`): If True, makes potentially nondeterministic
        operations switch to a deterministic algorithm or throw a runtime
        error. If False, allows nondeterministic operations.

Keyword args:
    warn_only (:class:`bool`, optional): If True, operations that do not
        have a deterministic implementation will throw a warning instead of
        an error. Default: ``False``

Example::

    >>> # xdoctest: +SKIP
    >>> torch.use_deterministic_algorithms(True)

    # Forward mode nondeterministic error
    >>> torch.randn(10, device='cuda').kthvalue(1)
    ...
    RuntimeError: kthvalue CUDA does not have a deterministic implementation...

    # Backward mode nondeterministic error
    >>> torch.nn.AvgPool3d(1)(torch.randn(3, 4, 5, 6, requires_grad=True).cuda()).sum().backward()
    ...
    RuntimeError: avg_pool3d_backward_cuda does not have a deterministic implementation...
r}  N)rO  _set_deterministic_algorithms)r   r~  s     r   rf   rf     s    V $$T?r   c                  ,    [         R                  " 5       $ )zReturns True if the global deterministic flag is turned on. Refer to
:func:`torch.use_deterministic_algorithms` documentation for more details.
)rO  _get_deterministic_algorithmsr   r   r   r8   r8          ++--r   c                  ,    [         R                  " 5       $ )zReturns True if the global deterministic flag is set to warn only.
Refer to :func:`torch.use_deterministic_algorithms` documentation for more
details.
)rO  '_get_deterministic_algorithms_warn_onlyr   r   r   rF   rF     s    
 5577r   
debug_modec                    [        U [        R                  [        45      (       d  [	        S[        U 5       35      e[        U [        5      (       a)  U S:X  a  Sn O U S:X  a  Sn OU S:X  a  Sn O[        SU  35      eU S:X  a  [        R                  " S	5        gU S:X  a  [        R                  " S
S
S9  gU S:X  a  [        R                  " S
5        g[        SU  35      e)a  Sets the debug mode for deterministic operations.

.. note:: This is an alternative interface for
    :func:`torch.use_deterministic_algorithms`. Refer to that function's
    documentation for details about affected operations.

Args:
    debug_mode(str or int): If "default" or 0, don't error or warn on
        nondeterministic operations. If "warn" or 1, warn on
        nondeterministic operations. If "error" or 2, error on
        nondeterministic operations.
z'debug_mode must be str or int, but got defaultr   warnr   error   zQinvalid value of debug_mode, expected one of `default`, `warn`, `error`, but got FTr}  z:invalid value of debug_mode, expected 0, 1, or 2, but got N)	r  r   r   r  rB  r  RuntimeErrorrO  r  )r  s    r   rU   rU     s      j8<<"566A$zBRASTUU*c"""J6!J7"J,,6<9 
 Q
((/	q
((>	q
((.HU
 	
r   c                  p    [         R                  " 5       (       a  [         R                  " 5       (       a  ggg)zReturns the current value of the debug mode for deterministic
operations. Refer to :func:`torch.set_deterministic_debug_mode`
documentation for more details.
r   r  r   )rO  r  r  r   r   r   r@   r@     s+     
''))5577r   c                  ,    [         R                  " 5       $ )zReturns the current value of float32 matrix multiplication precision. Refer to
:func:`torch.set_float32_matmul_precision` documentation for more details.
)rO  _get_float32_matmul_precisionr   r   r   rB   rB     r  r   	precisionc                 0    [         R                  " U 5        g)a  Sets the internal precision of float32 matrix multiplications.

Running float32 matrix multiplications in lower precision may significantly increase
performance, and in some programs the loss of precision has a negligible impact.

Supports three settings:

    * "highest", float32 matrix multiplications use the float32 datatype (24 mantissa
      bits with 23 bits explicitly stored) for internal computations.
    * "high", float32 matrix multiplications either use the TensorFloat32 datatype (10
      mantissa bits explicitly stored) or treat each float32 number as the sum of two bfloat16 numbers
      (approximately 16 mantissa bits with 14 bits explicitly stored), if the appropriate fast matrix multiplication
      algorithms are available.  Otherwise float32 matrix multiplications are computed
      as if the precision is "highest".  See below for more information on the bfloat16
      approach.
    * "medium", float32 matrix multiplications use the bfloat16 datatype (8 mantissa
      bits with 7 bits explicitly stored) for internal computations, if a fast matrix multiplication algorithm
      using that datatype internally is available. Otherwise float32
      matrix multiplications are computed as if the precision is "high".

When using "high" precision, float32 multiplications may use a bfloat16-based algorithm
that is more complicated than simply truncating to some smaller number mantissa bits
(e.g. 10 for TensorFloat32, 7 for bfloat16 explicitly stored).  Refer to [Henry2019]_ for a complete
description of this algorithm.  To briefly explain here, the first step is to realize
that we can perfectly encode a single float32 number as the sum of three bfloat16
numbers (because float32 has 23 mantissa bits while bfloat16 has 7 explicitly stored, and both have the
same number of exponent bits).  This means that the product of two float32 numbers can
be exactly given by the sum of nine products of bfloat16 numbers.  We can then trade
accuracy for speed by dropping some of these products.  The "high" precision algorithm
specifically keeps only the three most significant products, which conveniently excludes
all of the products involving the last 8 mantissa bits of either input.  This means that
we can represent our inputs as the sum of two bfloat16 numbers rather than three.
Because bfloat16 fused-multiply-add (FMA) instructions are typically >10x faster than
float32 ones, it's faster to do three multiplications and 2 additions with bfloat16
precision than it is to do a single multiplication with float32 precision.

.. [Henry2019] http://arxiv.org/abs/1904.06376

.. note::

    This does not change the output dtype of float32 matrix multiplications,
    it controls how the internal computation of the matrix multiplication is performed.

.. note::

    This does not change the precision of convolution operations. Other flags,
    like `torch.backends.cudnn.allow_tf32`, may control the precision of convolution
    operations.

.. note::

    This flag currently only affects one native device type: CUDA.
    If "high" or "medium" are set then the TensorFloat32 datatype will be used
    when computing float32 matrix multiplications, equivalent to setting
    `torch.backends.cuda.matmul.allow_tf32 = True`. When "highest" (the default)
    is set then the float32 datatype is used for internal computations, equivalent
    to setting `torch.backends.cuda.matmul.allow_tf32 = False`.

Args:
    precision(str): can be set to "highest" (default), "high", or "medium" (see above).

N)rO  _set_float32_matmul_precision)r  s    r   rV   rV     s    ~ $$Y/r   r  c                0    [         R                  " U 5        g)ax  When this flag is False (default) then some PyTorch warnings may only
appear once per process. This helps avoid excessive warning information.
Setting it to True causes these warnings to always appear, which may be
helpful when debugging.

Args:
    b (:class:`bool`): If True, force warnings to always be emitted
                       If False, set to the default behaviour
N)rO  _set_warnAlways)r  s    r   rY   rY   1  s     qr   c                  ,    [         R                  " 5       $ )zReturns True if the global warn_always flag is turned on. Refer to
:func:`torch.set_warn_always` documentation for more details.
)rO  _get_warnAlwaysr   r   r   rI   rI   >  s     r   r<   messagec                 l   [        U[        R                  [        45      (       d  [	        S[        U5       35      eSSKJn  U" U5      (       a  g [        U [        5      (       a  [        U [        5      (       a   eUc  SnO+[        U5      (       d  [	        S5      e[        U" 5       5      nU " U5      e)Nzcond must be a bool, but got r   )expect_truezExpected cond to be True, but got False. (Could this error message be improved? If so, please report an enhancement request to PyTorch.)zmessage must be a callable)r  r   r  r2   rB  r  %torch.fx.experimental.symbolic_shapesr  
issubclassr   Warningcallabler  )
error_typer<   r  r  message_evaluateds        r   _check_withr  M  s    
 dX]]G4557T
|DEEA4 j),,Z
G5T5TTT 	   899	N
&
''r   c                 $    [        [        X5        g)a  Throws error containing an optional message if the specified condition
is False.

Error type: ``RuntimeError``

C++ equivalent: ``TORCH_CHECK``

Args:
    cond (:class:`bool`): If False, throw error

    message (Callable, optional): Callable that returns either a string or
        an object that has a ``__str__()`` method to be used as the error
        message. Default: ``None``
N)r  r  r<   r  s     r   r  r  m  s     d,r   )r  c                ~    [        U S:  U5        SSKJn  U" U 5        Ub  [        X:*  U5        SSKJn  U" X5        gg)aG  Checks that a given integer is a valid size (i.e., is non-negative).
You should use this over ``_check(i >= 0)`` because it can prevent
``GuardOnDataDependentSymNode`` exceptions by opting yourself into alternate
semantics for ``guard_size_oblivious`` tests that treat values 0 and 1
equivalently to all other values.

When max is not None, this specifies an upper bound equivalent to
``_check(i <= max)``.  This bound is also subject to alternate semantics:
in ``guard_size_oblivious`` tests, we assume that a constant max bound is
treated equivalently to all other values.  Symbolic max bounds are not yet
supported.

NB: Do NOT use this in contexts where a -1 size would be valid (indicating
to infer the size from context, or if you should wrap-around or truncate).
Only use this if the only valid value is an honest to goodness size.
r   )_advise_is_sizeN)_advise_is_bounded)r  r  r  r  )ir  r  r  r  s        r   _check_is_sizer    s>    $ 167EA
qx!L1" r   c                 $    [        [        X5        g)a  Throws error containing an optional message if the specified condition
is False.

Error type: ``IndexError``

C++ equivalent: ``TORCH_CHECK_INDEX``

Args:
    cond (:class:`bool`): If False, throw error

    message (Callable, optional): Callable that returns either a string or
        an object that has a ``__str__()`` method to be used as the error
        message. Default: ``None``
N)r  
IndexErrorr  s     r   _check_indexr         
D*r   c                 $    [        [        X5        g)a  Throws error containing an optional message if the specified condition
is False.

Error type: ``ValueError``

C++ equivalent: ``TORCH_CHECK_VALUE``

Args:
    cond (:class:`bool`): If False, throw error

    message (Callable, optional): Callable that returns either a string or
        an object that has a ``__str__()`` method to be used as the error
        message. Default: ``None``
N)r  r   r  s     r   _check_valuer    r  r   c                 $    [        [        X5        g)a  Throws error containing an optional message if the specified condition
is False.

Error type: ``TypeError``

C++ equivalent: ``TORCH_CHECK_TYPE``

Args:
    cond (:class:`bool`): If False, throw error

    message (Callable, optional): Callable that returns either a string or
        an object that has a ``__str__()`` method to be used as the error
        message. Default: ``None``
N)r  rB  r  s     r   _check_typer    s     	4)r   c                 $    [        [        X5        g)a  Throws error containing an optional message if the specified condition
is False.

Error type: ``NotImplementedError``

C++ equivalent: ``TORCH_CHECK_NOT_IMPLEMENTED``

Args:
    cond (:class:`bool`): If False, throw error

    message (Callable, optional): Callable that returns either a string or
        an object that has a ``__str__()`` method to be used as the error
        message. Default: ``None``
N)r  NotImplementedErrorr  s     r   _check_not_implementedr    s     #T3r   c                    [        U5      (       d  [        S[        U5       35      eUR                  [        R
                  :X  d  [        SUR                   35      e[        XR                  " 5       R                  5       U5        g )Nzcond must be a tensor, but got z0cond tensor must have dtype torch.bool, but got )	rH   rB  r  dtyper  r  r  _is_all_truerM  )r  r<   r  s      r   _check_tensor_all_withr    se    T??9$t*FGG::#J4::,WXX
--/446@r   c                 $    [        [        X5        g)a  Throws error containing an optional message if the specified condition
is False.

Error type: ``RuntimeError``

C++ equivalent: ``TORCH_CHECK_TENSOR_ALL``

Args:
    cond (:class:`torch.Tensor`): Tensor of dtype ``torch.bool``. If any
        element is ``False``, throw error

    message (Callable, optional): Callable that returns either a string or
        an object that has a ``__str__()`` method to be used as the error
        message. Default: ``None``
N)r  r  r  s     r   _check_tensor_allr    s      <7r   )einfnanpinewaxis)r  r  r  r  r  )r5   )storage)_LegacyStorage_StorageBase_warn_typed_storage_removalr6   r7   c                   4    \ rS rSr\S 5       r\S 5       rSrg)r#   i$  c                 ,    [        SS9  U R                  $ N   
stacklevelr  _dtyper  s    r   r  ByteStorage.dtype%      #q1{{r   c                 "    [         R                  $ r   )r  uint8r  s    r   r  ByteStorage._dtype*      {{r   r   Nr  r  r  r  r   r  r  r  r   r   r   r#   r#   $  (       r   r#   c                   4    \ rS rSr\S 5       r\S 5       rSrg)r'   i/  c                 ,    [        SS9  U R                  $ r  r  r  s    r   r  DoubleStorage.dtype0  r  r   c                 "    [         R                  $ r   )r  doubler  s    r   r  DoubleStorage._dtype5      ||r   r   Nr  r   r   r   r'   r'   /  (       r   r'   c                   4    \ rS rSr\S 5       r\S 5       rSrg)r)   i:  c                 ,    [        SS9  U R                  $ r  r  r  s    r   r  FloatStorage.dtype;  r  r   c                 "    [         R                  $ r   )r  r  r  s    r   r  FloatStorage._dtype@  r  r   r   Nr  r   r   r   r)   r)   :  r  r   r)   c                   4    \ rS rSr\S 5       r\S 5       rSrg)HalfStorageiE  c                 ,    [        SS9  U R                  $ r  r  r  s    r   r  HalfStorage.dtypeF  r  r   c                 "    [         R                  $ r   )r  halfr  s    r   r  HalfStorage._dtypeK      zzr   r   Nr  r   r   r   r  r  E  (       r   r  c                   4    \ rS rSr\S 5       r\S 5       rSrg)r.   iP  c                 ,    [        SS9  U R                  $ r  r  r  s    r   r  LongStorage.dtypeQ  r  r   c                 "    [         R                  $ r   )r  longr  s    r   r  LongStorage._dtypeV  r  r   r   Nr  r   r   r   r.   r.   P  r  r   r.   c                   4    \ rS rSr\S 5       r\S 5       rSrg)r,   i[  c                 ,    [        SS9  U R                  $ r  r  r  s    r   r  IntStorage.dtype\  r  r   c                 "    [         R                  $ r   )r  r   r  s    r   r  IntStorage._dtypea  s    yyr   r   Nr  r   r   r   r,   r,   [  s(       r   r,   c                   4    \ rS rSr\S 5       r\S 5       rSrg)r0   if  c                 ,    [        SS9  U R                  $ r  r  r  s    r   r  ShortStorage.dtypeg  r  r   c                 "    [         R                  $ r   )r  shortr  s    r   r  ShortStorage._dtypel  r  r   r   Nr  r   r   r   r0   r0   f  r  r   r0   c                   4    \ rS rSr\S 5       r\S 5       rSrg)r%   iq  c                 ,    [        SS9  U R                  $ r  r  r  s    r   r  CharStorage.dtyper  r  r   c                 "    [         R                  $ r   )r  int8r  s    r   r  CharStorage._dtypew  r  r   r   Nr  r   r   r   r%   r%   q  r  r   r%   c                   4    \ rS rSr\S 5       r\S 5       rSrg)r!   i|  c                 ,    [        SS9  U R                  $ r  r  r  s    r   r  BoolStorage.dtype}  r  r   c                 "    [         R                  $ r   )r  r  r  s    r   r  BoolStorage._dtype  r  r   r   Nr  r   r   r   r!   r!   |  r  r   r!   c                   4    \ rS rSr\S 5       r\S 5       rSrg)BFloat16Storagei  c                 ,    [        SS9  U R                  $ r  r  r  s    r   r  BFloat16Storage.dtype  r  r   c                 "    [         R                  $ r   )r  bfloat16r  s    r   r  BFloat16Storage._dtype      ~~r   r   Nr  r   r   r   r  r    (       r   r  c                   4    \ rS rSr\S 5       r\S 5       rSrg)ComplexDoubleStoragei  c                 ,    [        SS9  U R                  $ r  r  r  s    r   r  ComplexDoubleStorage.dtype  r  r   c                 "    [         R                  $ r   )r  cdoubler  s    r   r  ComplexDoubleStorage._dtype  s    }}r   r   Nr  r   r   r   r  r    s(       r   r  c                   4    \ rS rSr\S 5       r\S 5       rSrg)ComplexFloatStoragei  c                 ,    [        SS9  U R                  $ r  r  r  s    r   r  ComplexFloatStorage.dtype  r  r   c                 "    [         R                  $ r   )r  cfloatr  s    r   r  ComplexFloatStorage._dtype  r  r   r   Nr  r   r   r   r  r    r  r   r  c                   4    \ rS rSr\S 5       r\S 5       rSrg)QUInt8Storagei  c                 ,    [        SS9  U R                  $ r  r  r  s    r   r  QUInt8Storage.dtype  r  r   c                 "    [         R                  $ r   )r  quint8r  s    r   r  QUInt8Storage._dtype  r  r   r   Nr  r   r   r   r  r    r  r   r  c                   4    \ rS rSr\S 5       r\S 5       rSrg)QInt8Storagei  c                 ,    [        SS9  U R                  $ r  r  r  s    r   r  QInt8Storage.dtype  r  r   c                 "    [         R                  $ r   )r  qint8r  s    r   r  QInt8Storage._dtype  r  r   r   Nr  r   r   r   r#  r#    r  r   r#  c                   4    \ rS rSr\S 5       r\S 5       rSrg)QInt32Storagei  c                 ,    [        SS9  U R                  $ r  r  r  s    r   r  QInt32Storage.dtype  r  r   c                 "    [         R                  $ r   )r  qint32r  s    r   r  QInt32Storage._dtype  r  r   r   Nr  r   r   r   r*  r*    r  r   r*  c                   4    \ rS rSr\S 5       r\S 5       rSrg)QUInt4x2Storagei  c                 ,    [        SS9  U R                  $ r  r  r  s    r   r  QUInt4x2Storage.dtype  r  r   c                 "    [         R                  $ r   )r  quint4x2r  s    r   r  QUInt4x2Storage._dtype  r  r   r   Nr  r   r   r   r1  r1    r  r   r1  c                   4    \ rS rSr\S 5       r\S 5       rSrg)QUInt2x4Storagei  c                 ,    [        SS9  U R                  $ r  r  r  s    r   r  QUInt2x4Storage.dtype  r  r   c                 "    [         R                  $ r   )r  quint2x4r  s    r   r  QUInt2x4Storage._dtype  r  r   r   Nr  r   r   r   r8  r8    r  r   r8  rj  _tensor_classes)amprandomserialization)rW   )r9   r+   )rC   rE   rL   rR   rX   )rJ   rQ   c                     [        5       (       d  [        R                  " 5       S:X  a  g[        SSS5      n [	        [        S5      5        [
        R                  R                  U 5      (       d  [        SU -   5      eU R                  S5      $ )Nr   r   r  rn   torch_shm_managerz$Unable to find torch_shm_manager at zutf-8)
r   r   r   r   r   rs   rt   ru   r  encode)rt   s    r   _manager_pathrE    sk    !2i!?%)<=D'g(>?77>>$ADHII;;wr   )
unique_dimr5  segment_reducec              #      #    U  H6  n[        [        [        U5      [        R                  5      (       d  M2  Uv   M8     g 7fr   )r  r6  r  r  )rx   r8  s     r   rz   rz   >  s)      T:geT.BEKK#PDDZs
   1A 	A )_disable_dynamo)_VF
functionalc                     [        U 5      [        R                  La9  [        R                  " U 45      (       a  [        R
                  " [        U 4X5      $ U (       d   U5       eg)zAA wrapper around Python's assert which is symbolically traceable.N)r  r  r5   r  r  r  _assert)	conditionr  s     r   rM  rM  ^  sV    Iell*y/K/K	0 0 ..i\9
 	
 g9r   )r=   rD   rN   set_grad_enabled)
__config__
__future___awaitsacceleratorautogradbackendsrn  rk   distributeddistributionsfftfutureshubjitlinalgmpsmtiamultiprocessingnestednnoptimr  profilersparsespecialtestingtypesutilsxpu)windows)ao)
_size_docs_storage_docs_tensor_docs_torch_docsc                  "    [         R                  $ )z?Returns whether PyTorch was built with _GLIBCXX_USE_CXX11_ABI=1)rO  _GLIBCXX_USE_CXX11_ABIr   r   r   compiled_with_cxx11_abirr    s    $$$r   )_library_ops)ops)classesz.opsz.classes)quantization)quasirandom)register_after_fork)rK   )masked)_symeigeiglstsqmatrix_ranksolve)from_dlpack	to_dlpackc                   h    \ rS rSrSrS rS rS\\   4S jr	S\\
\\4      4S jrS	 rS
 rS rSrg)_TorchCompileInductorWrapperi  inductorc                 >   SSK Jn  0 U l        X0l        U R	                  U5        U R                  U5        U R                  UR                  S5      5        U R                  R                  SS5      (       a'  S[        R                  S'   S[        R                  S	'   g g )
Nr   CompilerBisectorr  triton.cudagraphsF1DISABLE_CUPTI_LAZY_REINIT0TEARDOWN_CUPTI)
!torch._inductor.compiler_bisectorr  configdynamic
apply_modeapply_optionsget_config_changer   rs   r   )r  r   optionsr  r  s        r   r  %_TorchCompileInductorWrapper.__init__  s    F')7#+==jIJ;;??.6669BJJ23
 ,/BJJ'( 7r   c                     [        U[        5      =(       a9    U R                  UR                  :H  =(       a    U R                  UR                  :H  $ r   )r  r  r  r  r#  s     r   rC  #_TorchCompileInductorWrapper.__eq__ 	  s<    u:; .u||+.-	
r   r   c                 p    U(       a/  US:w  a(  SSK Jn  U R                  U" XR                  5      5        g g g )Nr  r   )list_mode_options)torch._inductorr  r  r  )r  r   r  s      r   r  '_TorchCompileInductorWrapper.apply_mode	  s.    DI%90||DE &4r   r  c           
         U(       d  g SSK Jn  UR                  5       nUR                  5        H  u  pEUR	                  SS5      nXc;  a(  [        SU S[        UR                  5       5       35      eUR                  U5      n[        U5      cP  [        XW5      (       d@  [        U5      R                  n[        X6   5      R                  n	[        SU SU S	U	 35      eXPR                  U'   M     g )
Nr   r  -r   zUnexpected optimization option z, known options are zUnexpected type of attr z, got z should be )r  r  get_config_copyr   r   r  listkeysget_type_get_originr  r  r  )
r  r  r  current_configkeyval	attr_name	attr_typeval_type_strexpected_type_strs
             r   r  *_TorchCompileInductorWrapper.apply_options	  s    **0*@*@*BHCC-I."5cU:NtTbTgTgTiOjNkl  	2I 9%-!#11#'9#5#5L(,^-F(G(P(P%&23%vl^;WhVij  &)KK	"# (r   c                 0    SSK Jn  U" XU R                  S9$ )Nr   )
compile_fxconfig_patches)torch._inductor.compile_fxr  r  )r  model_inputs_r  s       r   __call__%_TorchCompileInductorWrapper.__call__(	  s    9&$++FFr   c                 .    SSK Jn  U" U R                  S9$ )Nr   )get_patched_config_dictr  )r  r  r  )r  r  s     r   get_compiler_config0_TorchCompileInductorWrapper.get_compiler_config-	  s    F&dkkBBr   c                     SSK Jn  SU R                  ;   d  UR                  R                  (       a0  U R                  R	                  SS5      (       a  SSKJn  U" 5         g g g )Nr   r  r  T)reset_cudagraph_trees)r  r  triton
cudagraphsr   torch._inductor.cudagraph_treesr  )r  r  r  s      r   reset"_TorchCompileInductorWrapper.reset2	  sG    *$++-1I1I{{2D99Q%' : 2Jr   )r  r  N)r  r  r  r  compiler_namer  rC  	_Optionalr  r  dict_Anyr  r  r  r  r  r   r   r   r  r    sM    M/"
Fy~ F)YtCI%? )6G
C
(r   r  c                   ,    \ rS rSrS rS rS rS rSrg)_TorchCompileWrapperi<	  c                 D   SSK Jn  [        U[        5      (       a  Xl        O3[        US5      (       a  UR                  U l        O[        U5      U l        X@l        U" U5      U l        0 U l	        U(       a  US:w  a  X R                  S'   U(       a  X0R                  S'   g g )Nr   )lookup_backendr  r  r   r  )
torch._dynamo.backends.registryr  r  r  r  r   r  r  compiler_fnkwargs)r  backendr   r  r  r  s         r   r  _TorchCompileWrapper.__init__=	  s    Bgs##!(Wj))!(!1!1D!$WD)'2DI%"&KK%,KK	" r   c                     [        U[        5      =(       aY    U R                  UR                  :H  =(       a9    U R                  UR                  :H  =(       a    U R                  UR                  :H  $ r   )r  r  r  r  r  r#  s     r   rC  _TorchCompileWrapper.__eq__O	  sW    u23 .  E$5$55.u||+. -		
r   c                 <    U R                   " X40 U R                  D6$ r   )r  r  )r  r  r  s      r   r  _TorchCompileWrapper.__call__W	  s    ?4;;??r   c                 p    [        U R                  S5      (       a  U R                  R                  5         g g )Nr  )r   r  r  r  s    r   r  _TorchCompileWrapper.resetZ	  s,    4##W--""$ .r   )r  r  r  r  N)	r  r  r  r  r  rC  r  r  r  r   r   r   r  r  <	  s    -$
@%r   r  _InputT_RetTr  	fullgraphr  r  r   r  disablemodelr  r  r  r  r  c                    g r   r   r  r  r  r  r   r  r  s          r   r;   r;   c	  s     !$r   c                    g r   r   r  s          r   r;   r;   p	  s	     ILr   c                0  ^^^^^^ SSK n[        R                  " S5        [        R                  S:  a  [        S5      eUR                  S5      S:X  a  [        S5      eU c5  S	[        [        [        4   S
[        [        [        4   4UUUUUU4S jjnU$ Tb  Tb  [        S5      eTc  Tc  SmSSK
Jn	  U	R                  5       =n
(       a  U
mTS:X  a  [        TTT5      mO[        TTTT5      m[        R                   R#                  TTTTS9" U 5      $ )a  
Optimizes given model/function using TorchDynamo and specified backend.
If you are compiling an :class:`torch.nn.Module`, you can also use :meth:`torch.nn.Module.compile`
to compile the module inplace without changing its structure.

Concretely, for every frame executed within the compiled region, we will attempt
to compile it and cache the compiled result on the code object for future
use.  A single frame may be compiled multiple times if previous compiled
results are not applicable for subsequent calls (this is called a "guard
failure), you can use TORCH_LOGS=guards to debug these situations.
Multiple compiled results can be associated with a frame up to
``torch._dynamo.config.recompile_limit``, which defaults to 8; at which
point we will fall back to eager.  Note that compile caches are per
*code object*, not frame; if you dynamically create multiple copies of a
function, they will all share the same code cache.

Args:
   model (Callable): Module/function to optimize
   fullgraph (bool): If False (default), torch.compile attempts to discover compileable regions
    in the function that it will optimize. If True, then we require that the entire function be
    capturable into a single graph. If this is not possible (that is, if there are graph breaks),
    then this will raise an error.
   dynamic (bool or None): Use dynamic shape tracing.  When this is True, we will up-front attempt
    to generate a kernel that is as dynamic as possible to avoid recompilations when
    sizes change.  This may not always work as some operations/optimizations will
    force specialization; use TORCH_LOGS=dynamic to debug overspecialization.
    When this is False, we will NEVER generate dynamic kernels, we will always specialize.
    By default (None), we automatically detect if dynamism has occurred and compile a more
    dynamic kernel upon recompile.
   backend (str or Callable): backend to be used

    - "inductor" is the default backend, which is a good balance between performance and overhead

    - Non experimental in-tree backends can be seen with `torch._dynamo.list_backends()`

    - Experimental or debug in-tree backends can be seen with `torch._dynamo.list_backends(None)`

    - To register an out-of-tree custom backend:
      https://pytorch.org/docs/main/torch.compiler_custom_backends.html#registering-custom-backends
   mode (str): Can be either "default", "reduce-overhead", "max-autotune" or "max-autotune-no-cudagraphs"

    - "default" is the default mode, which is a good balance between performance and overhead

    - "reduce-overhead" is a mode that reduces the overhead of python with CUDA graphs,
      useful for small batches.  Reduction of overhead can come at the cost of more memory
      usage, as we will cache the workspace memory required for the invocation so that we
      do not have to reallocate it on subsequent runs.  Reduction of overhead is not guaranteed
      to work; today, we only reduce overhead for CUDA only graphs which do not mutate inputs.
      There are other circumstances where CUDA graphs are not applicable; use TORCH_LOG=perf_hints
      to debug.

    - "max-autotune" is a mode that leverages Triton or template based matrix multiplications
      on supported devices and Triton based convolutions on GPU.
      It enables CUDA graphs by default on GPU.

    - "max-autotune-no-cudagraphs" is a mode similar to "max-autotune" but without CUDA graphs

    - To see the exact configs that each mode sets you can call `torch._inductor.list_mode_options()`

   options (dict): A dictionary of options to pass to the backend. Some notable ones to try out are

    - `epilogue_fusion` which fuses pointwise ops into templates. Requires `max_autotune` to also be set

    - `max_autotune` which will profile to pick the best matmul configuration

    - `fallback_random` which is useful when debugging accuracy issues

    - `shape_padding` which pads matrix shapes to better align loads on GPUs especially for tensor cores

    - `triton.cudagraphs` which will reduce the overhead of python with CUDA graphs

    - `trace.enabled` which is the most useful debugging flag to turn on

    - `trace.graph_diagram` which will show you a picture of your graph after fusion

    - For inductor you can see the full list of configs that it supports by calling `torch._inductor.list_options()`
   disable (bool): Turn torch.compile() into a no-op for testing

Example::

    @torch.compile(options={"triton.cudagraphs": True}, fullgraph=True)
    def foo(x):
        return torch.sin(x) + torch.cos(x)

r   Nztorch.compile)r     z.torch.compile is not supported on Python 3.14+Py_GIL_DISABLEDr   z@torch.compile is not supported on Python built with GIL disabledr  r   c           
      >   > U c  [        S5      e[        U TTTTTTS9$ )NzModel can't be Noner  )r  r;   )r  r  r  r  r  r   r  s    r   r7  compile.<locals>.fn	  s6    }"#899# r   zVEither mode or options can be specified, but both can't be specified at the same time.r  r  r  )r  nopythonr  r  )r   rO  _log_api_usage_oncer   version_infor  r   	_Callabler  r  r  r  get_backendr  r  r  _dynamooptimize)r  r  r  r  r   r  r  r   r7  r  bisect_backends    ``````    r   r;   r;   }	  s,   D ?+
7"KLL		!	!"3	4	9N
 	

 }	i/ 	Igun4M 	 	 	G/d
 	
 |B)5577~7 *.tWgF&wgwG==!!	 " 
  r   c           	      4   [         R                  " U 5      R                  n [        R                  [
           n[        X 5      (       a  [        SU  S[        X 5       S35      e[        X U5        SR                  [
        U /5      nU[        R                  U'   g)zRegister an external runtime module of the specific :attr:`device_type`
supported by torch.

After the :attr:`module` is registered correctly, the user can refer
the external runtime module as part of torch with attribute torch.xxx.
zThe runtime module of 'z$' has already been registered with ''r   N)r  rp  r  r   r   r  r   r  r6  setattrrv   )device_typer^  mtorch_module_names       r   _register_device_moduler  
  s     ,,{+00KHAq%k] 3%%,Q%<$=Q@
 	
 AF#(K!89%+CKK!"r   )r>   funclibraryreturn_types)r<   
while_loop)rg   )_meta_registrationsTORCH_CUDA_SANITIZER)fx)compilerc                       \ rS rSr% \R
                  R                  SS5      r0 r\	\
\\4   \4   \S'   \S 5       rSrg)_TritonLibraryiF
  r  DEF	ops_tablec                     X4U R                   ;  aI  U R                  R                  U5        U R                  R                  SU-   X45        X0R                   X4'   U R                   X4   $ )Nztriton::)r  ro   defineimpl)clsop_keyfull_schemaop_impldispatch_keys        r   
registerOp_TritonLibrary.registerOpJ
  sY    %S]]:{+Z&0'H8?v45==&!788r   r   N)r  r  r  r  r  r  rm   ro   r  r  r  r  r  __annotations__classmethodr  r  r   r   r   r  r  F
  sF    mm##He468	4c3h238		9 
	9r   r  )has_mpshas_cuda	has_cudnn
has_mkldnn)r  	_inductor_subclassesonnx>   r  r  _exportr  c           	          [         R                  U 5      nUb9  SS KnUR                  SU  SUR                   SUR
                   S3SS9  U" 5       $ U [        ;   a  [        R                  " SU  3[
        5      $ [        S[
         S	U  S35      e)
Nr   r  z' is deprecated, please use 'r   z()'r  r  zmodule 'z' has no attribute ')
_deprecated_attrsr   warningsr  r  r  _lazy_modules	importlibimport_moduleAttributeError)r8  replacementr  s      r   __getattr__r  p
  s    '++D1"MMD66{7M7M6NaP[PdPdOeehi   =  = **Qtf:x@@xz1EdV1MNNr   c                    [        U [        R                  5      (       a  U R                  nOq[        U [        5      (       a!  [        R                  " U 5      R                  nO;U c)  [        R
                  R                  5       R                  nO[        SU  S35      e[        [        US5      nUc  [        SU SU S35      eU$ )z
Returns the module associated with a given device(e.g., torch.device('cuda'), "mtia:0", "xpu", ...).
If no device is given, return the module for the current accelerator or CPU if none is present.
NzInvalid value of device 'z$', expect torch.device, str, or NonezDevice 'z<' does not have a corresponding module registered as 'torch.z'.)	r  r  rp  r  r  rO  _get_acceleratorr  r6  )rp  device_module_namedevice_modules      r   rA   rA   
  s    
 &%,,''#[[	FC	 	 "\\&166	"XX668=='x/ST
 	
 E#5t<M)**fgyfzz|}
 	
 r   r)  r  c                 .    [         R                  " XUS9  g)a)  
This indicates that a given int is size-like, and can be used in any context where a size is expected.
You will typically use this when reading out integers from Tensors, e.g., max.item() or lengths.tolist()
which then need to be used as tensor constructors. Providing these assertions to PyTorch can help resolve
  GuardOnDataDependentSymNode errors upon export, since we cannot guard on unbacked SymInts.

This function has unusual semantics in some circumstances in framework
code, we will treat this int as >= 2 (when we do a size-oblivious guard).
This makes it easier to use the unbacked int in size contexts,
as we will often attempt to guard on a size being zero/one
(e.g., when computing the contiguity of a tensor, or testing if
broadcasting can occur), which will not work on unbacked SymInts.
However, if we conservatively assume that the size is not zero/one, we will
end up with a graph that will still work even if the size is zero/one.

For more details, see https://docs.google.com/document/d/1HSuTTVvYH1pTew89Rtpeu84Ht3nQEFTYhAX3Ypa_xJs/edit
```
)r)  r  N)r  sym_constrain_range_for_size)symbolr)  r  s      r   _constrain_as_sizer  
  s    . 
&&vC@r   )_loggingc                     SSK Jn   Sn[        R                  S:  a  U " 5       R	                  US5      nOU " US9nU H  n UR                  5       nU" 5         M     g	! [         a  n[        SUR                   S35      UeS	nAff = f)
z
Leverage the Python plugin mechanism to load out-of-the-tree device extensions.
See this RFC: https://github.com/pytorch/pytorch/issues/122468
r   )entry_pointsztorch.backends)r  
   r   )groupz&Failed to load the backend extension: zN. You can disable extension auto-loading with TORCH_DEVICE_BACKEND_AUTOLOAD=0.N)	importlib.metadatar"  r   r  r   rJ   r   r  r8  )r"  
group_namebackend_extensionsbackend_extension
entrypointr   s         r   _import_device_backendsr*  
  s    
 0!J
'!)^//
B?)
;/		*//1JL 0  	89J9O9O8P Q_ ` 	s   A
B'BBc                  6    [         R                  " SS5      S:H  $ )a>  
Whether autoloading out-of-the-tree device extensions is enabled.
The switch depends on the value of the environment variable
`TORCH_DEVICE_BACKEND_AUTOLOAD`.

Returns:
    bool: Whether to enable autoloading the extensions. Enabled by default.

Examples:
    >>> torch._is_device_backend_autoload_enabled()
    True
TORCH_DEVICE_BACKEND_AUTOLOADr  )rs   r   r   r   r   #_is_device_backend_autoload_enabledr-  
  s     994c:cAAr   c                    [        U 5      nU[        R                  L a#  [        R                  " U [        R
                  S9$ U[        R                  L a#  [        R                  " U [        R                  S9$ [        R                  " U 5      $ )z
Like torch.as_tensor, but when given Python data types it will keep
them in full precision.  Used for calling convention for Dynamo.
)r  )r  r   r  r  	as_tensorfloat64r   int64)rJ  tys     r   _as_tensor_fullprecr3  
  s^    
 
aB	X^^q66	x||	q44q!!r   )r   Nr   )r   rk  )r{  ztorch.dtyper   N)NN(C  r  r   r   r   r  rY  r-  rs   r   r   r   	threadingtypingr   r  r   r  r   r  r   r  r   	_overloadr   r	   _TypeVarr
   _Uniontyping_extensionsr   
_ParamSpecrg  r   r  r   torch._utilsr   _syncr   r   torch._utils_internalr   r   r   r   r    	TypeGuard_TypeIsr   torch.torch_version__all__sortedr   r  r  r   r   r   r   r   getdlopenflags	old_flagssetdlopenflagsr   	RTLD_LAZYtorch._Cr4   r3   r2   rb   r\   r^   r`   r  r  r  ra   rc   r:  __fn__name
__sym_namer  r  globalsrH  appendr_   r]   rN  ImportErrorrO  _C_for_compiled_checkr   r   r   r  __objrX  endswithr6  r  isclassr  delattrr   r]  rd   rH   rG   localro  r?   r   rS   rT   r|  rf   r8   rF   rU   r@   rB   rV   rY   rI   r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r   torch._tensorr5   r  torch.storager  r  r  r6   r7   r#   r'   r)   r  r.   r,   r0   r%   r!   r  r  r  r  r#  r*  r1  r8  rj  rV  r>  r?  r@  rA  torch._tensor_strrW   	torch.ampr9   r+   torch.randomrC   rE   rL   rR   rX   torch.serializationrJ   rQ   rE  torch._C._VariableFunctionsrG  _segment_reducePRIVATE_OPS_VariableFunctionsr[  torch._compilerI  rJ  rK  torch.functionalrM  torch.autogradr=   rD   rN   rO  rP  rQ  rR  rS  rT  rU  rn  rk   rV  rW  rX  rY  rZ  r[  r\  r]  r^  r_  r`  ra  rb  r  rc  rd  re  rf  rh  ri  torch.signalrj  rk  torch.nn.intrinsictorch.nn.qattorch.nn.quantizabletorch.nn.quantized_init_namesrl  rm  rn  ro  rr  rs  rt  
torch._opsru  torch._classesrv  r\  rw  rx  contiguous_formatlegacy_contiguous_formattorch.multiprocessing._atforkry  get_num_threadstorch._lobpcgrK   atenquantized_lstmquantized_grurz  torch._linalg_utilsr{  symeigr|  r}  r~  r  torch.utils.dlpackr  r  r  r  r  r  r  r;   r  r>   r  r  r  torch._higher_order_opsr<   r  
torch.funcrg   r  r   torch.cuda._sanitizer
_sanitizercsanenable_cuda_sanitizerr1  r  _initr  r  is_builtr   is_availablemkldnnr  r  r  r  r  r  r  rp  rA   r  r   
_init_logsr*  r-  r3  r   r   r   <module>r     s         	  
  	 	 	 6 "Hhmm H 
  $K #--#* 3>HV &/! !! <<7n/` (c (s (c (d3i (3 # $ "BCJ "RYY/F%G%Ghoo/9<$ ""$Ir~~45y! B BJt2 t2nA- A-H""6"uU49%5uT3Y7G%GH "$"&L.
 ( fjF !JF#D(22D GIj!& 	&*. 9[! z %
'4  "gFayC 7 7vF#E??gooe448+ " 
 (0E$ , 5 
<	H%v. " E
? %R(( "$  "c  "F)4 )w~6 )()D )/O(P Q ) #* # =;f^S(,,>?@=;	=;@#vd>&:C&?@ # #>2p  %K@
--K@ }}K@ 
	K@\.hmm .8x}} 8)
VHLL#4E-F )
4 )
Xhll .c .?0C ?0D ?0D
x}} 
D 
   (
'
(( r3w(@-$#4 #>+$+$*$4$A82 !     3 4 ! % . N > . .  > . . n > . N > N n n  'E #d6,">?@A . .1UT.)* 2 O N . * V V *    -/ "  . %O "''(F&K"7B))62EE!!!	&vGIfS!!v ) E   Z  + 7  (        > ,
      t$% & G F }j% %
 5 " -   (4(# .   (8,g 6 / -
 -  > = E)) * + * ((&&
 #    6 5M( M(` %  %F Y
   %(,&0"NR"	$We^$	$ }}	$ x}}%		$
 CN#	$ d
	$ tCX\\8==(H!IIJK	$ ]]	$ w~	$ 	$ 	L  %(,&0"NR"	L	L }}	L x}}%		L
 CN#	L d
	L tCX\\8==(H!IIJK	L ]]	L 	'5.)*Igun,EEF	L 	L #'T  %(,&0"NR"TYT }}T x}}%	T
 CN#T d
T tCX\\8==(H!IIJKT ]]T y%()9We^+DDEgunTn,(   K J # # ) RZZ'((  &       *9 9  ~~!!**##,,%%22..''44	    MO&iu||S/@(AB 4 $(#'A	8<<	 A 
8<<	 A4  	   4BX]] B""" '(( )u8  
, %%-OO eg
 	  
+
s   p: :Aq<