
    sg|                         d dl Zd dlZd dlZd dlmZ d dlZddlmZ	 ddl
mZmZmZmZmZmZ ddlmZ d Zd	 Z G d
 de      Zy)    N)ArgumentParser   )__version__)is_accelerate_availableis_flax_availableis_safetensors_availableis_tf_availableis_torch_availableis_torch_npu_available   )BaseTransformersCLICommandc                     t               S N)EnvironmentCommand)_s    L/var/www/html/venv/lib/python3.12/site-packages/transformers/commands/env.pyinfo_command_factoryr   "   s        c                 ,    t        | j                        S r   )r   accelerate_config_file)argss    r   download_command_factoryr   &   s    d99::r   c                   @    e Zd Zedefd       ZddZd Zed        Zy)r   parserc                     | j                  d      }|j                  t               |j                  dd d       |j                  t               y )Nenv)funcz--accelerate-config_filezQThe accelerate config file to use for the default values in the launching script.)defaulthelp)
add_parserset_defaultsr   add_argumentr   )r   download_parsers     r   register_subcommandz&EnvironmentCommand.register_subcommand+   sT     ++E2$$*>$?$$&d 	% 	

 	$$*B$Cr   Nc                     || _         y r   )_accelerate_config_file)selfr   r   s      r   __init__zEnvironmentCommand.__init__6   s
    '=$r   c                 J   d}t               rdd l}|j                  }n2t        j                  j                  d      dd l}|j                   d}d}dx}}t               rdd l}ddlm	}m
} |j                  }| j                  t        j                  j                  |      r  || j                        j                         }t!        |t"              r8dj%                  |j'                         D 	
cg c]  \  }	}
d|	 d	|
  c}
}	      nd
| }d}d}t)               r4dd l}|j                  }|j,                  j/                         }t1               }d}d}t3               r+dd l}|j                  }	 |j6                  j9                         }d}d}d}d}tC               r^dd l"}dd l#}dd l$}|j                  }|j                  }|j                  }|jJ                  jL                  jO                         jP                  }tR        tQ        jP                         tQ        jT                         tV        j                  | | | | d| d| d| d| d| d| | dd}t)               rb|r#d|d<   j,                  jY                         |d<   n=r;d|d<   jZ                  jY                         |d<   |jR                  j\                  |d<   t_        d       t_        | ja                  |             |S c c}
}	w # t:        $ r( t=        |j>                  jA                  d            }Y w xY w)Nznot installedr   safetensorsz3 but is ignored because of PyTorch version too old.z	not found)default_config_fileload_config_from_file
z	- : 	NAGPUz ()z	<fill in>)z`transformers` versionPlatformzPython versionzHuggingface_hub versionzSafetensors versionzAccelerate versionzAccelerate configzPyTorch version (GPU?)zTensorflow version (GPU?)zFlax version (CPU?/GPU?/TPU?)zJax versionzJaxLib versionz/Using distributed or parallel set-up in script?zUsing GPU in script?zGPU typezUsing NPU in script?zNPU typezCANN versionzV
Copy-and-paste the text below in your GitHub issue and FILL OUT the two last points.
)1r   r*   r   	importlibutil	find_specr   
accelerateaccelerate.commands.configr+   r,   r&   ospathisfileto_dict
isinstancedictjoinitemsr
   torchcudais_availabler   r	   
tensorflowtestis_gpu_availableAttributeErrorboolconfiglist_physical_devicesr   flaxjaxjaxliblib
xla_bridgeget_backendplatformversionpython_versionhuggingface_hubget_device_namenpucannprintformat_dict)r'   safetensors_versionr*   accelerate_versionaccelerate_configaccelerate_config_strr7   r+   r,   propval
pt_versionpt_cuda_availablerA   pt_npu_available
tf_versiontf_cuda_availabletfflax_versionjax_versionjaxlib_versionjax_backendrK   rL   rM   infos                             r   runzEnvironmentCommand.run9   s   -#%"-"9"9^^%%m4@%0%<%<$==p"q,4??1"$]!+!7!7++7277>>J];^$9$:V:V$W$_$_$a! /6 		ARAXAXAZ[ID#T$r#/[\+,- " %
 **J %

 7 7 957$
 #JQ$&GG$<$<$>!
 '%(++L//K#//N'',,88:CCK '. ))+&557'6'B'B&9%:%7$8$9#:)3B7H6I&K,6<r:K9LA)N0<~R}A-N)]!/ 0?J
  /:+,#(::#=#=#?Z !/:+,#(99#<#<#>Z ',}}'9'9^$hidt$%I \. " Q$()H)H)O$P!Qs   1K+
1K1 1-L"!L"c           
          dj                  | j                         D cg c]  \  }}d| d|  c}}      dz   S c c}}w )Nr-   z- r.   )r?   r@   )dr^   r_   s      r   rY   zEnvironmentCommand.format_dict   s;    yyaggiHsBtfBse,HIDPPHs   <
)returnN)	__name__
__module____qualname__staticmethodr   r$   r(   rk   rY    r   r   r   r   *   s@    DN D D>[z Q Qr   r   )importlib.utilr4   r9   rQ   argparser   rT    r   rR   utilsr   r   r   r	   r
   r   r   r   r   r   rs   r   r   <module>rx      sC     	  #  %  ) ;nQ3 nQr   