"""simple docstring"""


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     __UpperCAmelCase					(			lowercase		):







  """simple docstring"""
  return EnvironmentCommand()


class        a				(		a__   ):


    @staticmethod
    def      lowerCAmelCase_  (					__lowerCAmelCase	:  List[Any]					):
      _UpperCAmelCase						 =      parser.add_parser("""env"""					)
      download_parser.set_defaults(func=lowerCamelCase_					)


    def      lowerCAmelCase_  (					self	:  str					):
      _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      lowerCAmelCase_  (					__lowerCAmelCase	:  int					):
      return "\n".join([f'''- {prop}: {val}''' for prop, val in d.items()]					) + "\n"

"""simple docstring"""


def     __UpperCAmelCase					(			lowercase		):







  """simple docstring"""
  _UpperCAmelCase						 =      abs(lowercase		)
  _UpperCAmelCase						 =      0
  while n > 0:
    res += n % 10
    n //= 10
  return res






def     __UpperCAmelCase					(			lowercase		):







  """simple docstring"""
  _UpperCAmelCase						 =      abs(lowercase		)
  return n if n < 10 else n % 10 + sum_of_digits(n // 10		)






def     __UpperCAmelCase					(			lowercase		):







  """simple docstring"""
  return sum(int(lowercase		) for c in str(abs(lowercase		)		)		)






def     __UpperCAmelCase					(			):







  """simple docstring"""
  from collections.abc import Callable
  from timeit import timeit

  def benchmark_a_function(lowercase   ,lowercase		) -> None:
    _UpperCAmelCase						 =      f'''{func.__name__}({value})'''
    _UpperCAmelCase						 =      timeit(f'''__main__.{call}'''   ,setup="""import __main__"""		)
    print(f'''{call:56} = {func(lowercase		)} -- {timing:.4f} seconds'''		)

  for value in (26_21_44, 11_25_89_99_06_84_26_24, 1_26_76_50_60_02_28_22_94_01_49_67_03_20_53_76):
    for func in (sum_of_digits, sum_of_digits_recursion, sum_of_digits_compact):
      benchmark_a_function(lowercase   ,lowercase		)
    print()


if __name__ == "__main__":
    import doctest

    doctest.testmod()
    benchmark()
