






import random
import unittest

import numpy as np

from diffusers import (
    DPMSolverMultistepScheduler,
    EulerAncestralDiscreteScheduler,
    EulerDiscreteScheduler,
    LMSDiscreteScheduler,
    OnnxStableDiffusionImgaImgPipeline,
    PNDMScheduler,
)
from diffusers.utils import floats_tensor
from diffusers.utils.testing_utils import (
    is_onnx_available,
    load_image,
    nightly,
    require_onnxruntime,
    require_torch_gpu,
)

from ..test_pipelines_onnx_common import OnnxPipelineTesterMixin


if is_onnx_available():
   import onnxruntime as ort



class 				_A			(     UpperCamelCase					,					unittest.TestCase				):
    """simple docstring"""

    lowerCamelCase	:							List[Any]				= 'hf-internal-testing/tiny-random-OnnxStableDiffusionPipeline'



    def _a							(				self      :     Optional[int] ,     __SCREAMING_SNAKE_CASE      :     str=0      )      ->							Any:
           __UpperCAmelCase     				=floats_tensor((1, 3, 128, 128) ,     rng=random.Random(__SCREAMING_SNAKE_CASE      )      )
           __UpperCAmelCase     				=np.random.RandomState(__SCREAMING_SNAKE_CASE      )
           __UpperCAmelCase     				={
               """prompt""": """A painting of a squirrel eating a burger""",
               """image""": image,
               """generator""": generator,
               """num_inference_steps""": 3,
               """strength""": 0.75,
               """guidance_scale""": 7.5,
               """output_type""": """numpy""",
           }
           return inputs



    def _a							(				self      :     Optional[Any]      )      ->							int:
           __UpperCAmelCase     				=OnnxStableDiffusionImgaImgPipeline.from_pretrained(self.hub_checkpoint ,     provider="""CPUExecutionProvider"""      )
           pipe.set_progress_bar_config(disable=__SCREAMING_SNAKE_CASE      )

           __UpperCAmelCase     				=self.get_dummy_inputs()
           __UpperCAmelCase     				=pipe(**__SCREAMING_SNAKE_CASE      ).images
           __UpperCAmelCase     				=image[0, -3:, -3:, -1].flatten()

           assert image.shape == (1, 128, 128, 3)
           __UpperCAmelCase     				=np.array([0.69_643, 0.58_484, 0.50_314, 0.58_760, 0.55_368, 0.59_643, 0.51_529, 0.41_217, 0.49_087]      )
           assert np.abs(image_slice - expected_slice      ).max() < 1e-1



    def _a							(				self      :     Union[str, Any]      )      ->							Union[str, Any]:
           __UpperCAmelCase     				=OnnxStableDiffusionImgaImgPipeline.from_pretrained(self.hub_checkpoint ,     provider="""CPUExecutionProvider"""      )
           __UpperCAmelCase     				=PNDMScheduler.from_config(pipe.scheduler.config ,     skip_prk_steps=__SCREAMING_SNAKE_CASE      )
           pipe.set_progress_bar_config(disable=__SCREAMING_SNAKE_CASE      )

           __UpperCAmelCase     				=self.get_dummy_inputs()
           __UpperCAmelCase     				=pipe(**__SCREAMING_SNAKE_CASE      ).images
           __UpperCAmelCase     				=image[0, -3:, -3:, -1]

           assert image.shape == (1, 128, 128, 3)
           __UpperCAmelCase     				=np.array([0.61_737, 0.54_642, 0.53_183, 0.54_465, 0.52_742, 0.60_525, 0.49_969, 0.40_655, 0.48_154]      )

           assert np.abs(image_slice.flatten() - expected_slice      ).max() < 1e-1



    def _a							(				self      :     Optional[Any]      )      ->							Dict:
           __UpperCAmelCase     				=OnnxStableDiffusionImgaImgPipeline.from_pretrained(self.hub_checkpoint ,     provider="""CPUExecutionProvider"""      )
           __UpperCAmelCase     				=LMSDiscreteScheduler.from_config(pipe.scheduler.config      )
           pipe.set_progress_bar_config(disable=__SCREAMING_SNAKE_CASE      )

           # warmup pass to apply optimizations
           __UpperCAmelCase     				=pipe(**self.get_dummy_inputs()      )

           __UpperCAmelCase     				=self.get_dummy_inputs()
           __UpperCAmelCase     				=pipe(**__SCREAMING_SNAKE_CASE      ).images
           __UpperCAmelCase     				=image[0, -3:, -3:, -1]

           assert image.shape == (1, 128, 128, 3)
           __UpperCAmelCase     				=np.array([0.52_761, 0.59_977, 0.49_033, 0.49_619, 0.54_282, 0.50_311, 0.47_600, 0.40_918, 0.45_203]      )

           assert np.abs(image_slice.flatten() - expected_slice      ).max() < 1e-1



    def _a							(				self      :     List[Any]      )      ->							List[str]:
           __UpperCAmelCase     				=OnnxStableDiffusionImgaImgPipeline.from_pretrained(self.hub_checkpoint ,     provider="""CPUExecutionProvider"""      )
           __UpperCAmelCase     				=EulerDiscreteScheduler.from_config(pipe.scheduler.config      )
           pipe.set_progress_bar_config(disable=__SCREAMING_SNAKE_CASE      )

           __UpperCAmelCase     				=self.get_dummy_inputs()
           __UpperCAmelCase     				=pipe(**__SCREAMING_SNAKE_CASE      ).images
           __UpperCAmelCase     				=image[0, -3:, -3:, -1]

           assert image.shape == (1, 128, 128, 3)
           __UpperCAmelCase     				=np.array([0.52_911, 0.60_004, 0.49_229, 0.49_805, 0.54_502, 0.50_680, 0.47_777, 0.41_028, 0.45_304]      )

           assert np.abs(image_slice.flatten() - expected_slice      ).max() < 1e-1



    def _a							(				self      :     Union[str, Any]      )      ->							Optional[Any]:
           __UpperCAmelCase     				=OnnxStableDiffusionImgaImgPipeline.from_pretrained(self.hub_checkpoint ,     provider="""CPUExecutionProvider"""      )
           __UpperCAmelCase     				=EulerAncestralDiscreteScheduler.from_config(pipe.scheduler.config      )
           pipe.set_progress_bar_config(disable=__SCREAMING_SNAKE_CASE      )

           __UpperCAmelCase     				=self.get_dummy_inputs()
           __UpperCAmelCase     				=pipe(**__SCREAMING_SNAKE_CASE      ).images
           __UpperCAmelCase     				=image[0, -3:, -3:, -1]

           assert image.shape == (1, 128, 128, 3)
           __UpperCAmelCase     				=np.array([0.52_911, 0.60_004, 0.49_229, 0.49_805, 0.54_502, 0.50_680, 0.47_777, 0.41_028, 0.45_304]      )

           assert np.abs(image_slice.flatten() - expected_slice      ).max() < 1e-1



    def _a							(				self      :     Union[str, Any]      )      ->							Dict:
           __UpperCAmelCase     				=OnnxStableDiffusionImgaImgPipeline.from_pretrained(self.hub_checkpoint ,     provider="""CPUExecutionProvider"""      )
           __UpperCAmelCase     				=DPMSolverMultistepScheduler.from_config(pipe.scheduler.config      )
           pipe.set_progress_bar_config(disable=__SCREAMING_SNAKE_CASE      )

           __UpperCAmelCase     				=self.get_dummy_inputs()
           __UpperCAmelCase     				=pipe(**__SCREAMING_SNAKE_CASE      ).images
           __UpperCAmelCase     				=image[0, -3:, -3:, -1]

           assert image.shape == (1, 128, 128, 3)
           __UpperCAmelCase     				=np.array([0.65_331, 0.58_277, 0.48_204, 0.56_059, 0.53_665, 0.56_235, 0.50_969, 0.40_009, 0.46_552]      )

           assert np.abs(image_slice.flatten() - expected_slice      ).max() < 1e-1




@nightly
@require_onnxruntime
@require_torch_gpu
class 				_A			(     unittest.TestCase				):
    """simple docstring"""

    @property
    def _a							(				self      :     List[str]      )      ->							Optional[int]:
           return (
               "CUDAExecutionProvider",
               {
                   "gpu_mem_limit": "15000000000",  # 15GB
                   "arena_extend_strategy": "kSameAsRequested",
               },
           )



    @property
    def _a							(				self      :     Dict      )      ->							int:
           __UpperCAmelCase     				=ort.SessionOptions()
           __UpperCAmelCase     				=False
           return options



    def _a							(				self      :     Dict      )      ->							Any:
           __UpperCAmelCase     				=load_image(
               """https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main"""
               """/img2img/sketch-mountains-input.jpg"""      )
           __UpperCAmelCase     				=init_image.resize((768, 512)      )
           # using the PNDM scheduler by default
           __UpperCAmelCase     				=OnnxStableDiffusionImgaImgPipeline.from_pretrained(
               """CompVis/stable-diffusion-v1-4""" ,     revision="""onnx""" ,     safety_checker=__SCREAMING_SNAKE_CASE ,     feature_extractor=__SCREAMING_SNAKE_CASE ,     provider=self.gpu_provider ,     sess_options=self.gpu_options ,     )
           pipe.set_progress_bar_config(disable=__SCREAMING_SNAKE_CASE      )

           __UpperCAmelCase     				="""A fantasy landscape, trending on artstation"""

           __UpperCAmelCase     				=np.random.RandomState(0      )
           __UpperCAmelCase     				=pipe(
               prompt=__SCREAMING_SNAKE_CASE ,     image=__SCREAMING_SNAKE_CASE ,     strength=0.75 ,     guidance_scale=7.5 ,     num_inference_steps=10 ,     generator=__SCREAMING_SNAKE_CASE ,     output_type="""np""" ,     )
           __UpperCAmelCase     				=output.images
           __UpperCAmelCase     				=images[0, 255:258, 383:386, -1]

           assert images.shape == (1, 512, 768, 3)
           __UpperCAmelCase     				=np.array([0.4_909, 0.5_059, 0.5_372, 0.4_623, 0.4_876, 0.5_049, 0.4_820, 0.4_956, 0.5_019]      )
           # TODO: lower the tolerance after finding the cause of onnxruntime reproducibility issues

           assert np.abs(image_slice.flatten() - expected_slice      ).max() < 2e-2



    def _a							(				self      :     List[str]      )      ->							str:
           __UpperCAmelCase     				=load_image(
               """https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main"""
               """/img2img/sketch-mountains-input.jpg"""      )
           __UpperCAmelCase     				=init_image.resize((768, 512)      )
           __UpperCAmelCase     				=LMSDiscreteScheduler.from_pretrained(
               """runwayml/stable-diffusion-v1-5""" ,     subfolder="""scheduler""" ,     revision="""onnx"""      )
           __UpperCAmelCase     				=OnnxStableDiffusionImgaImgPipeline.from_pretrained(
               """runwayml/stable-diffusion-v1-5""" ,     revision="""onnx""" ,     scheduler=__SCREAMING_SNAKE_CASE ,     safety_checker=__SCREAMING_SNAKE_CASE ,     feature_extractor=__SCREAMING_SNAKE_CASE ,     provider=self.gpu_provider ,     sess_options=self.gpu_options ,     )
           pipe.set_progress_bar_config(disable=__SCREAMING_SNAKE_CASE      )

           __UpperCAmelCase     				="""A fantasy landscape, trending on artstation"""

           __UpperCAmelCase     				=np.random.RandomState(0      )
           __UpperCAmelCase     				=pipe(
               prompt=__SCREAMING_SNAKE_CASE ,     image=__SCREAMING_SNAKE_CASE ,     strength=0.75 ,     guidance_scale=7.5 ,     num_inference_steps=20 ,     generator=__SCREAMING_SNAKE_CASE ,     output_type="""np""" ,     )
           __UpperCAmelCase     				=output.images
           __UpperCAmelCase     				=images[0, 255:258, 383:386, -1]

           assert images.shape == (1, 512, 768, 3)
           __UpperCAmelCase     				=np.array([0.8_043, 0.926, 0.9_581, 0.8_119, 0.8_954, 0.913, 0.7_209, 0.7_463, 0.7_431]      )
           # TODO: lower the tolerance after finding the cause of onnxruntime reproducibility issues

           assert np.abs(image_slice.flatten() - expected_slice      ).max() < 2e-2








"""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      A(  unittest.TestCase		):

		"""simple docstring"""





		def   _UpperCamelCase( self   )      ->	int:

					"""simple docstring"""



					_UpperCamelCase					:List[str]					     =	{
					    '''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					:Union[str, Any]					     =	{
					    '''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(SCREAMING_SNAKE_CASE__   )					,				SCREAMING_SNAKE_CASE__   )
		def   _UpperCamelCase( self   )      ->	Any:

					"""simple docstring"""



					_UpperCamelCase					:Optional[int]					     =	np.random.randn(3					,				4   )
					self.assertTrue(np.allclose(transpose(SCREAMING_SNAKE_CASE__   )					,				x.transpose()   )   )

					_UpperCamelCase					:Tuple					     =	np.random.randn(3					,				4					,				5   )
					self.assertTrue(np.allclose(transpose(SCREAMING_SNAKE_CASE__					,				axes=(1, 2, 0)   )					,				x.transpose((1, 2, 0)   )   )   )
		@require_torch
		def   _UpperCamelCase( self   )      ->	str:

					"""simple docstring"""



					_UpperCamelCase					:Union[str, Any]					     =	np.random.randn(3					,				4   )
					_UpperCamelCase					:Any					     =	torch.tensor(SCREAMING_SNAKE_CASE__   )
					self.assertTrue(np.allclose(transpose(SCREAMING_SNAKE_CASE__   )					,				transpose(SCREAMING_SNAKE_CASE__   ).numpy()   )   )

					_UpperCamelCase					:int					     =	np.random.randn(3					,				4					,				5   )
					_UpperCamelCase					:Any					     =	torch.tensor(SCREAMING_SNAKE_CASE__   )
					self.assertTrue(np.allclose(transpose(SCREAMING_SNAKE_CASE__					,				axes=(1, 2, 0)   )					,				transpose(SCREAMING_SNAKE_CASE__					,				axes=(1, 2, 0)   ).numpy()   )   )
		@require_tf
		def   _UpperCamelCase( self   )      ->	Dict:

					"""simple docstring"""



					_UpperCamelCase					:Dict					     =	np.random.randn(3					,				4   )
					_UpperCamelCase					:List[str]					     =	tf.constant(SCREAMING_SNAKE_CASE__   )
					self.assertTrue(np.allclose(transpose(SCREAMING_SNAKE_CASE__   )					,				transpose(SCREAMING_SNAKE_CASE__   ).numpy()   )   )

					_UpperCamelCase					:int					     =	np.random.randn(3					,				4					,				5   )
					_UpperCamelCase					:Dict					     =	tf.constant(SCREAMING_SNAKE_CASE__   )
					self.assertTrue(np.allclose(transpose(SCREAMING_SNAKE_CASE__					,				axes=(1, 2, 0)   )					,				transpose(SCREAMING_SNAKE_CASE__					,				axes=(1, 2, 0)   ).numpy()   )   )
		@require_flax
		def   _UpperCamelCase( self   )      ->	str:

					"""simple docstring"""



					_UpperCamelCase					:int					     =	np.random.randn(3					,				4   )
					_UpperCamelCase					:Optional[Any]					     =	jnp.array(SCREAMING_SNAKE_CASE__   )
					self.assertTrue(np.allclose(transpose(SCREAMING_SNAKE_CASE__   )					,				np.asarray(transpose(SCREAMING_SNAKE_CASE__   )   )   )   )

					_UpperCamelCase					:Dict					     =	np.random.randn(3					,				4					,				5   )
					_UpperCamelCase					:Dict					     =	jnp.array(SCREAMING_SNAKE_CASE__   )
					self.assertTrue(np.allclose(transpose(SCREAMING_SNAKE_CASE__					,				axes=(1, 2, 0)   )					,				np.asarray(transpose(SCREAMING_SNAKE_CASE__					,				axes=(1, 2, 0)   )   )   )   )
		def   _UpperCamelCase( self   )      ->	int:

					"""simple docstring"""



					_UpperCamelCase					:int					     =	np.random.randn(3					,				4   )
					self.assertTrue(np.allclose(reshape(SCREAMING_SNAKE_CASE__					,				(4, 3)   )					,				np.reshape(SCREAMING_SNAKE_CASE__					,				(4, 3)   )   )   )

					_UpperCamelCase					:Dict					     =	np.random.randn(3					,				4					,				5   )
					self.assertTrue(np.allclose(reshape(SCREAMING_SNAKE_CASE__					,				(12, 5)   )					,				np.reshape(SCREAMING_SNAKE_CASE__					,				(12, 5)   )   )   )
		@require_torch
		def   _UpperCamelCase( self   )      ->	int:

					"""simple docstring"""



					_UpperCamelCase					:Union[str, Any]					     =	np.random.randn(3					,				4   )
					_UpperCamelCase					:Optional[Any]					     =	torch.tensor(SCREAMING_SNAKE_CASE__   )
					self.assertTrue(np.allclose(reshape(SCREAMING_SNAKE_CASE__					,				(4, 3)   )					,				reshape(SCREAMING_SNAKE_CASE__					,				(4, 3)   ).numpy()   )   )

					_UpperCamelCase					:str					     =	np.random.randn(3					,				4					,				5   )
					_UpperCamelCase					:str					     =	torch.tensor(SCREAMING_SNAKE_CASE__   )
					self.assertTrue(np.allclose(reshape(SCREAMING_SNAKE_CASE__					,				(12, 5)   )					,				reshape(SCREAMING_SNAKE_CASE__					,				(12, 5)   ).numpy()   )   )
		@require_tf
		def   _UpperCamelCase( self   )      ->	Tuple:

					"""simple docstring"""



					_UpperCamelCase					:Optional[int]					     =	np.random.randn(3					,				4   )
					_UpperCamelCase					:Dict					     =	tf.constant(SCREAMING_SNAKE_CASE__   )
					self.assertTrue(np.allclose(reshape(SCREAMING_SNAKE_CASE__					,				(4, 3)   )					,				reshape(SCREAMING_SNAKE_CASE__					,				(4, 3)   ).numpy()   )   )

					_UpperCamelCase					:Union[str, Any]					     =	np.random.randn(3					,				4					,				5   )
					_UpperCamelCase					:Optional[int]					     =	tf.constant(SCREAMING_SNAKE_CASE__   )
					self.assertTrue(np.allclose(reshape(SCREAMING_SNAKE_CASE__					,				(12, 5)   )					,				reshape(SCREAMING_SNAKE_CASE__					,				(12, 5)   ).numpy()   )   )
		@require_flax
		def   _UpperCamelCase( self   )      ->	int:

					"""simple docstring"""



					_UpperCamelCase					:List[str]					     =	np.random.randn(3					,				4   )
					_UpperCamelCase					:str					     =	jnp.array(SCREAMING_SNAKE_CASE__   )
					self.assertTrue(np.allclose(reshape(SCREAMING_SNAKE_CASE__					,				(4, 3)   )					,				np.asarray(reshape(SCREAMING_SNAKE_CASE__					,				(4, 3)   )   )   )   )

					_UpperCamelCase					:Dict					     =	np.random.randn(3					,				4					,				5   )
					_UpperCamelCase					:Union[str, Any]					     =	jnp.array(SCREAMING_SNAKE_CASE__   )
					self.assertTrue(np.allclose(reshape(SCREAMING_SNAKE_CASE__					,				(12, 5)   )					,				np.asarray(reshape(SCREAMING_SNAKE_CASE__					,				(12, 5)   )   )   )   )
		def   _UpperCamelCase( self   )      ->	int:

					"""simple docstring"""



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

					_UpperCamelCase					:List[Any]					     =	np.random.randn(1					,				4					,				1					,				5   )
					self.assertTrue(np.allclose(squeeze(SCREAMING_SNAKE_CASE__					,				axis=2   )					,				np.squeeze(SCREAMING_SNAKE_CASE__					,				axis=2   )   )   )
		@require_torch
		def   _UpperCamelCase( self   )      ->	Union[str, Any]:

					"""simple docstring"""



					_UpperCamelCase					:str					     =	np.random.randn(1					,				3					,				4   )
					_UpperCamelCase					:Any					     =	torch.tensor(SCREAMING_SNAKE_CASE__   )
					self.assertTrue(np.allclose(squeeze(SCREAMING_SNAKE_CASE__   )					,				squeeze(SCREAMING_SNAKE_CASE__   ).numpy()   )   )

					_UpperCamelCase					:List[str]					     =	np.random.randn(1					,				4					,				1					,				5   )
					_UpperCamelCase					:List[Any]					     =	torch.tensor(SCREAMING_SNAKE_CASE__   )
					self.assertTrue(np.allclose(squeeze(SCREAMING_SNAKE_CASE__					,				axis=2   )					,				squeeze(SCREAMING_SNAKE_CASE__					,				axis=2   ).numpy()   )   )
		@require_tf
		def   _UpperCamelCase( self   )      ->	int:

					"""simple docstring"""



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

					_UpperCamelCase					:str					     =	np.random.randn(1					,				4					,				1					,				5   )
					_UpperCamelCase					:str					     =	tf.constant(SCREAMING_SNAKE_CASE__   )
					self.assertTrue(np.allclose(squeeze(SCREAMING_SNAKE_CASE__					,				axis=2   )					,				squeeze(SCREAMING_SNAKE_CASE__					,				axis=2   ).numpy()   )   )
		@require_flax
		def   _UpperCamelCase( self   )      ->	Optional[Any]:

					"""simple docstring"""



					_UpperCamelCase					:Union[str, Any]					     =	np.random.randn(1					,				3					,				4   )
					_UpperCamelCase					:Optional[Any]					     =	jnp.array(SCREAMING_SNAKE_CASE__   )
					self.assertTrue(np.allclose(squeeze(SCREAMING_SNAKE_CASE__   )					,				np.asarray(squeeze(SCREAMING_SNAKE_CASE__   )   )   )   )

					_UpperCamelCase					:Dict					     =	np.random.randn(1					,				4					,				1					,				5   )
					_UpperCamelCase					:int					     =	jnp.array(SCREAMING_SNAKE_CASE__   )
					self.assertTrue(np.allclose(squeeze(SCREAMING_SNAKE_CASE__					,				axis=2   )					,				np.asarray(squeeze(SCREAMING_SNAKE_CASE__					,				axis=2   )   )   )   )
		def   _UpperCamelCase( self   )      ->	Tuple:

					"""simple docstring"""



					_UpperCamelCase					:Dict					     =	np.random.randn(3					,				4   )
					self.assertTrue(np.allclose(expand_dims(SCREAMING_SNAKE_CASE__					,				axis=1   )					,				np.expand_dims(SCREAMING_SNAKE_CASE__					,				axis=1   )   )   )
		@require_torch
		def   _UpperCamelCase( self   )      ->	Tuple:

					"""simple docstring"""



					_UpperCamelCase					:List[str]					     =	np.random.randn(3					,				4   )
					_UpperCamelCase					:Union[str, Any]					     =	torch.tensor(SCREAMING_SNAKE_CASE__   )
					self.assertTrue(np.allclose(expand_dims(SCREAMING_SNAKE_CASE__					,				axis=1   )					,				expand_dims(SCREAMING_SNAKE_CASE__					,				axis=1   ).numpy()   )   )
		@require_tf
		def   _UpperCamelCase( self   )      ->	Optional[int]:

					"""simple docstring"""



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





		@require_flax
		def   _UpperCamelCase( self   )      ->	List[Any]:

					"""simple docstring"""



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

