


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       (		__A			)						->					Union[str, Any]:



       '''simple docstring'''





       return EnvironmentCommand()




class     lowercase__  (					__SCREAMING_SNAKE_CASE		):






  @staticmethod
  def 			_UpperCAmelCase  (					_lowercase      :					ArgumentParser ):




         """simple docstring"""







         UpperCAmelCase__										=     parser.add_parser("env" )
         download_parser.set_defaults(func=_lowercase )






  def 			_UpperCAmelCase  (					self      :					Union[str, Any] ):




         """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(_lowercase ) )

         return info






  @staticmethod
  def 			_UpperCAmelCase  (					_lowercase      :					Dict ):




         """simple docstring"""







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









from __future__ import annotations





def __UpperCAmelCase       (		__A ,						__A ,						__A ,						)						->					tuple:



       '''simple docstring'''





       if (electron_conc, hole_conc, intrinsic_conc).count(0			) != 1:
              raise ValueError("You cannot supply more or less than 2 values"			)
       elif electron_conc < 0:
              raise ValueError("Electron concentration cannot be negative in a semiconductor"			)
       elif hole_conc < 0:
              raise ValueError("Hole concentration cannot be negative in a semiconductor"			)
       elif intrinsic_conc < 0:
              raise ValueError(
                  "Intrinsic concentration cannot be negative in a semiconductor"			)
       elif electron_conc == 0:
              return (
                  "electron_conc",
                  intrinsic_conc**2 / hole_conc,
              )
       elif hole_conc == 0:
              return (
                  "hole_conc",
                  intrinsic_conc**2 / electron_conc,
              )
       elif intrinsic_conc == 0:
              return (
                  "intrinsic_conc",
                  (electron_conc * hole_conc) ** 0.5,
              )
       else:
              return (-1, -1)


if __name__ == "__main__":
    import doctest

    doctest.testmod()





