

import platform
from argparse import ArgumentParser

import huggingface_hub

from .. import __version__ as version
from ..utils import is_accelerate_available, is_torch_available, is_transformers_available, is_xformers_available
from . import BaseDiffusersCLICommand



def       __lowerCAmelCase      (						A    ):
	return EnvironmentCommand()




class 						__UpperCamelCase    (					lowercase						):




	@staticmethod
	def       __A					(		lowerCAmelCase	:						ArgumentParser							):


		'''simple docstring'''







		UpperCAmelCase_       				=			parser.add_parser("env"							)
		download_parser.set_defaults(func=lowerCAmelCase							)




	def       __A					(		self	:						Tuple							):


		'''simple docstring'''







		UpperCAmelCase_       				=			huggingface_hub.__version__

		UpperCAmelCase_       				=			"not installed"
		UpperCAmelCase_       				=			"NA"
		if is_torch_available():
			import torch

			UpperCAmelCase_       				=			torch.__version__
			UpperCAmelCase_       				=			torch.cuda.is_available()

		UpperCAmelCase_       				=			"not installed"
		if is_transformers_available():
			import transformers

			UpperCAmelCase_       				=			transformers.__version__

		UpperCAmelCase_       				=			"not installed"
		if is_accelerate_available():
			import accelerate

			UpperCAmelCase_       				=			accelerate.__version__

		UpperCAmelCase_       				=			"not installed"
		if is_xformers_available():
			import xformers

			UpperCAmelCase_       				=			xformers.__version__

		UpperCAmelCase_       				=			{
		    "`diffusers` version": version,
		    "Platform": platform.platform(),
		    "Python version": platform.python_version(),
		    "PyTorch version (GPU?)": F"{pt_version} ({pt_cuda_available})",
		    "Huggingface_hub version": hub_version,
		    "Transformers version": transformers_version,
		    "Accelerate version": accelerate_version,
		    "xFormers version": xformers_version,
		    "Using GPU in script?": "<fill in>",
		    "Using distributed or parallel set-up in script?": "<fill in>",
		}

		print("\nCopy-and-paste the text below in your GitHub issue and FILL OUT the two last points.\n"							)
		print(self.format_dict(lowerCAmelCase							)							)

		return info




	@staticmethod
	def       __A					(		lowerCAmelCase	:						Dict							):


		'''simple docstring'''







		return "\n".join([F"- {prop}: {val}" for prop, val in d.items()]							) + "\n"


from .imports import is_tqdm_available


if is_tqdm_available():
				from tqdm.auto import tqdm as _tqdm

from ..state import PartialState



def       __lowerCAmelCase      (						A = True       ,     *A       ,     **A    ):
	if not is_tqdm_available():
		raise ImportError("Accelerate's `tqdm` module requires `tqdm` to be installed. Please run `pip install tqdm`."    )
	UpperCAmelCase_       				=			False
	if main_process_only:
		UpperCAmelCase_       				=			PartialState().local_process_index == 0
	return _tqdm(*A       ,     **A       ,     disable=A    )