



import inspect
import unittest

from datasets import load_dataset
from packaging import version

from transformers import BeitConfig
from transformers.models.auto import get_values
from transformers.testing_utils import require_torch, require_torch_multi_gpu, require_vision, slow, torch_device
from transformers.utils import cached_property, is_torch_available, is_vision_available

from ...test_configuration_common import ConfigTester
from ...test_modeling_common import ModelTesterMixin, _config_zero_init, floats_tensor, ids_tensor
from ...test_pipeline_mixin import PipelineTesterMixin


if is_torch_available():
	import torch
	from torch import nn

	from transformers import (
	    MODEL_MAPPING,
	    BeitForImageClassification,
	    BeitForMaskedImageModeling,
	    BeitForSemanticSegmentation,
	    BeitModel,
	)
	from transformers.models.beit.modeling_beit import BEIT_PRETRAINED_MODEL_ARCHIVE_LIST


if is_vision_available():
	import PIL
	from PIL import Image

	from transformers import BeitImageProcessor

class  __snake_case      :







							'''simple docstring'''






							def __init__(							self  ,  a_  ,  a_=100  ,  a_=13  ,  a_=30  ,  a_=2  ,  a_=3  ,  a_=True  ,  a_=True  ,  a_=32  ,  a_=4  ,  a_=4  ,  a_=37  ,  a_="gelu"  ,  a_=0.1  ,  a_=0.1  ,  a_=10  ,  a_=0.02  ,  a_=3  ,  a_=None  ,  a_=[0, 1, 2, 3]  ,  ):
											a__				      =		parent
											a__				      =		100
											a__				      =		batch_size
											a__				      =		image_size
											a__				      =		patch_size
											a__				      =		num_channels
											a__				      =		is_training
											a__				      =		use_labels
											a__				      =		hidden_size
											a__				      =		num_hidden_layers
											a__				      =		num_attention_heads
											a__				      =		intermediate_size
											a__				      =		hidden_act
											a__				      =		hidden_dropout_prob
											a__				      =		attention_probs_dropout_prob
											a__				      =		type_sequence_label_size
											a__				      =		initializer_range
											a__				      =		scope
											a__				      =		out_indices
											a__				      =		num_labels

											# in BeiT, the seq length equals the number of patches + 1 (we add 1 for the [CLS] token)
											a__				      =		(image_size // patch_size) ** 2
											a__				      =		num_patches + 1


							def _a      (							self		):
											a__				      =		floats_tensor([self.batch_size, self.num_channels, self.image_size, self.image_size]		)

											a__				      =		None
											a__				      =		None
											if self.use_labels:
															a__				      =		ids_tensor([self.batch_size]  ,  self.type_sequence_label_size		)
															a__				      =		ids_tensor([self.batch_size, self.image_size, self.image_size]  ,  self.num_labels		)

											a__				      =		self.get_config()

											return config, pixel_values, labels, pixel_labels


							def _a      (							self		):
											return BeitConfig(
											    vocab_size=self.vocab_size  ,  image_size=self.image_size  ,  patch_size=self.patch_size  ,  num_channels=self.num_channels  ,  hidden_size=self.hidden_size  ,  num_hidden_layers=self.num_hidden_layers  ,  num_attention_heads=self.num_attention_heads  ,  intermediate_size=self.intermediate_size  ,  hidden_act=self.hidden_act  ,  hidden_dropout_prob=self.hidden_dropout_prob  ,  attention_probs_dropout_prob=self.attention_probs_dropout_prob  ,  is_decoder=a_  ,  initializer_range=self.initializer_range  ,  out_indices=self.out_indices  ,  )


							def _a      (							self  ,  a_  ,  a_  ,  a_  ,  a_		):
											a__				      =		BeitModel(config=a_		)
											model.to(a_		)
											model.eval()
											a__				      =		model(a_		)
											self.parent.assertEqual(result.last_hidden_state.shape  ,  (self.batch_size, self.seq_length, self.hidden_size)		)


							def _a      (							self  ,  a_  ,  a_  ,  a_  ,  a_		):
											a__				      =		BeitForMaskedImageModeling(config=a_		)
											model.to(a_		)
											model.eval()
											a__				      =		model(a_		)
											self.parent.assertEqual(result.logits.shape  ,  (self.batch_size, self.seq_length - 1, self.vocab_size)		)


							def _a      (							self  ,  a_  ,  a_  ,  a_  ,  a_		):
											a__				      =		self.type_sequence_label_size
											a__				      =		BeitForImageClassification(a_		)
											model.to(a_		)
											model.eval()
											a__				      =		model(a_  ,  labels=a_		)
											self.parent.assertEqual(result.logits.shape  ,  (self.batch_size, self.type_sequence_label_size)		)

											# test greyscale images
											a__				      =		1
											a__				      =		BeitForImageClassification(a_		)
											model.to(a_		)
											model.eval()

											a__				      =		floats_tensor([self.batch_size, 1, self.image_size, self.image_size]		)
											a__				      =		model(a_  ,  labels=a_		)
											self.parent.assertEqual(result.logits.shape  ,  (self.batch_size, self.type_sequence_label_size)		)


							def _a      (							self  ,  a_  ,  a_  ,  a_  ,  a_		):
											a__				      =		self.num_labels
											a__				      =		BeitForSemanticSegmentation(a_		)
											model.to(a_		)
											model.eval()
											a__				      =		model(a_		)
											self.parent.assertEqual(
											    result.logits.shape  ,  (self.batch_size, self.num_labels, self.image_size * 2, self.image_size * 2)		)
											a__				      =		model(a_  ,  labels=a_		)
											self.parent.assertEqual(
											    result.logits.shape  ,  (self.batch_size, self.num_labels, self.image_size * 2, self.image_size * 2)		)







							def _a      (							self		):
											a__				      =		self.prepare_config_and_inputs()
											a__      ,			a__      ,			a__      ,			a__				      =		config_and_inputs
											a__				      =		{"""pixel_values""": pixel_values}
											return config, inputs_dict




@require_torch
class  __snake_case      (   SCREAMING_SNAKE_CASE			,SCREAMING_SNAKE_CASE			,unittest.TestCase):







							'''simple docstring'''






							UpperCamelCase__				:      List[Any]         =					(
							    (BeitModel, BeitForImageClassification, BeitForMaskedImageModeling, BeitForSemanticSegmentation)
							    if is_torch_available()
							    else ()
							)
							UpperCamelCase__				:      Optional[int]         =					(
							    {
							        """feature-extraction""": BeitModel,
							        """image-classification""": BeitForImageClassification,
							        """image-segmentation""": BeitForSemanticSegmentation,
							    }
							    if is_torch_available()
							    else {}
							)

							UpperCamelCase__				:      List[str]         =					False
							UpperCamelCase__				:      Any         =					False
							UpperCamelCase__				:      List[Any]         =					False


							def _a      (							self		):
											a__				      =		BeitModelTester(self		)
											a__				      =		ConfigTester(self  ,  config_class=a_  ,  has_text_modality=a_  ,  hidden_size=37		)


							def _a      (							self		):
											self.config_tester.run_common_tests()


							@unittest.skip(reason="""BEiT does not use inputs_embeds"""		)
							def _a      (							self		):
											pass


							@require_torch_multi_gpu
							@unittest.skip(reason="""BEiT has some layers using `add_module` which doesn't work well with `nn.DataParallel`"""		)
							def _a      (							self		):
											pass


							def _a      (							self		):
											a__      ,			a__				      =		self.model_tester.prepare_config_and_inputs_for_common()

											for model_class in self.all_model_classes:
															a__				      =		model_class(a_		)
															self.assertIsInstance(model.get_input_embeddings()  ,  (nn.Module)		)
															a__				      =		model.get_output_embeddings()
															self.assertTrue(x is None or isinstance(a_  ,  nn.Linear		)		)


							def _a      (							self		):
											a__      ,			a__				      =		self.model_tester.prepare_config_and_inputs_for_common()

											for model_class in self.all_model_classes:
															a__				      =		model_class(a_		)
															a__				      =		inspect.signature(model.forward		)
															# signature.parameters is an OrderedDict => so arg_names order is deterministic
															a__				      =		[*signature.parameters.keys()]

															a__				      =		["""pixel_values"""]
															self.assertListEqual(arg_names[:1]  ,  a_		)


							def _a      (							self		):
											a__				      =		self.model_tester.prepare_config_and_inputs()
											self.model_tester.create_and_check_model(*a_		)


							def _a      (							self		):
											a__				      =		self.model_tester.prepare_config_and_inputs()
											self.model_tester.create_and_check_for_masked_lm(*a_		)


							def _a      (							self		):
											a__				      =		self.model_tester.prepare_config_and_inputs()
											self.model_tester.create_and_check_for_image_classification(*a_		)


							def _a      (							self		):
											a__				      =		self.model_tester.prepare_config_and_inputs()
											self.model_tester.create_and_check_for_semantic_segmentation(*a_		)


							def _a      (							self		):
											if not self.model_tester.is_training:
															return

											a__      ,			a__				      =		self.model_tester.prepare_config_and_inputs_for_common()
											a__				      =		True

											for model_class in self.all_model_classes:
															# we don't test BeitForMaskedImageModeling
															if model_class in [*get_values(a_		), BeitForMaskedImageModeling]:
																			continue

															a__				      =		model_class(a_		)
															model.to(a_		)
															model.train()
															a__				      =		self._prepare_for_class(a_  ,  a_  ,  return_labels=a_		)
															a__				      =		model(**a_		).loss
															loss.backward()


							def _a      (							self		):
											a__      ,			a__				      =		self.model_tester.prepare_config_and_inputs_for_common()
											if not self.model_tester.is_training:
															return

											a__				      =		False
											a__				      =		True

											for model_class in self.all_model_classes:
															# we don't test BeitForMaskedImageModeling
															if (
															    model_class in [*get_values(a_		), BeitForMaskedImageModeling]
															    or not model_class.supports_gradient_checkpointing
															):
																			continue

															a__				      =		model_class(a_		)
															model.gradient_checkpointing_enable()
															model.to(a_		)
															model.train()
															a__				      =		self._prepare_for_class(a_  ,  a_  ,  return_labels=a_		)
															a__				      =		model(**a_		).loss
															loss.backward()


							def _a      (							self		):
											a__      ,			a__				      =		self.model_tester.prepare_config_and_inputs_for_common()

											a__				      =		_config_zero_init(a_		)
											for model_class in self.all_model_classes:
															a__				      =		model_class(config=a_		)
															for name, param in model.named_parameters():
																			# we skip lambda parameters as these require special initial values
																			# determined by config.layer_scale_init_value
																			if "lambda" in name:
																							continue
																			if param.requires_grad:
																							self.assertIn(
																							    ((param.data.mean() * 1E9).round() / 1E9).item()  ,  [0.0, 1.0]  ,  msg=F'''Parameter {name} of model {model_class} seems not properly initialized'''  ,  )







							@slow
							def _a      (							self		):
											for model_name in BEIT_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
															a__				      =		BeitModel.from_pretrained(a_		)
															self.assertIsNotNone(a_		)




def 			A_      (	):

				"""simple docstring"""
				a__				      =		Image.open("""./tests/fixtures/tests_samples/COCO/000000039769.png"""		)
				return image




@require_torch
@require_vision
class  __snake_case      (   unittest.TestCase):







							'''simple docstring'''






							@cached_property
							def _a      (							self		):
											return BeitImageProcessor.from_pretrained("""microsoft/beit-base-patch16-224"""		) if is_vision_available() else None


							@slow
							def _a      (							self		):
											a__				      =		BeitForMaskedImageModeling.from_pretrained("""microsoft/beit-base-patch16-224-pt22k"""		).to(a_		)

											a__				      =		self.default_image_processor
											a__				      =		prepare_img()
											a__				      =		image_processor(images=a_  ,  return_tensors="""pt"""		).pixel_values.to(a_		)

											# prepare bool_masked_pos
											a__				      =		torch.ones((1, 196)  ,  dtype=torch.bool		).to(a_		)

											# forward pass
											with torch.no_grad():
															a__				      =		model(pixel_values=a_  ,  bool_masked_pos=a_		)
											a__				      =		outputs.logits

											# verify the logits
											a__				      =		torch.Size((1, 196, 8_192)		)
											self.assertEqual(logits.shape  ,  a_		)

											a__				      =		torch.tensor(
											    [[-3.2_437, 0.5_072, -13.9_174], [-3.2_456, 0.4_948, -13.9_401], [-3.2_033, 0.5_121, -13.8_550]]		).to(a_		)

											self.assertTrue(torch.allclose(logits[bool_masked_pos][:3, :3]  ,  a_  ,  atol=1E-2		)		)


							@slow
							def _a      (							self		):
											a__				      =		BeitForImageClassification.from_pretrained("""microsoft/beit-base-patch16-224"""		).to(a_		)

											a__				      =		self.default_image_processor
											a__				      =		prepare_img()
											a__				      =		image_processor(images=a_  ,  return_tensors="""pt"""		).to(a_		)

											# forward pass
											with torch.no_grad():
															a__				      =		model(**a_		)
											a__				      =		outputs.logits

											# verify the logits
											a__				      =		torch.Size((1, 1_000)		)
											self.assertEqual(logits.shape  ,  a_		)

											a__				      =		torch.tensor([-1.2_385, -1.0_987, -1.0_108]		).to(a_		)

											self.assertTrue(torch.allclose(logits[0, :3]  ,  a_  ,  atol=1E-4		)		)

											a__				      =		281
											self.assertEqual(logits.argmax(-1		).item()  ,  a_		)


							@slow
							def _a      (							self		):
											a__				      =		BeitForImageClassification.from_pretrained("""microsoft/beit-large-patch16-224-pt22k-ft22k"""		).to(
											    a_		)

											a__				      =		self.default_image_processor
											a__				      =		prepare_img()
											a__				      =		image_processor(images=a_  ,  return_tensors="""pt"""		).to(a_		)

											# forward pass
											with torch.no_grad():
															a__				      =		model(**a_		)
											a__				      =		outputs.logits

											# verify the logits
											a__				      =		torch.Size((1, 21_841)		)
											self.assertEqual(logits.shape  ,  a_		)

											a__				      =		torch.tensor([1.6_881, -0.2_787, 0.5_901]		).to(a_		)

											self.assertTrue(torch.allclose(logits[0, :3]  ,  a_  ,  atol=1E-4		)		)

											a__				      =		2_396
											self.assertEqual(logits.argmax(-1		).item()  ,  a_		)


							@slow
							def _a      (							self		):
											a__				      =		BeitForSemanticSegmentation.from_pretrained("""microsoft/beit-base-finetuned-ade-640-640"""		)
											a__				      =		model.to(a_		)

											a__				      =		BeitImageProcessor(do_resize=a_  ,  size=640  ,  do_center_crop=a_		)

											a__				      =		load_dataset("""hf-internal-testing/fixtures_ade20k"""  ,  split="""test"""		)
											a__				      =		Image.open(ds[0]["""file"""]		)
											a__				      =		image_processor(images=a_  ,  return_tensors="""pt"""		).to(a_		)

											# forward pass
											with torch.no_grad():
															a__				      =		model(**a_		)
											a__				      =		outputs.logits

											# verify the logits
											a__				      =		torch.Size((1, 150, 160, 160)		)
											self.assertEqual(logits.shape  ,  a_		)

											a__				      =		version.parse(PIL.__version__		) < version.parse("""9.0.0"""		)

											if is_pillow_less_than_a:
															a__				      =		torch.tensor(
															    [
															        [[-4.9_225, -2.3_954, -3.0_522], [-2.8_822, -1.0_046, -1.7_561], [-2.9_549, -1.3_228, -2.1_347]],
															        [[-5.8_168, -3.4_129, -4.0_778], [-3.8_651, -2.2_214, -3.0_277], [-3.8_356, -2.4_643, -3.3_535]],
															        [[-0.0_078, 3.9_952, 4.0_754], [2.9_856, 4.6_944, 5.0_035], [3.2_413, 4.7_813, 4.9_969]],
															    ]  ,  device=a_  ,  )
											else:
															a__				      =		torch.tensor(
															    [
															        [[-4.8_960, -2.3_688, -3.0_355], [-2.8_478, -0.9_836, -1.7_418], [-2.9_449, -1.3_332, -2.1_456]],
															        [[-5.8_081, -3.4_124, -4.1_006], [-3.8_561, -2.2_081, -3.0_323], [-3.8_365, -2.4_601, -3.3_669]],
															        [[-0.0_309, 3.9_868, 4.0_540], [2.9_640, 4.6_877, 4.9_976], [3.2_081, 4.7_690, 4.9_942]],
															    ]  ,  device=a_  ,  )

											self.assertTrue(torch.allclose(logits[0, :3, :3, :3]  ,  a_  ,  atol=1E-4		)		)







							@slow
							def _a      (							self		):
											a__				      =		BeitForSemanticSegmentation.from_pretrained("""microsoft/beit-base-finetuned-ade-640-640"""		)
											a__				      =		model.to(a_		)

											a__				      =		BeitImageProcessor(do_resize=a_  ,  size=640  ,  do_center_crop=a_		)

											a__				      =		load_dataset("""hf-internal-testing/fixtures_ade20k"""  ,  split="""test"""		)
											a__				      =		Image.open(ds[0]["""file"""]		)
											a__				      =		image_processor(images=a_  ,  return_tensors="""pt"""		).to(a_		)

											# forward pass
											with torch.no_grad():
															a__				      =		model(**a_		)

											a__				      =		outputs.logits.detach().cpu()

											a__				      =		image_processor.post_process_semantic_segmentation(outputs=a_  ,  target_sizes=[(500, 300)]		)
											a__				      =		torch.Size((500, 300)		)
											self.assertEqual(segmentation[0].shape  ,  a_		)

											a__				      =		image_processor.post_process_semantic_segmentation(outputs=a_		)
											a__				      =		torch.Size((160, 160)		)
											self.assertEqual(segmentation[0].shape  ,  a_		)






import gc
import unittest

import numpy as np
import torch

from diffusers import (
    AudioDiffusionPipeline,
    AutoencoderKL,
    DDIMScheduler,
    DDPMScheduler,
    DiffusionPipeline,
    Mel,
    UNetaDConditionModel,
    UNetaDModel,
)
from diffusers.utils import slow, torch_device
from diffusers.utils.testing_utils import enable_full_determinism, require_torch_gpu


enable_full_determinism()

class  __snake_case      (   unittest.TestCase):







							'''simple docstring'''






							def _a      (							self		):
											# clean up the VRAM after each test
											super().tearDown()
											gc.collect()
											torch.cuda.empty_cache()


							@property
							def _a      (							self		):
											torch.manual_seed(0		)
											a__				      =		UNetaDModel(
											    sample_size=(32, 64)  ,  in_channels=1  ,  out_channels=1  ,  layers_per_block=2  ,  block_out_channels=(128, 128)  ,  down_block_types=("""AttnDownBlock2D""", """DownBlock2D""")  ,  up_block_types=("""UpBlock2D""", """AttnUpBlock2D""")  ,  )
											return model


							@property
							def _a      (							self		):
											torch.manual_seed(0		)
											a__				      =		UNetaDConditionModel(
											    sample_size=(64, 32)  ,  in_channels=1  ,  out_channels=1  ,  layers_per_block=2  ,  block_out_channels=(128, 128)  ,  down_block_types=("""CrossAttnDownBlock2D""", """DownBlock2D""")  ,  up_block_types=("""UpBlock2D""", """CrossAttnUpBlock2D""")  ,  cross_attention_dim=10  ,  )
											return model


							@property
							def _a      (							self		):
											torch.manual_seed(0		)
											a__				      =		AutoencoderKL(
											    sample_size=(128, 64)  ,  in_channels=1  ,  out_channels=1  ,  latent_channels=1  ,  layers_per_block=2  ,  block_out_channels=(128, 128)  ,  down_block_types=("""DownEncoderBlock2D""", """DownEncoderBlock2D""")  ,  up_block_types=("""UpDecoderBlock2D""", """UpDecoderBlock2D""")  ,  )
											a__				      =		UNetaDModel(
											    sample_size=(64, 32)  ,  in_channels=1  ,  out_channels=1  ,  layers_per_block=2  ,  block_out_channels=(128, 128)  ,  down_block_types=("""AttnDownBlock2D""", """DownBlock2D""")  ,  up_block_types=("""UpBlock2D""", """AttnUpBlock2D""")  ,  )
											return vqvae, unet







							@slow
							def _a      (							self		):
											a__				      =		"""cpu"""  # ensure determinism for the device-dependent torch.Generator
											a__				      =		Mel(
											    x_res=self.dummy_unet.config.sample_size[1]  ,  y_res=self.dummy_unet.config.sample_size[0]  ,  )

											a__				      =		DDPMScheduler()
											a__				      =		AudioDiffusionPipeline(vqvae=a_  ,  unet=self.dummy_unet  ,  mel=a_  ,  scheduler=a_		)
											a__				      =		pipe.to(a_		)
											pipe.set_progress_bar_config(disable=a_		)

											a__				      =		torch.Generator(device=a_		).manual_seed(42		)
											a__				      =		pipe(generator=a_  ,  steps=4		)
											a__				      =		output.audios[0]
											a__				      =		output.images[0]

											a__				      =		torch.Generator(device=a_		).manual_seed(42		)
											a__				      =		pipe(generator=a_  ,  steps=4  ,  return_dict=a_		)
											a__				      =		output[0][0]

											assert audio.shape == (1, (self.dummy_unet.config.sample_size[1] - 1) * mel.hop_length)
											assert (
											    image.height == self.dummy_unet.config.sample_size[0]
											    and image.width == self.dummy_unet.config.sample_size[1]
											)
											a__				      =		np.frombuffer(image.tobytes()  ,  dtype="""uint8"""		)[:10]
											a__				      =		np.frombuffer(image_from_tuple.tobytes()  ,  dtype="""uint8"""		)[:10]
											a__				      =		np.array([69, 255, 255, 255, 0, 0, 77, 181, 12, 127]		)

											assert np.abs(image_slice.flatten() - expected_slice		).max() == 0
											assert np.abs(image_from_tuple_slice.flatten() - expected_slice		).max() == 0

											a__				      =		Mel(
											    x_res=self.dummy_vqvae_and_unet[0].config.sample_size[1]  ,  y_res=self.dummy_vqvae_and_unet[0].config.sample_size[0]  ,  )

											a__				      =		DDIMScheduler()
											a__				      =		self.dummy_vqvae_and_unet
											a__				      =		AudioDiffusionPipeline(
											    vqvae=self.dummy_vqvae_and_unet[0]  ,  unet=dummy_vqvae_and_unet[1]  ,  mel=a_  ,  scheduler=a_		)
											a__				      =		pipe.to(a_		)
											pipe.set_progress_bar_config(disable=a_		)

											np.random.seed(0		)
											a__				      =		np.random.uniform(-1  ,  1  ,  ((dummy_vqvae_and_unet[0].config.sample_size[1] - 1) * mel.hop_length,)		)
											a__				      =		torch.Generator(device=a_		).manual_seed(42		)
											a__				      =		pipe(raw_audio=a_  ,  generator=a_  ,  start_step=5  ,  steps=10		)
											a__				      =		output.images[0]

											assert (
											    image.height == self.dummy_vqvae_and_unet[0].config.sample_size[0]
											    and image.width == self.dummy_vqvae_and_unet[0].config.sample_size[1]
											)
											a__				      =		np.frombuffer(image.tobytes()  ,  dtype="""uint8"""		)[:10]
											a__				      =		np.array([120, 117, 110, 109, 138, 167, 138, 148, 132, 121]		)

											assert np.abs(image_slice.flatten() - expected_slice		).max() == 0

											a__				      =		self.dummy_unet_condition
											a__				      =		AudioDiffusionPipeline(
											    vqvae=self.dummy_vqvae_and_unet[0]  ,  unet=a_  ,  mel=a_  ,  scheduler=a_		)
											a__				      =		pipe.to(a_		)
											pipe.set_progress_bar_config(disable=a_		)

											np.random.seed(0		)
											a__				      =		torch.rand((1, 1, 10)		)
											a__				      =		pipe(generator=a_  ,  encoding=a_		)
											a__				      =		output.images[0]
											a__				      =		np.frombuffer(image.tobytes()  ,  dtype="""uint8"""		)[:10]
											a__				      =		np.array([107, 103, 120, 127, 142, 122, 113, 122, 97, 111]		)

											assert np.abs(image_slice.flatten() - expected_slice		).max() == 0




@slow
@require_torch_gpu
class  __snake_case      (   unittest.TestCase):







							'''simple docstring'''






							def _a      (							self		):
											# clean up the VRAM after each test
											super().tearDown()
											gc.collect()
											torch.cuda.empty_cache()







							def _a      (							self		):
											a__				      =		torch_device

											a__				      =		DiffusionPipeline.from_pretrained("""teticio/audio-diffusion-ddim-256"""		)
											a__				      =		pipe.to(a_		)
											pipe.set_progress_bar_config(disable=a_		)

											a__				      =		torch.Generator(device=a_		).manual_seed(42		)
											a__				      =		pipe(generator=a_		)
											a__				      =		output.audios[0]
											a__				      =		output.images[0]

											assert audio.shape == (1, (pipe.unet.config.sample_size[1] - 1) * pipe.mel.hop_length)
											assert image.height == pipe.unet.config.sample_size[0] and image.width == pipe.unet.config.sample_size[1]
											a__				      =		np.frombuffer(image.tobytes()  ,  dtype="""uint8"""		)[:10]
											a__				      =		np.array([151, 167, 154, 144, 122, 134, 121, 105, 70, 26]		)

											assert np.abs(image_slice.flatten() - expected_slice		).max() == 0

