
'''simple docstring'''





import unittest

import numpy as np

from transformers.testing_utils import require_flax, require_tf, require_torch
from transformers.utils import (
    expand_dims,
    flatten_dict,
    is_flax_available,
    is_tf_available,
    is_torch_available,
    reshape,
    squeeze,
    transpose,
)


if is_flax_available():
		import jax.numpy as jnp

if is_tf_available():
		import tensorflow as tf

if is_torch_available():
		import torch







class        lowerCAmelCase__      (   unittest.TestCase	):

						def  A_				(			self				)					->      Tuple:


								'''simple docstring'''

								_UpperCamelCase						    =	{
								    """task_specific_params""": {
								        """summarization""": {"""length_penalty""": 1.0, """max_length""": 1_28, """min_length""": 12, """num_beams""": 4},
								        """summarization_cnn""": {"""length_penalty""": 2.0, """max_length""": 1_42, """min_length""": 56, """num_beams""": 4},
								        """summarization_xsum""": {"""length_penalty""": 1.0, """max_length""": 62, """min_length""": 11, """num_beams""": 6},
								    }
								}
								_UpperCamelCase						    =	{
								    """task_specific_params.summarization.length_penalty""": 1.0,
								    """task_specific_params.summarization.max_length""": 1_28,
								    """task_specific_params.summarization.min_length""": 12,
								    """task_specific_params.summarization.num_beams""": 4,
								    """task_specific_params.summarization_cnn.length_penalty""": 2.0,
								    """task_specific_params.summarization_cnn.max_length""": 1_42,
								    """task_specific_params.summarization_cnn.min_length""": 56,
								    """task_specific_params.summarization_cnn.num_beams""": 4,
								    """task_specific_params.summarization_xsum.length_penalty""": 1.0,
								    """task_specific_params.summarization_xsum.max_length""": 62,
								    """task_specific_params.summarization_xsum.min_length""": 11,
								    """task_specific_params.summarization_xsum.num_beams""": 6,
								}

								self.assertEqual(flatten_dict(a				)       ,							a				)

						def  A_				(			self				)					->      str:


								'''simple docstring'''

								_UpperCamelCase						    =	np.random.randn(3       ,							4				)
								self.assertTrue(np.allclose(transpose(a				)       ,							x.transpose()				)				)

								_UpperCamelCase						    =	np.random.randn(3       ,							4       ,							5				)
								self.assertTrue(np.allclose(transpose(a       ,							axes=(1, 2, 0)				)       ,							x.transpose((1, 2, 0)				)				)				)

						@require_torch
						def  A_				(			self				)					->      Any:


								'''simple docstring'''

								_UpperCamelCase						    =	np.random.randn(3       ,							4				)
								_UpperCamelCase						    =	torch.tensor(a				)
								self.assertTrue(np.allclose(transpose(a				)       ,							transpose(a				).numpy()				)				)

								_UpperCamelCase						    =	np.random.randn(3       ,							4       ,							5				)
								_UpperCamelCase						    =	torch.tensor(a				)
								self.assertTrue(np.allclose(transpose(a       ,							axes=(1, 2, 0)				)       ,							transpose(a       ,							axes=(1, 2, 0)				).numpy()				)				)

						@require_tf
						def  A_				(			self				)					->      int:


								'''simple docstring'''

								_UpperCamelCase						    =	np.random.randn(3       ,							4				)
								_UpperCamelCase						    =	tf.constant(a				)
								self.assertTrue(np.allclose(transpose(a				)       ,							transpose(a				).numpy()				)				)

								_UpperCamelCase						    =	np.random.randn(3       ,							4       ,							5				)
								_UpperCamelCase						    =	tf.constant(a				)
								self.assertTrue(np.allclose(transpose(a       ,							axes=(1, 2, 0)				)       ,							transpose(a       ,							axes=(1, 2, 0)				).numpy()				)				)

						@require_flax
						def  A_				(			self				)					->      Dict:


								'''simple docstring'''

								_UpperCamelCase						    =	np.random.randn(3       ,							4				)
								_UpperCamelCase						    =	jnp.array(a				)
								self.assertTrue(np.allclose(transpose(a				)       ,							np.asarray(transpose(a				)				)				)				)

								_UpperCamelCase						    =	np.random.randn(3       ,							4       ,							5				)
								_UpperCamelCase						    =	jnp.array(a				)
								self.assertTrue(np.allclose(transpose(a       ,							axes=(1, 2, 0)				)       ,							np.asarray(transpose(a       ,							axes=(1, 2, 0)				)				)				)				)

						def  A_				(			self				)					->      str:


								'''simple docstring'''

								_UpperCamelCase						    =	np.random.randn(3       ,							4				)
								self.assertTrue(np.allclose(reshape(a       ,							(4, 3)				)       ,							np.reshape(a       ,							(4, 3)				)				)				)

								_UpperCamelCase						    =	np.random.randn(3       ,							4       ,							5				)
								self.assertTrue(np.allclose(reshape(a       ,							(12, 5)				)       ,							np.reshape(a       ,							(12, 5)				)				)				)

						@require_torch
						def  A_				(			self				)					->      List[Any]:


								'''simple docstring'''

								_UpperCamelCase						    =	np.random.randn(3       ,							4				)
								_UpperCamelCase						    =	torch.tensor(a				)
								self.assertTrue(np.allclose(reshape(a       ,							(4, 3)				)       ,							reshape(a       ,							(4, 3)				).numpy()				)				)

								_UpperCamelCase						    =	np.random.randn(3       ,							4       ,							5				)
								_UpperCamelCase						    =	torch.tensor(a				)
								self.assertTrue(np.allclose(reshape(a       ,							(12, 5)				)       ,							reshape(a       ,							(12, 5)				).numpy()				)				)

						@require_tf
						def  A_				(			self				)					->      Dict:


								'''simple docstring'''

								_UpperCamelCase						    =	np.random.randn(3       ,							4				)
								_UpperCamelCase						    =	tf.constant(a				)
								self.assertTrue(np.allclose(reshape(a       ,							(4, 3)				)       ,							reshape(a       ,							(4, 3)				).numpy()				)				)

								_UpperCamelCase						    =	np.random.randn(3       ,							4       ,							5				)
								_UpperCamelCase						    =	tf.constant(a				)
								self.assertTrue(np.allclose(reshape(a       ,							(12, 5)				)       ,							reshape(a       ,							(12, 5)				).numpy()				)				)

						@require_flax
						def  A_				(			self				)					->      Any:


								'''simple docstring'''

								_UpperCamelCase						    =	np.random.randn(3       ,							4				)
								_UpperCamelCase						    =	jnp.array(a				)
								self.assertTrue(np.allclose(reshape(a       ,							(4, 3)				)       ,							np.asarray(reshape(a       ,							(4, 3)				)				)				)				)

								_UpperCamelCase						    =	np.random.randn(3       ,							4       ,							5				)
								_UpperCamelCase						    =	jnp.array(a				)
								self.assertTrue(np.allclose(reshape(a       ,							(12, 5)				)       ,							np.asarray(reshape(a       ,							(12, 5)				)				)				)				)

						def  A_				(			self				)					->      str:


								'''simple docstring'''

								_UpperCamelCase						    =	np.random.randn(1       ,							3       ,							4				)
								self.assertTrue(np.allclose(squeeze(a				)       ,							np.squeeze(a				)				)				)

								_UpperCamelCase						    =	np.random.randn(1       ,							4       ,							1       ,							5				)
								self.assertTrue(np.allclose(squeeze(a       ,							axis=2				)       ,							np.squeeze(a       ,							axis=2				)				)				)

						@require_torch
						def  A_				(			self				)					->      Union[str, Any]:


								'''simple docstring'''

								_UpperCamelCase						    =	np.random.randn(1       ,							3       ,							4				)
								_UpperCamelCase						    =	torch.tensor(a				)
								self.assertTrue(np.allclose(squeeze(a				)       ,							squeeze(a				).numpy()				)				)

								_UpperCamelCase						    =	np.random.randn(1       ,							4       ,							1       ,							5				)
								_UpperCamelCase						    =	torch.tensor(a				)
								self.assertTrue(np.allclose(squeeze(a       ,							axis=2				)       ,							squeeze(a       ,							axis=2				).numpy()				)				)

						@require_tf
						def  A_				(			self				)					->      Tuple:


								'''simple docstring'''

								_UpperCamelCase						    =	np.random.randn(1       ,							3       ,							4				)
								_UpperCamelCase						    =	tf.constant(a				)
								self.assertTrue(np.allclose(squeeze(a				)       ,							squeeze(a				).numpy()				)				)

								_UpperCamelCase						    =	np.random.randn(1       ,							4       ,							1       ,							5				)
								_UpperCamelCase						    =	tf.constant(a				)
								self.assertTrue(np.allclose(squeeze(a       ,							axis=2				)       ,							squeeze(a       ,							axis=2				).numpy()				)				)

						@require_flax
						def  A_				(			self				)					->      Dict:


								'''simple docstring'''

								_UpperCamelCase						    =	np.random.randn(1       ,							3       ,							4				)
								_UpperCamelCase						    =	jnp.array(a				)
								self.assertTrue(np.allclose(squeeze(a				)       ,							np.asarray(squeeze(a				)				)				)				)

								_UpperCamelCase						    =	np.random.randn(1       ,							4       ,							1       ,							5				)
								_UpperCamelCase						    =	jnp.array(a				)
								self.assertTrue(np.allclose(squeeze(a       ,							axis=2				)       ,							np.asarray(squeeze(a       ,							axis=2				)				)				)				)

						def  A_				(			self				)					->      Optional[Any]:


								'''simple docstring'''

								_UpperCamelCase						    =	np.random.randn(3       ,							4				)
								self.assertTrue(np.allclose(expand_dims(a       ,							axis=1				)       ,							np.expand_dims(a       ,							axis=1				)				)				)

						@require_torch
						def  A_				(			self				)					->      List[str]:


								'''simple docstring'''

								_UpperCamelCase						    =	np.random.randn(3       ,							4				)
								_UpperCamelCase						    =	torch.tensor(a				)
								self.assertTrue(np.allclose(expand_dims(a       ,							axis=1				)       ,							expand_dims(a       ,							axis=1				).numpy()				)				)

						@require_tf
						def  A_				(			self				)					->      Optional[Any]:


								'''simple docstring'''

								_UpperCamelCase						    =	np.random.randn(3       ,							4				)
								_UpperCamelCase						    =	tf.constant(a				)
								self.assertTrue(np.allclose(expand_dims(a       ,							axis=1				)       ,							expand_dims(a       ,							axis=1				).numpy()				)				)







						@require_flax
						def  A_				(			self				)					->      Tuple:


								'''simple docstring'''

								_UpperCamelCase						    =	np.random.randn(3       ,							4				)
								_UpperCamelCase						    =	jnp.array(a				)
								self.assertTrue(np.allclose(expand_dims(a       ,							axis=1				)       ,							np.asarray(expand_dims(a       ,							axis=1				)				)				)				)





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 							__A(lowerCAmelCase )		->				Optional[int]:

		"""simple docstring"""






		return EnvironmentCommand()







class        lowerCAmelCase__      (   __lowercase	):

						@staticmethod
						def  A_				(			a				)					->      List[str]:


								'''simple docstring'''

								_UpperCamelCase						    =	parser.add_parser("""env"""				)
								download_parser.set_defaults(func=a				)

						def  A_				(			self				)					->      List[str]:


								'''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(a				)				)

								return info







						@staticmethod
						def  A_				(			a				)					->      Dict:


								'''simple docstring'''

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



