
'''simple docstring'''







import inspect
import math
import tempfile
import unittest

import numpy as np

from transformers import ViTMAEConfig
from transformers.testing_utils import require_torch, 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, floats_tensor, ids_tensor
from ...test_pipeline_mixin import PipelineTesterMixin


if is_torch_available():
						import torch
						from torch import nn

						from transformers import ViTMAEForPreTraining, ViTMAEModel
						from transformers.models.vit.modeling_vit import VIT_PRETRAINED_MODEL_ARCHIVE_LIST


if is_vision_available():
						from PIL import Image

						from transformers import ViTImageProcessor


class 			lowerCAmelCase :




		def __init__(				self					,						UpperCamelCase					,						UpperCamelCase=13					,						UpperCamelCase=30					,						UpperCamelCase=2					,						UpperCamelCase=3					,						UpperCamelCase=True					,						UpperCamelCase=True					,						UpperCamelCase=32					,						UpperCamelCase=5					,						UpperCamelCase=4					,						UpperCamelCase=37					,						UpperCamelCase="gelu"					,						UpperCamelCase=0.1					,						UpperCamelCase=0.1					,						UpperCamelCase=10					,						UpperCamelCase=0.02					,						UpperCamelCase=3					,						UpperCamelCase=0.6					,						UpperCamelCase=None					,						):
								_SCREAMING_SNAKE_CASE				= parent
								_SCREAMING_SNAKE_CASE				= batch_size
								_SCREAMING_SNAKE_CASE				= image_size
								_SCREAMING_SNAKE_CASE				= patch_size
								_SCREAMING_SNAKE_CASE				= num_channels
								_SCREAMING_SNAKE_CASE				= is_training
								_SCREAMING_SNAKE_CASE				= use_labels
								_SCREAMING_SNAKE_CASE				= hidden_size
								_SCREAMING_SNAKE_CASE				= num_hidden_layers
								_SCREAMING_SNAKE_CASE				= num_attention_heads
								_SCREAMING_SNAKE_CASE				= intermediate_size
								_SCREAMING_SNAKE_CASE				= hidden_act
								_SCREAMING_SNAKE_CASE				= hidden_dropout_prob
								_SCREAMING_SNAKE_CASE				= attention_probs_dropout_prob
								_SCREAMING_SNAKE_CASE				= type_sequence_label_size
								_SCREAMING_SNAKE_CASE				= initializer_range
								_SCREAMING_SNAKE_CASE				= mask_ratio
								_SCREAMING_SNAKE_CASE				= scope

								# in ViTMAE, the expected sequence length = (num_patches + 1) * (1 - config.mask_ratio), rounded above
								# (we add 1 for the [CLS] token)
								_SCREAMING_SNAKE_CASE				= (image_size // patch_size) ** 2
								_SCREAMING_SNAKE_CASE				= int(math.ceil((1 - mask_ratio) * (num_patches + 1)      )      )




		def     lowercase       (				self      ):
								_SCREAMING_SNAKE_CASE				= floats_tensor([self.batch_size, self.num_channels, self.image_size, self.image_size]      )

								_SCREAMING_SNAKE_CASE				= None
								if self.use_labels:
														_SCREAMING_SNAKE_CASE				= ids_tensor([self.batch_size]					,						self.type_sequence_label_size      )

								_SCREAMING_SNAKE_CASE				= self.get_config()

								return config, pixel_values, labels




		def     lowercase       (				self      ):
								return ViTMAEConfig(
								    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=UpperCamelCase					,						initializer_range=self.initializer_range					,						mask_ratio=self.mask_ratio					,						)




		def     lowercase       (				self					,						UpperCamelCase					,						UpperCamelCase					,						UpperCamelCase      ):
								_SCREAMING_SNAKE_CASE				= ViTMAEModel(config=UpperCamelCase      )
								model.to(UpperCamelCase      )
								model.eval()
								_SCREAMING_SNAKE_CASE				= model(UpperCamelCase      )
								self.parent.assertEqual(result.last_hidden_state.shape					,						(self.batch_size, self.seq_length, self.hidden_size)      )




		def     lowercase       (				self					,						UpperCamelCase					,						UpperCamelCase					,						UpperCamelCase      ):
								_SCREAMING_SNAKE_CASE				= ViTMAEForPreTraining(UpperCamelCase      )
								model.to(UpperCamelCase      )
								model.eval()
								_SCREAMING_SNAKE_CASE				= model(UpperCamelCase      )
								_SCREAMING_SNAKE_CASE				= (self.image_size // self.patch_size) ** 2
								_SCREAMING_SNAKE_CASE				= self.patch_size**2 * self.num_channels
								self.parent.assertEqual(result.logits.shape					,						(self.batch_size, num_patches, expected_num_channels)      )

								# test greyscale images
								_SCREAMING_SNAKE_CASE				= 1
								_SCREAMING_SNAKE_CASE				= ViTMAEForPreTraining(UpperCamelCase      )
								model.to(UpperCamelCase      )
								model.eval()
								_SCREAMING_SNAKE_CASE				= floats_tensor([self.batch_size, 1, self.image_size, self.image_size]      )
								_SCREAMING_SNAKE_CASE				= model(UpperCamelCase      )
								_SCREAMING_SNAKE_CASE				= self.patch_size**2
								self.parent.assertEqual(result.logits.shape					,						(self.batch_size, num_patches, expected_num_channels)      )




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


@require_torch
class 			lowerCAmelCase (				__UpperCAmelCase		,     __UpperCAmelCase		,     unittest.TestCase			):
		a							:					str       =					(ViTMAEModel, ViTMAEForPreTraining) if is_torch_available() else ()
		a							:					Union[str, Any]       =					{"""feature-extraction""": ViTMAEModel} if is_torch_available() else {}

		a							:					int       =					False
		a							:					Tuple       =					False
		a							:					Any       =					False
		a							:					Tuple       =					False




		def     lowercase       (				self      ):
								_SCREAMING_SNAKE_CASE				= ViTMAEModelTester(self      )
								_SCREAMING_SNAKE_CASE				= ConfigTester(self					,						config_class=UpperCamelCase					,						has_text_modality=UpperCamelCase					,						hidden_size=37      )




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




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




		def     lowercase       (				self      ):
								_SCREAMING_SNAKE_CASE,							_SCREAMING_SNAKE_CASE				= self.model_tester.prepare_config_and_inputs_for_common()

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




		def     lowercase       (				self      ):
								_SCREAMING_SNAKE_CASE,							_SCREAMING_SNAKE_CASE				= self.model_tester.prepare_config_and_inputs_for_common()

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

														_SCREAMING_SNAKE_CASE				= ["pixel_values"]
														self.assertListEqual(arg_names[:1]					,						UpperCamelCase      )




		def     lowercase       (				self      ):
								_SCREAMING_SNAKE_CASE				= self.model_tester.prepare_config_and_inputs()
								self.model_tester.create_and_check_model(*UpperCamelCase      )




		def     lowercase       (				self      ):
								_SCREAMING_SNAKE_CASE				= self.model_tester.prepare_config_and_inputs()
								self.model_tester.create_and_check_for_pretraining(*UpperCamelCase      )




		def     lowercase       (				self					,						UpperCamelCase					,						UpperCamelCase					,						UpperCamelCase      ):
								# make masks reproducible
								np.random.seed(2      )

								_SCREAMING_SNAKE_CASE				= int((pt_model.config.image_size // pt_model.config.patch_size) ** 2      )
								_SCREAMING_SNAKE_CASE				= np.random.uniform(size=(self.model_tester.batch_size, num_patches)      )
								_SCREAMING_SNAKE_CASE				= torch.from_numpy(UpperCamelCase      )

								# Add `noise` argument.
								# PT inputs will be prepared in `super().check_pt_tf_models()` with this added `noise` argument
								_SCREAMING_SNAKE_CASE				= pt_noise

								super().check_pt_tf_models(UpperCamelCase					,						UpperCamelCase					,						UpperCamelCase      )




		def     lowercase       (				self      ):
								_SCREAMING_SNAKE_CASE,							_SCREAMING_SNAKE_CASE				= self.model_tester.prepare_config_and_inputs_for_common()

								for model_class in self.all_model_classes:
														_SCREAMING_SNAKE_CASE				= model_class(UpperCamelCase      )
														model.to(UpperCamelCase      )
														model.eval()
														# make random mask reproducible
														torch.manual_seed(2      )
														with torch.no_grad():
																				_SCREAMING_SNAKE_CASE				= model(**self._prepare_for_class(UpperCamelCase					,						UpperCamelCase      )      )

														_SCREAMING_SNAKE_CASE				= outputs[0].cpu().numpy()
														_SCREAMING_SNAKE_CASE				= 0

														with tempfile.TemporaryDirectory() as tmpdirname:
																				model.save_pretrained(UpperCamelCase      )
																				_SCREAMING_SNAKE_CASE				= model_class.from_pretrained(UpperCamelCase      )
																				model.to(UpperCamelCase      )
																				# make random mask reproducible
																				torch.manual_seed(2      )
																				with torch.no_grad():
																										_SCREAMING_SNAKE_CASE				= model(**self._prepare_for_class(UpperCamelCase					,						UpperCamelCase      )      )

																				# Make sure we don't have nans
																				_SCREAMING_SNAKE_CASE				= after_outputs[0].cpu().numpy()
																				_SCREAMING_SNAKE_CASE				= 0
																				_SCREAMING_SNAKE_CASE				= np.amax(np.abs(out_a - out_a      )      )
																				self.assertLessEqual(UpperCamelCase					,						1e-5      )




		@unittest.skip(
		    reason="ViTMAE returns a random mask + ids_restore in each forward pass. See test_save_load\n    to get deterministic results."      )
		def     lowercase       (				self      ):
								pass




		@unittest.skip(
		    reason="ViTMAE returns a random mask + ids_restore in each forward pass. See test_save_load\n    to get deterministic results."      )
		def     lowercase       (				self      ):
								pass




		@unittest.skip(
		    reason="ViTMAE returns a random mask + ids_restore in each forward pass. See test_save_load\n    to get deterministic results."      )
		def     lowercase       (				self      ):
								pass




		@unittest.skip(reason="ViTMAE returns a random mask + ids_restore in each forward pass. See test_save_load"      )
		def     lowercase       (				self      ):
								pass




		@unittest.skip("Will be fixed soon by reducing the size of the model used for common tests."      )
		def     lowercase       (				self      ):
								pass




		@slow
		def     lowercase       (				self      ):
								for model_name in VIT_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
														_SCREAMING_SNAKE_CASE				= ViTMAEModel.from_pretrained(UpperCamelCase      )
														self.assertIsNotNone(UpperCamelCase      )



def 			_a		(	):
						_SCREAMING_SNAKE_CASE				= Image.open("./tests/fixtures/tests_samples/COCO/000000039769.png"  )
						return image




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




		@cached_property
		def     lowercase       (				self      ):
								return ViTImageProcessor.from_pretrained("facebook/vit-mae-base"      ) if is_vision_available() else None




		@slow
		def     lowercase       (				self      ):
								# make random mask reproducible across the PT and TF model
								np.random.seed(2      )

								_SCREAMING_SNAKE_CASE				= ViTMAEForPreTraining.from_pretrained("facebook/vit-mae-base"      ).to(UpperCamelCase      )

								_SCREAMING_SNAKE_CASE				= self.default_image_processor
								_SCREAMING_SNAKE_CASE				= prepare_img()
								_SCREAMING_SNAKE_CASE				= image_processor(images=UpperCamelCase					,						return_tensors="pt"      ).to(UpperCamelCase      )

								# prepare a noise vector that will be also used for testing the TF model
								# (this way we can ensure that the PT and TF models operate on the same inputs)
								_SCREAMING_SNAKE_CASE				= ViTMAEConfig()
								_SCREAMING_SNAKE_CASE				= int((vit_mae_config.image_size // vit_mae_config.patch_size) ** 2      )
								_SCREAMING_SNAKE_CASE				= np.random.uniform(size=(1, num_patches)      )

								# forward pass
								with torch.no_grad():
														_SCREAMING_SNAKE_CASE				= model(**UpperCamelCase					,						noise=torch.from_numpy(UpperCamelCase      ).to(device=UpperCamelCase      )      )

								# verify the logits
								_SCREAMING_SNAKE_CASE				= torch.Size((1, 196, 768)      )
								self.assertEqual(outputs.logits.shape					,						UpperCamelCase      )

								_SCREAMING_SNAKE_CASE				= torch.tensor(
								    [[-0.05_48, -1.70_23, -0.93_25], [0.37_21, -0.56_70, -0.22_33], [0.82_35, -1.38_78, -0.35_24]]      )

								self.assertTrue(torch.allclose(outputs.logits[0, :3, :3]					,						expected_slice.to(UpperCamelCase      )					,						atol=1e-4      )      )

'''simple docstring'''







import tempfile

import numpy as np
import torch
from transformers import AutoTokenizer, TaEncoderModel

from diffusers import DDPMScheduler, UNetaDConditionModel
from diffusers.models.attention_processor import AttnAddedKVProcessor
from diffusers.pipelines.deepfloyd_if import IFWatermarker
from diffusers.utils.testing_utils import torch_device

from ..test_pipelines_common import to_np


class 			lowerCAmelCase :




		def     lowercase       (				self      ):
								torch.manual_seed(0      )
								_SCREAMING_SNAKE_CASE				= TaEncoderModel.from_pretrained("hf-internal-testing/tiny-random-t5"      )

								torch.manual_seed(0      )
								_SCREAMING_SNAKE_CASE				= AutoTokenizer.from_pretrained("hf-internal-testing/tiny-random-t5"      )

								torch.manual_seed(0      )
								_SCREAMING_SNAKE_CASE				= UNetaDConditionModel(
								    sample_size=32					,						layers_per_block=1					,						block_out_channels=[32, 64]					,						down_block_types=[
								        "ResnetDownsampleBlock2D",
								        "SimpleCrossAttnDownBlock2D",
								    ]					,						mid_block_type="UNetMidBlock2DSimpleCrossAttn"					,						up_block_types=["SimpleCrossAttnUpBlock2D", "ResnetUpsampleBlock2D"]					,						in_channels=3					,						out_channels=6					,						cross_attention_dim=32					,						encoder_hid_dim=32					,						attention_head_dim=8					,						addition_embed_type="text"					,						addition_embed_type_num_heads=2					,						cross_attention_norm="group_norm"					,						resnet_time_scale_shift="scale_shift"					,						act_fn="gelu"					,						)
								unet.set_attn_processor(AttnAddedKVProcessor()      )  # For reproducibility tests

								torch.manual_seed(0      )
								_SCREAMING_SNAKE_CASE				= DDPMScheduler(
								    num_train_timesteps=1_000					,						beta_schedule="squaredcos_cap_v2"					,						beta_start=0.00_01					,						beta_end=0.02					,						thresholding=UpperCamelCase					,						dynamic_thresholding_ratio=0.95					,						sample_max_value=1.0					,						prediction_type="epsilon"					,						variance_type="learned_range"					,						)

								torch.manual_seed(0      )
								_SCREAMING_SNAKE_CASE				= IFWatermarker()

								return {
								    "text_encoder": text_encoder,
								    "tokenizer": tokenizer,
								    "unet": unet,
								    "scheduler": scheduler,
								    "watermarker": watermarker,
								    "safety_checker": None,
								    "feature_extractor": None,
								}




		def     lowercase       (				self      ):
								torch.manual_seed(0      )
								_SCREAMING_SNAKE_CASE				= TaEncoderModel.from_pretrained("hf-internal-testing/tiny-random-t5"      )

								torch.manual_seed(0      )
								_SCREAMING_SNAKE_CASE				= AutoTokenizer.from_pretrained("hf-internal-testing/tiny-random-t5"      )

								torch.manual_seed(0      )
								_SCREAMING_SNAKE_CASE				= UNetaDConditionModel(
								    sample_size=32					,						layers_per_block=[1, 2]					,						block_out_channels=[32, 64]					,						down_block_types=[
								        "ResnetDownsampleBlock2D",
								        "SimpleCrossAttnDownBlock2D",
								    ]					,						mid_block_type="UNetMidBlock2DSimpleCrossAttn"					,						up_block_types=["SimpleCrossAttnUpBlock2D", "ResnetUpsampleBlock2D"]					,						in_channels=6					,						out_channels=6					,						cross_attention_dim=32					,						encoder_hid_dim=32					,						attention_head_dim=8					,						addition_embed_type="text"					,						addition_embed_type_num_heads=2					,						cross_attention_norm="group_norm"					,						resnet_time_scale_shift="scale_shift"					,						act_fn="gelu"					,						class_embed_type="timestep"					,						mid_block_scale_factor=1.4_14					,						time_embedding_act_fn="gelu"					,						time_embedding_dim=32					,						)
								unet.set_attn_processor(AttnAddedKVProcessor()      )  # For reproducibility tests

								torch.manual_seed(0      )
								_SCREAMING_SNAKE_CASE				= DDPMScheduler(
								    num_train_timesteps=1_000					,						beta_schedule="squaredcos_cap_v2"					,						beta_start=0.00_01					,						beta_end=0.02					,						thresholding=UpperCamelCase					,						dynamic_thresholding_ratio=0.95					,						sample_max_value=1.0					,						prediction_type="epsilon"					,						variance_type="learned_range"					,						)

								torch.manual_seed(0      )
								_SCREAMING_SNAKE_CASE				= DDPMScheduler(
								    num_train_timesteps=1_000					,						beta_schedule="squaredcos_cap_v2"					,						beta_start=0.00_01					,						beta_end=0.02					,						)

								torch.manual_seed(0      )
								_SCREAMING_SNAKE_CASE				= IFWatermarker()

								return {
								    "text_encoder": text_encoder,
								    "tokenizer": tokenizer,
								    "unet": unet,
								    "scheduler": scheduler,
								    "image_noising_scheduler": image_noising_scheduler,
								    "watermarker": watermarker,
								    "safety_checker": None,
								    "feature_extractor": None,
								}




		def     lowercase       (				self      ):
								_SCREAMING_SNAKE_CASE				= self.get_dummy_components()
								_SCREAMING_SNAKE_CASE				= self.pipeline_class(**UpperCamelCase      )
								pipe.to(UpperCamelCase      )
								pipe.set_progress_bar_config(disable=UpperCamelCase      )

								_SCREAMING_SNAKE_CASE				= self.get_dummy_inputs(UpperCamelCase      )

								_SCREAMING_SNAKE_CASE				= inputs["prompt"]
								_SCREAMING_SNAKE_CASE				= inputs["generator"]
								_SCREAMING_SNAKE_CASE				= inputs["num_inference_steps"]
								_SCREAMING_SNAKE_CASE				= inputs["output_type"]

								if "image" in inputs:
														_SCREAMING_SNAKE_CASE				= inputs["image"]
								else:
														_SCREAMING_SNAKE_CASE				= None

								if "mask_image" in inputs:
														_SCREAMING_SNAKE_CASE				= inputs["mask_image"]
								else:
														_SCREAMING_SNAKE_CASE				= None

								if "original_image" in inputs:
														_SCREAMING_SNAKE_CASE				= inputs["original_image"]
								else:
														_SCREAMING_SNAKE_CASE				= None

								_SCREAMING_SNAKE_CASE,							_SCREAMING_SNAKE_CASE				= pipe.encode_prompt(UpperCamelCase      )

								# inputs with prompt converted to embeddings
								_SCREAMING_SNAKE_CASE				= {
								    "prompt_embeds": prompt_embeds,
								    "negative_prompt_embeds": negative_prompt_embeds,
								    "generator": generator,
								    "num_inference_steps": num_inference_steps,
								    "output_type": output_type,
								}

								if image is not None:
														_SCREAMING_SNAKE_CASE				= image

								if mask_image is not None:
														_SCREAMING_SNAKE_CASE				= mask_image

								if original_image is not None:
														_SCREAMING_SNAKE_CASE				= original_image

								# set all optional components to None
								for optional_component in pipe._optional_components:
														setattr(UpperCamelCase					,						UpperCamelCase					,						UpperCamelCase      )

								_SCREAMING_SNAKE_CASE				= pipe(**UpperCamelCase      )[0]

								with tempfile.TemporaryDirectory() as tmpdir:
														pipe.save_pretrained(UpperCamelCase      )
														_SCREAMING_SNAKE_CASE				= self.pipeline_class.from_pretrained(UpperCamelCase      )
														pipe_loaded.to(UpperCamelCase      )
														pipe_loaded.set_progress_bar_config(disable=UpperCamelCase      )

								pipe_loaded.unet.set_attn_processor(AttnAddedKVProcessor()      )  # For reproducibility tests

								for optional_component in pipe._optional_components:
														self.assertTrue(
														    getattr(UpperCamelCase					,						UpperCamelCase      ) is None					,						F'`{optional_component}` did not stay set to None after loading.'					,						)

								_SCREAMING_SNAKE_CASE				= self.get_dummy_inputs(UpperCamelCase      )

								_SCREAMING_SNAKE_CASE				= inputs["generator"]
								_SCREAMING_SNAKE_CASE				= inputs["num_inference_steps"]
								_SCREAMING_SNAKE_CASE				= inputs["output_type"]

								# inputs with prompt converted to embeddings
								_SCREAMING_SNAKE_CASE				= {
								    "prompt_embeds": prompt_embeds,
								    "negative_prompt_embeds": negative_prompt_embeds,
								    "generator": generator,
								    "num_inference_steps": num_inference_steps,
								    "output_type": output_type,
								}

								if image is not None:
														_SCREAMING_SNAKE_CASE				= image

								if mask_image is not None:
														_SCREAMING_SNAKE_CASE				= mask_image

								if original_image is not None:
														_SCREAMING_SNAKE_CASE				= original_image

								_SCREAMING_SNAKE_CASE				= pipe_loaded(**UpperCamelCase      )[0]

								_SCREAMING_SNAKE_CASE				= np.abs(to_np(UpperCamelCase      ) - to_np(UpperCamelCase      )      ).max()
								self.assertLess(UpperCamelCase					,						1e-4      )




		def     lowercase       (				self      ):
								_SCREAMING_SNAKE_CASE				= self.get_dummy_components()
								_SCREAMING_SNAKE_CASE				= self.pipeline_class(**UpperCamelCase      )
								pipe.to(UpperCamelCase      )
								pipe.set_progress_bar_config(disable=UpperCamelCase      )

								_SCREAMING_SNAKE_CASE				= self.get_dummy_inputs(UpperCamelCase      )
								_SCREAMING_SNAKE_CASE				= pipe(**UpperCamelCase      )[0]

								with tempfile.TemporaryDirectory() as tmpdir:
														pipe.save_pretrained(UpperCamelCase      )
														_SCREAMING_SNAKE_CASE				= self.pipeline_class.from_pretrained(UpperCamelCase      )
														pipe_loaded.to(UpperCamelCase      )
														pipe_loaded.set_progress_bar_config(disable=UpperCamelCase      )

								pipe_loaded.unet.set_attn_processor(AttnAddedKVProcessor()      )  # For reproducibility tests

								_SCREAMING_SNAKE_CASE				= self.get_dummy_inputs(UpperCamelCase      )
								_SCREAMING_SNAKE_CASE				= pipe_loaded(**UpperCamelCase      )[0]

								_SCREAMING_SNAKE_CASE				= np.abs(to_np(UpperCamelCase      ) - to_np(UpperCamelCase      )      ).max()
								self.assertLess(UpperCamelCase					,						1e-4      )