
    9iw                        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  S SK	J
r   S SKrSr\" S/ SQ5      r/ SQr/ S	Qr/ S
Qr/ SQr/ SQrS rS rS rS rS2S jrS rS rS rS r S r!S r"S r#S r$S r%S r&S r'S r(S r)S r*S  r+S! r,S" r-S# r.S$ r/S% r0S& r1S' r2S2S( jr3S) r4S* r5S+ r6S, r7S-Rq                  5       r9S. r:S/ r;S0 r<\=S1:X  a  \<" 5         gg! \\\\4 a    Sr Nf = f)3    N)
namedtuple)castTF	SystemEnv)torch_versionis_debug_buildcuda_compiled_versiongcc_versionclang_versioncmake_versionoslibc_versionpython_versionpython_platformis_cuda_availablecuda_runtime_versioncuda_module_loadingnvidia_driver_versionnvidia_gpu_modelscudnn_versionis_xpu_availablepip_versionpip_packagesconda_packageship_compiled_versionhip_runtime_versionmiopen_runtime_versioncaching_allocator_configis_xnnpack_availablecpu_info)torchnumpytritonoptree)zcuda-cudartz
cuda-cuptizcuda-librarieszcuda-openclz
cuda-nvrtczcuda-runtimecublascudnncufftcurandcusolvercusparsenccl	nvjitlinknvtx)zdpcpp-cpp-rtzintel-cmplr-lib-rtzintel-cmplr-lib-urzintel-cmplr-lic-rtzintel-opencl-rtzintel-sycl-rtmklzonemkl-sycl-blaszonemkl-sycl-dftzonemkl-sycl-lapackzonemkl-sycl-rngzonemkl-sycl-sparsezintel-openmptbbzimpi-rtz
impi-develonecclzoneccl-develz	intel-ptiumftcmlib)cudatoolkitsoumithr-   magma)mypyflake8onnxc                    [        U 5      [        L a  SOSn[        R                  " U [        R                  [        R                  US9nUR                  5       u  p4UR                  n[        5       S:X  a  SnO[        R                  " 5       nUR                  U5      nUR                  U5      nXWR                  5       UR                  5       4$ )z%Return (return-code, stdout, stderr).TF)stdoutstderrshellwin32oem)typestr
subprocessPopenPIPEcommunicate
returncodeget_platformlocalegetpreferredencodingdecodestrip)	commandr;   p
raw_outputraw_errrcencoutputerrs	            W/var/www/html/land-doc-ocr/venv/lib/python3.13/site-packages/torch/utils/collect_env.pyrunrS   x   s    MS(DeE

u	A --/J	
B~ ))+s#F
..
C||~syy{**    c                 *    U " U5      u  p#nUS:w  a  gU$ )zIRun command using run_lambda; reads and returns entire output if rc is 0.r   N 
run_lambdarJ   rN   out_s        rR   run_and_read_allr[      s    G$JBQ	QwJrT   c                 |    U " U5      u  p4nUS:w  a  g[         R                  " X$5      nUc  gUR                  S5      $ )zIRun command using run_lambda, returns the first regex match if it exists.r   N   )researchgroup)rX   rJ   regexrN   rY   rZ   matchs          rR   run_and_parse_first_matchrc      s>    G$JBQ	QwIIe!E};;q>rT   c                 N    U " U5      u  p#nUS:w  a  gUR                  S5      S   $ )zKRun command using run_lambda and returns first line if output is not empty.r   N
)splitrW   s        rR   run_and_return_first_linerg      s-    G$JBQ	Qw99T?1rT   c                   ^ Tc  [         [        -   [        -   [        -   m[        R
                  R                  SS5      n[        U SR                  U5      5      nUc  U$ SR                  U4S jUR                  5        5       5      $ )N	CONDA_EXEcondaz{} listre   c              3      >^#    U  H;  mTR                  S 5      (       a  M  [        U4S jT 5       5      (       d  M7  Tv   M=     g7f)#c              3   ,   >#    U  H	  oT;   v   M     g 7fNrV   .0namelines     rR   	<genexpr>/get_conda_packages.<locals>.<genexpr>.<genexpr>   s     +NXTDLX   N)
startswithanyrp   rr   patternss    @rR   rs   %get_conda_packages.<locals>.<genexpr>   s9      $Ds# 	(++NX+N(N 	$s   AA	A)CONDA_PATTERNSCOMMON_PATTERNSNVIDIA_PATTERNSONEAPI_PATTERNSr   environgetr[   formatjoin
splitlines)rX   ry   rj   rY   s    `  rR   get_conda_packagesr      sw    !O3oEWJJNN;0E
:y'7'7'>
?C
{
99 NN$  rT   c                     [        U SS5      $ )Nzgcc --versionzgcc (.*)rc   rX   s    rR   get_gcc_versionr      s    $Z+NNrT   c                     [        U SS5      $ )Nzclang --versionzclang version (.*)r   r   s    rR   get_clang_versionr      s    $%'< rT   c                     [        U SS5      $ )Nzcmake --versionz
cmake (.*)r   r   s    rR   get_cmake_versionr      s    $Z1BMRRrT   c                 f    [        5       S:X  a  Sn[        XS5      $ [        5       n[        XS5      $ )Ndarwinzkextstat | grep -i cudazcom[.]nvidia[.]CUDA [(](.*?)[)]zDriver Version: (.*?) )rE   rc   get_nvidia_smi)rX   cmdsmis      rR   get_nvidia_driver_versionr      s<    ~!'(?
 	
 
C$Z6OPPrT   c                    [        5       S:X  dE  [        (       a  [        [        R                  S5      (       a  [        R                  R
                  b  [        (       a  [        R                  R                  5       (       a  [        R                  R
                  bO  [        R                  R                  S5      n[        US5      (       a  SR                  UR                  5      nOSnOSn[        R                  R                  S 5      U-   $ g [        5       n[        R                  " S5      nU " US	-   5      u  pVnUS:w  a  g [        R                  " USU5      $ )
Nr   hipr   gcnArchNamez ({})NoGCNArchNameOnOldPyTorch z \(UUID: .+?\)z -L)rE   TORCH_AVAILABLEhasattrr    versionr   cudais_availableget_device_propertiesr   r   get_device_namer   r^   compilesub)rX   propgcnArchr   
uuid_regexrN   rY   rZ   s           rR   get_gpu_infor      s    ~!EMM5))MM)?uzz6688}}  ,zz77:4//%nnT-=-=>G9G::--d3g==

C-.JC%K(JBQ	Qw66*b#&&rT   c                     [        U SS5      $ )Nznvcc --versionzrelease .+ V(.*)r   r   s    rR   get_running_cuda_versionr      s    $Z1ACVWWrT   c                    [        5       S:X  as  [        R                  R                  SS5      n[        R                  R                  SS5      n[        R                  R                  USS5      nSR                  X25      nO[        5       S	:X  a  S
nOSnU " U5      u  pVn[        U5      S:X  d  US:w  al  US:w  af  [        R                  R                  S5      nUbC  [        R                  R                  U5      (       a  [        R                  R                  U5      $ g[        5       n	UR                  S5       HY  n
[        R                  R                  U
5      n
[        R                  R                  U
5      (       d  MH  U	R                  U
5        M[     U	(       d  g[        U	5      n[        U5      S:X  a  US   $ SR                  U5      nSR                  U5      $ )zHReturn a list of libcudnn.so; it's hard to tell which one is being used.r<   
SYSTEMROOT
C:\Windows	CUDA_PATHz%CUDA_PATH%System32wherez{} /R "{}\bin" cudnn*.dllr   z ls /usr/local/cuda/lib/libcudnn*z7ldconfig -p | grep libcudnn | rev | cut -d" " -f1 | revr   r]   CUDNN_LIBRARYNre   z!Probably one of the following:
{})rE   r   r   r   pathr   r   lenisfilerealpathsetrf   addsorted)rX   system_root	cuda_path	where_cmd	cudnn_cmdrN   rY   rZ   l	files_setfnfilesresults                rR   get_cudnn_versionr      sg   ~ jjnn\=AJJNN;>	GGLLj'B	077	M		8	#
 7	M	I&JBQ
3x1}qR1WJJNN?+=RWW^^A..77##A&&IiioWWb!77>>"MM"  9E
5zQQxYYuF/66v>>rT   c                     Sn [        5       S:X  a  [        R                  R                  SS5      n[        R                  R                  SS5      n[        R                  R                  USSU 5      n[        R                  R                  US	U 5      nXC/nU H;  n[        R                  R                  U5      (       d  M)  S
R                  U5      n   U $    U $ )Nz
nvidia-smir<   r   r   PROGRAMFILESzC:\Program FileszNVIDIA CorporationNVSMIr   z"{}")rE   r   r   r   r   r   existsr   )r   r   program_files_rootlegacy_pathnew_pathsmiscandidate_smis          rR   r   r     s    
C~ jjnn\=AZZ^^N<OPggll 4gs
 77<<Z=&!Mww~~m,,mmM2J	 " JrT   c                  l    [        5       S:w  a  gS H  n [        SU  35      u  n  nUS:X  d  M  U s  $    g)NlinuxN/Adpkgdnfyumzypperzwhich r   )rE   rS   )mgr_namerN   rZ   s      rR   _detect_linux_pkg_managerr      sA    ~ 4z*+Aq7O 5 rT   c                 h   [        5       nUS:X  a  gSSS.SSS.SSS.SSS.S	.n[        [        [        X2   S
   5      5      n[        X2   S   5      nUR	                  U5      n[        X5      nUb  US:X  a  g[        R                  " SSU5      R                  S5      n[        U5      U::  a  gXt   $ )Nr      zdpkg -l | grep {})field_indexrJ   r]   zdnf list | grep {}zyum list | grep {}zzypper info {} | grep Versionr   r   rJ   r   z + )
r   int_castr?   r   r[   r^   r   rf   r   )rX   pkg_namepkg_mgrgrep_versionr   r   retlsts           rR   get_linux_pkg_versionr   *  s    ')G% *

 +

 +

 6
L& 5l&;M&JKLK<(34C
**X
C
:
+C
{cRi
&&sC
 
&
&s
+C
3x;rT   c           
         / n[        5       nUS:X  aZ  1 SkSS1SS1SS1S.R                  [        5       0 5      nU H-  n[        X5      nUS:w  d  M  UR	                  SU SU 35        M/     US	;   a  [        U S
5      n [        R                  " U5      n[        U5      [        L a.  U H'  nUR	                  SUS    SUS    SUS    S35        M)     OUR	                  SUS    SUS    S35         SR                  U5      $ ! [         a5  n	UR	                  U5        UR	                  [        U	5      5         S n	A	NKS n	A	ff = f)Nr   >   libze1
level-zerointel-opencl-icdzintel-openclr   r   r   * z:	r<   cygwinzpowershell.exe "gwmi -Class Win32_PnpSignedDriver | where{$_.DeviceClass -eq \"DISPLAY\"            -and $_.Manufacturer -match \"Intel\"} | Select-Object -Property DeviceName,DriverVersion,DriverDate            | ConvertTo-Json"
DeviceName: DriverVersion (
DriverDate)re   )rE   r   r   r   appendr[   jsonloadsr>   list
ValueErrorr?   r   )
rX   r   platformpkgspkgvertxtobjoes
             rR   get_intel_gpu_driver_versionr   N  sw   
C~H7 
 
 
$ #')2
.% 	& C'
8Ce|

RuCu-.  &&
	**S/CCyD AJJQ|_-R/0B/C2aoEVVWX 
 

RO 45RL8I7J!LM 99S>  	JJsOJJs1v	s    AD D 
E+E  Ec                    / n[        5       nUS:X  a  [        U S5      nU(       ap   [        R                  " U5      nUR	                  S/ 5      n[        U[        5      (       a   U(       a  UR                  S U 5       5        O#UR                  S5        OUR                  S5        US;   a  [        U S5      nU(       aq   [        R                  " U5      n[        U[        5      (       a   U(       a  UR                  S U 5       5        O6UR                  S	UR	                  S
S5       35        OUR                  S5        SR                  U5      $ ! [        [        4 a5  nUR                  U5        UR                  [        U5      5         S nANS nAff = f! [         a5  nUR                  U5        UR                  [        U5      5         S nANS nAff = f)Nr   zxpu-smi discovery -jdevice_listc              3   2   #    U  H  nS US    3v   M     g7f)r   device_nameNrV   rp   devices     rR   rs   (get_intel_gpu_onboard.<locals>.<genexpr>  s     V+F=$9#:;+   r   r   zpowershell.exe "gwmi -Class Win32_PnpSignedDriver | where{$_.DeviceClass -eq \"DISPLAY\"            -and $_.Manufacturer -match \"Intel\"} | Select-Object -Property DeviceName | ConvertTo-Json"c              3   2   #    U  H  nS US    3v   M     g7f)r   r   NrV   r   s     rR   rs   r     s     MvF<$8#9:r   r   r   re   )rE   r[   r   r   r   
isinstancer   extendr   r   	TypeErrorr?   r   )rX   r   r   r   r   r   r   s          rR   get_intel_gpu_onboardr    sv   C~H7z+AB	#jjo!ggmR8k400[JJV+VVJJu%
 JJu&&m

 #jjoc4((SJJMMMJJCGGL%$@#ABC
 JJu99S>/ 	* #

3

3q6""#$  #

3

3q6""#s=   AE E A
F $F F#+FF
G%+GGc           	      6   [         (       a  [        [        S5      (       d  g[        R                  R	                  5       nUS:X  a  g[        U5       Vs/ s H(  nSU S[        R                  R                  U5       3PM*     nnSR                  U5      $ s  snf )Nxpur   r   z* [z] re   )r   r   r    r  device_countranger   r   )rX   r  idevicess       rR   get_intel_gpu_detectedr    s    ?'%"7"799))+Lq BG|ATATA#aS599221567AT   99Ws   /Bc           
         Su  pn[        5       S:X  a  U " S5      u  pnGO[        5       S:X  a  U " S5      u  pnUS:X  a  / n [        R                  " U5      n[        U5      [        L aT  U HM  nUR                  S5        UR                  UR                  5        VVs/ s H  u  pxU SU 3PM     snn5        MO     O:UR                  UR                  5        VVs/ s H  u  pxU SU 3PM     snn5         S	R                  U5      nO[        5       S
:X  a  U " S5      u  pnSn
US:X  a  Un
U
$ Un
U
$ s  snnf s  snnf ! [         a5  n	UR                  U5        UR                  [        U	5      5         S n	A	NS n	A	ff = f)N)r   r   r   r   lscpur<   zpowershell.exe "gwmi -Class Win32_Processor | Select-Object -Property Name,Manufacturer,Family,            Architecture,ProcessorType,DeviceID,CurrentClockSpeed,MaxClockSpeed,L2CacheSize,L2CacheSpeed,Revision            | ConvertTo-Json"r   z----------------------r   re   r   z"sysctl -n machdep.cpu.brand_stringNone)rE   r   r   r>   r   r   r  itemsr   r?   r   )rX   rN   rY   rQ   r   r   r   kvr   r   s              rR   get_cpu_infor     sc   LBS~ !'*	7	"!

 7C
#jjo9$ 

#;<

aggi#HiFQqcA3Ki#HI ! JJ#))+F+1#Rs+FG ))C.C	8	#!"FGH	Qw O O $IF #

3

3q6""#s=   AE  D42E  ?E  D:
0E  4E   
E?
+E::E?c                  J   [         R                  R                  S5      (       a  g[         R                  R                  S5      (       a  g[         R                  R                  S5      (       a  g[         R                  R                  S5      (       a  g[         R                  $ )Nr   r<   r   r   )sysr   rv   rV   rT   rR   rE   rE   "  sl    
||w''		 	 	)	)		 	 	*	*		 	 	*	*||rT   c                     [        U SS5      $ )Nzsw_vers -productVersionz(.*)r   r   s    rR   get_mac_versionr  /  s    $Z1JGTTrT   c                     [        U S5      n [        R                  " U5      nUS    SUS    SUS    S3nU$ ! [         a  nUS[	        U5       3-  n S nAU$ S nAff = f)	Nzpowershell.exe "gwmi -Class Win32_OperatingSystem | Select-Object -Property Caption,        OSArchitecture,Version | ConvertTo-Json"Captionr   Versionr   OSArchitecturer   re   )r[   r   r   r   r?   )rX   r   r   r   s       rR   get_windows_versionr  3  s    
	2C
jjoY 3y>"2!C8H4I3J!L J  CF8}Js   *: 
A AA c                     [        U SS5      $ )Nzlsb_release -azDescription:\t(.*)r   r   s    rR   get_lsb_versionr  A  s    $$&; rT   c                     [        U SS5      $ )Nzcat /etc/*-releasezPRETTY_NAME="(.*)"r   r   s    rR   check_release_filer   G  s    $(*? rT   c                 f   SSK Jn  [        5       nUS;   a  [        U 5      $ US:X  a%  [	        U 5      nUc  g SR                  X1" 5       5      $ US:X  a^  [        U 5      nUb  SR                  XA" 5       5      $ [        U 5      nUb  SR                  XA" 5       5      $ SR                  X!" 5       5      $ U$ )Nr   )machiner   r   zmacOS {} ({})r   z{} ({}))r   r"  rE   r  r  r   r  r   )rX   r"  r   r   descs        rR   get_osr$  M  s     ~H&&":..8!*-?%%gwy997z*##D')44 "*-##D')44')44 OrT   c                  *    SS K n U R                  5       $ Nr   r   r'  s    rR   get_python_platformr(  l  s    rT   c                  f    SS K n [        5       S:w  a  gSR                  U R                  5       5      $ )Nr   r   r   -)r   rE   r   libc_verr'  s    rR   get_libc_versionr,  r  s*    ~ 88H%%'((rT   c                 J  ^ Tc  [         [        -   [        -   [        -   m[        R
                  R                  S:X  a  SOSnS[        R                  S'   [        U [        R                  SSS/5      nUc  X#4$ S	R                  U4S
 jUR                  5        5       5      nX$4$ )zZReturn `pip list` output. Note: will also find conda-installed pytorch and numpy packages.   pip3pip1PIP_DISABLE_PIP_VERSION_CHECKz-mpipr   z--format=freezere   c              3   b   >^#    U  H#  m[        U4S  jT 5       5      (       d  M  Tv   M%     g7f)c              3   ,   >#    U  H	  oT;   v   M     g 7frn   rV   ro   s     rR   rs   -get_pip_packages.<locals>.<genexpr>.<genexpr>  s     0S($(ru   N)rw   rx   s    @rR   rs   #get_pip_packages.<locals>.<genexpr>  s$      )S0S(0S-S)s   /	/)PIP_PATTERNSr|   r}   r~   r  version_infomajorr   r   r[   
executabler   r   )rX   ry   r   rY   filtered_outs    `   rR   get_pip_packagesr<  z  s    /1OCoU,,22a7&UK25BJJ./ S^^Wf6GHC {99 ) L $$rT   c                      [         R                  R                  SS5      n U (       d   [         R                  R                  SS5      n U $ )NPYTORCH_CUDA_ALLOC_CONFr   PYTORCH_HIP_ALLOC_CONF)r   r   r   )	ca_configs    rR   get_cachingallocator_configrA    s5    

8"=IJJNN#;R@	rT   c                      [         (       ac  [        R                  R                  5       (       a@  [        R                  R	                  5         [
        R                  R                  SS5      n U $ g)NCUDA_MODULE_LOADINGr   r   )r   r    r   r   initr   r   r   )configs    rR   get_cuda_module_loading_configrF    sD    5::2244

 5r:rT   c                  t    [         (       a-  SS Kn [        U R                  R                  R
                  5      $ g)Nr   r   )r   torch.backends.xnnpackr?   backendsxnnpackenabled)r    s    rR   r   r     s(    %5>>))1122rT   c            
         [         n [        U 5      u  p[        (       Ga  [        R                  n[        [        R                  R                  5      n[        [        R                  R                  5       5      n[        R                  R                  n[        [        R                  R                  5       5      n[        R                  R                  5       (       aS  U S3S[        R                  R                   S3-   S[        U 5       S3-   S[        U 5       S3-   S[        U 5       3-   n[        [        R                  S5      (       a  [        R                  R                  c  S=n=pOmS n[        R                   R#                  5       R%                  S5      nU" US	5      n	U" US
5      n
Sn[        R                  R                  nOS=n=n=n=pgS=n=p[&        R                  R)                  SS5      n[+        U 5      n[-        S(0 SU_SU_SSR/                  U[&        R0                  R3                  5       S-   5      _S[5        5       _SU_SU_S[7        U 5      _S[9        5       _S[;        U 5      _S[=        U 5      _S[?        U 5      _SU_SU_SU	_SU
_SU_SU_SU_S [A        U 5      _S![C        5       _S"[E        U 5      _S#[G        U 5      _S$[I        U 5      _S%[K        5       _S&[M        5       _S'[O        U 5      _6$ ))a  
Collects environment information to aid in debugging.

The returned environment information contains details on torch version, is debug build
or not, cuda compiled version, gcc version, clang version, cmake version, operating
system, libc version, python version, python platform, CUDA availability, CUDA
runtime version, CUDA module loading config, GPU model and configuration, Nvidia
driver version, cuDNN version, pip version and versions of relevant pip and
conda packages, HIP runtime version, MIOpen runtime version,
Caching allocator config, XNNPACK availability and CPU information.

Returns:
    SystemEnv (namedtuple): A tuple containing various environment details
        and system information.
re   zXPU used to build PyTorch: zIntel GPU driver version:
zIntel GPU models onboard:
zIntel GPU models detected:
r   r   c                     U  Vs/ s H  o!U;   d  M
  UR                  S S5      S   PM!     nnU(       a  US   $ S$ s  snf )Nr]   r   r   )rsplit)cfgprefixs_lsts       rR   get_version_or_na'get_env_info.<locals>.get_version_or_na  sD    7:Js!k-q)"-sJ"&tAw1E1 Ks   	;;zHIP RuntimeMIOpenr   r   r   r   z{} ({}-bit runtime)r]   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r	   r
   r   r   r   r   rV   )(rS   r<  r   r    __version__r?   r   debugr   r   r  r   r  r  r   r   _C_show_configrf   r  replacer   r   r   maxsize
bit_lengthr(  r   rF  r   r   r   r$  r,  r   r   r   rA  r   r  )rX   r   pip_list_outputversion_strdebug_mode_strcuda_available_strcuda_version_strxpu_available_strr   r   r   rT  rP  sys_versionr   s                  rR   get_env_infore    sD     J#3J#? K''U]]001 !8!8!:; ==--		 6 6 8999!!##$%R(/0A0A/B"EF/0LZ0X/YY[\] 00Ej0Q/RRTUV 11G
1S0TU	V  u--1B1B1JRWW W#69O2 (('')//5C"3C"G%6sH%E"$#(==#4#4 chhhnh'9h<LNSSS2++%%dC0K'
3N !% -33//1A5
 ,- - / 6jA ;< 'z2 8
C (
3 + 2  0!"  6#$  %& %'( &)* *+, &'-. $J//0 (
312 (
334 "=!>56 2378 j)9 rT   au  
PyTorch version: {torch_version}
Is debug build: {is_debug_build}
CUDA used to build PyTorch: {cuda_compiled_version}
ROCM used to build PyTorch: {hip_compiled_version}

OS: {os}
GCC version: {gcc_version}
Clang version: {clang_version}
CMake version: {cmake_version}
Libc version: {libc_version}

Python version: {python_version}
Python platform: {python_platform}
Is CUDA available: {is_cuda_available}
CUDA runtime version: {cuda_runtime_version}
CUDA_MODULE_LOADING set to: {cuda_module_loading}
GPU models and configuration: {nvidia_gpu_models}
Nvidia driver version: {nvidia_driver_version}
cuDNN version: {cudnn_version}
Is XPU available: {is_xpu_available}
HIP runtime version: {hip_runtime_version}
MIOpen runtime version: {miopen_runtime_version}
Is XNNPACK available: {is_xnnpack_available}

CPU:
{cpu_info}

Versions of relevant libraries:
{pip_packages}
{conda_packages}
c                   ^
 SS jnSS jnSS jnSS jnS nU R                  5       m
U" U R                  5      T
S'   / SQnUS/-   n[        U
4S	 jU 5       5      n[        (       aJ  [        R
                  R                  5       (       d'  U(       a   U H  n	S
T
U	'   M
     U R                  c  ST
S'   U" T
5      m
U" T
5      m
U" T
S   5      T
S'   U" T
S   5      T
S'   T
S   (       a(  U" T
S   SR                  U R                  5      5      T
S'   T
S   (       a  U" T
S   S5      T
S'   U R                  T
S'   [        R                  " S0 T
D6$ )Nc                 J    U R                  5        H  nX   b  M
  XU'   M     U $ rn   keys)dctreplacementkeys      rR   replace_nones!pretty_str.<locals>.replace_nones%  s+    88:Cx#"H  
rT   c                 h    U R                  5        H  nX   SL a  XU'   M  X   SL d  M  X U'   M     U $ )NTFrh  )rj  truefalserl  s       rR   replace_bools!pretty_str.<locals>.replace_bools,  s;    88:Cx4CU" C	 
 
rT   c                 x    U R                  S5      nU Vs/ s H  o1U-   PM	     nnSR                  U5      $ s  snf )Nre   )rf   r   )texttaglinesrr   updated_liness        rR   prependpretty_str.<locals>.prepend4  s:    

4 056t6yy'' 7s   7c                 .    U b  [        U 5      S:X  a  U$ U $ r&  )r   )ru  rk  s     rR   replace_if_empty$pretty_str.<locals>.replace_if_empty9  s    D	QrT   c                 j    U b/  [        U R                  S5      5      S:  a  SR                  U 5      $ U $ )Nre   r]   z
{}
)r   rf   r   )strings    rR   maybe_start_on_next_line,pretty_str.<locals>.maybe_start_on_next_line>  s1    #fll4&8"9A"=??6**rT   r   )r   r   r   r   c              3   2   >#    U  H  nTU   S L v   M     g 7frn   rV   )rp   fieldmutable_dicts     rR   rs   pretty_str.<locals>.<genexpr>R  s      *1DUt#1Ds   zNo CUDAr  r   r   r   z[{}] z[conda] r   )zCould not collect)YesNo)z	[prepend])zNo relevant packagesrV   )_asdictr   allr   r    r   r   r   r   r   r   env_info_fmt)envinform  rr  ry  r|  r  dynamic_cuda_fieldsall_cuda_fieldsall_dynamic_cuda_fields_missingr  r  s             @rR   
pretty_strr  $  s   (

 ??$L )A!!)L$%

 *_,==O&) *1D* '# 	

''))+$E"+L %((04:L01 !.L !.L $4L4P#QL %5lCS6T%UL!" N#'.('..9L9L*M(
^$ $%)0)*J*
%&  '//L...rT   c                  (    [        [        5       5      $ )a  
Returns a pretty string of environment information.

This function retrieves environment information by calling the `get_env_info` function
and then formats the information into a human-readable string. The retrieved environment
information is listed in the document of `get_env_info`.
This function is used in `python collect_env.py` that should be executed when reporting a bug.

Returns:
    str: A pretty string of the environment information.
)r  re  rV   rT   rR   get_pretty_env_infor  w  s     ln%%rT   c                  R   [        S5        [        5       n [        U 5        [        (       Gav  [        [        S5      (       Ga_  [        [        R
                  S5      (       Ga>  [        R
                  R                  R                  n[        R                  S:X  Ga  [        R                  R                  U5      (       a  [        R                  " U5       Vs/ s H"  n[        R                  R                  X5      PM$     nn[        U[        R                  R                   S9n[        R                  R!                  U5      n["        R"                  R%                  U5      R'                  S5      nSR)                  XF5      S-   n[        U[        R*                  S	9  g g g g g g s  snf )
Nz%Collecting environment information...utils_crash_handlerr   )rl  z%Y-%m-%d %H:%M:%Sz.
*** Detected a minidump at {} created on {}, zKif this is related to your bug please include it when you file a report ***)file)printr  r   r   r    r  r  DEFAULT_MINIDUMP_DIRr  r   r   r   r   listdirr   maxgetctimedatetimefromtimestampstrftimer   r:   )rP   minidump_dirdumpdumpslatestctimecreation_timemsgs           rR   mainr    sH   	
12 "F	&M 	E7##EKK!122{{11FF<<7"rww~~l'C'C=?ZZ=U=UT\0=U   BGG$4$45FGG$$V,E$--;;EBKK#M BHH ``  #CJJ' (D" 3 $ 	s   )F$__main__rn   )>r  r   rF   r   r^   r@   r  collectionsr   typingr   r   r    r   ImportError	NameErrorAttributeErrorOSErrorr   r|   r}   r~   r{   r7  rS   r[   rc   rg   r   r   r   r   r   r   r   r   r   r   r   r   r  r  r  rE   r  r  r  r   r$  r(  r,  r<  rA  rF  r   re  rI   r  r  r  r  __name__rV   rT   rR   <module>r     sm      	 	  
 "  O
 	@$0+"OSQ'4X"?J$!H.b$NtD
U>)%.Up> 
EG? DP/f&(: zF ] 	Y8 Os   C C*)C*