


'''simple docstring'''






import inspect
import unittest
from typing import List

import numpy as np

from transformers import EfficientFormerConfig
from transformers.testing_utils import require_tf, require_vision, slow
from transformers.utils import cached_property, is_tf_available, is_vision_available

from ...test_configuration_common import ConfigTester
from ...test_modeling_tf_common import TFModelTesterMixin, floats_tensor, ids_tensor
from ...test_pipeline_mixin import PipelineTesterMixin


if is_tf_available():
					import tensorflow as tf

					from transformers import (
					    TFEfficientFormerForImageClassification,
					    TFEfficientFormerForImageClassificationWithTeacher,
					    TFEfficientFormerModel,
					)
					from transformers.models.efficientformer.modeling_tf_efficientformer import (
					    TF_EFFICIENTFORMER_PRETRAINED_MODEL_ARCHIVE_LIST,
					)


if is_vision_available():
					from PIL import Image

					from transformers import EfficientFormerImageProcessor
class 						__UpperCamelCase	:





							def __init__(  self		:List[Any]  ,_UpperCamelCase		:int  ,_UpperCamelCase		:Optional[int] = 1_3  ,_UpperCamelCase		:str = 6_4  ,_UpperCamelCase		:int = 2  ,_UpperCamelCase		:List[Any] = 3  ,_UpperCamelCase		:int = 3  ,_UpperCamelCase		:Any = True  ,_UpperCamelCase		:Dict = True  ,_UpperCamelCase		:Tuple = 1_2_8  ,_UpperCamelCase		:Optional[int]=[1_6, 3_2, 6_4, 1_2_8]  ,_UpperCamelCase		:Any = 7  ,_UpperCamelCase		:Optional[int] = 4  ,_UpperCamelCase		:Optional[int] = 3_7  ,_UpperCamelCase		:str = "gelu"  ,_UpperCamelCase		:Tuple = 0.1  ,_UpperCamelCase		:Optional[Any] = 0.1  ,_UpperCamelCase		:int = 1_0  ,_UpperCamelCase		:Dict = 0.02  ,_UpperCamelCase		:Any = 2  ,_UpperCamelCase		:Optional[int] = 1  ,_UpperCamelCase		:str = 1_2_8  ,_UpperCamelCase		:Union[str, Any] = [2, 2, 2, 2]  ,_UpperCamelCase		:Union[str, Any] = 2  ,_UpperCamelCase		:Optional[int] = 2  ,):
									snake_case_		:							str			       =						parent
									snake_case_		:							List[Any]			       =						batch_size
									snake_case_		:							int			       =						image_size
									snake_case_		:							Tuple			       =						patch_size
									snake_case_		:							str			       =						num_channels
									snake_case_		:							Union[str, Any]			       =						is_training
									snake_case_		:							List[Any]			       =						use_labels
									snake_case_		:							int			       =						hidden_size
									snake_case_		:							Optional[Any]			       =						num_hidden_layers
									snake_case_		:							List[Any]			       =						num_attention_heads
									snake_case_		:							Dict			       =						intermediate_size
									snake_case_		:							str			       =						hidden_act
									snake_case_		:							Dict			       =						hidden_dropout_prob
									snake_case_		:							str			       =						attention_probs_dropout_prob
									snake_case_		:							Optional[int]			       =						type_sequence_label_size
									snake_case_		:							Dict			       =						initializer_range
									snake_case_		:							Dict			       =						encoder_stride
									snake_case_		:							int			       =						num_attention_outputs
									snake_case_		:							List[Any]			       =						embed_dim
									snake_case_		:							Optional[Any]			       =						embed_dim + 1
									snake_case_		:							Optional[Any]			       =						resolution
									snake_case_		:							Optional[Any]			       =						depths
									snake_case_		:							Union[str, Any]			       =						hidden_sizes
									snake_case_		:							List[str]			       =						dim
									snake_case_		:							Any			       =						mlp_expansion_ratio





							def 		a__   (  self		:Dict			):
									snake_case_		:							Union[str, Any]			       =						floats_tensor([self.batch_size, self.num_channels, self.image_size, self.image_size]			)

									snake_case_		:							str			       =						None
									if self.use_labels:
											snake_case_		:							List[str]			       =						ids_tensor([self.batch_size]  ,self.type_sequence_label_size			)

									snake_case_		:							List[str]			       =						self.get_config()

									return config, pixel_values, labels





							def 		a__   (  self		:str			):
									return EfficientFormerConfig(
									    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=_lowercase  ,initializer_range=self.initializer_range  ,encoder_stride=self.encoder_stride  ,resolution=self.resolution  ,depths=self.depths  ,hidden_sizes=self.hidden_sizes  ,dim=self.dim  ,mlp_expansion_ratio=self.mlp_expansion_ratio  ,)





							def 		a__   (  self		:Any  ,_UpperCamelCase		:Optional[Any]  ,_UpperCamelCase		:Optional[int]  ,_UpperCamelCase		:Optional[Any]			):
									snake_case_		:							Optional[Any]			       =						TFEfficientFormerModel(config=_lowercase			)
									snake_case_		:							List[Any]			       =						model(_lowercase  ,training=_lowercase			)
									self.parent.assertEqual(result.last_hidden_state.shape  ,(self.batch_size, self.seq_length, self.hidden_size)			)





							def 		a__   (  self		:str  ,_UpperCamelCase		:List[Any]  ,_UpperCamelCase		:Union[str, Any]  ,_UpperCamelCase		:Optional[int]			):
									snake_case_		:							Optional[Any]			       =						self.type_sequence_label_size
									snake_case_		:							Any			       =						TFEfficientFormerForImageClassification(_lowercase			)
									snake_case_		:							Union[str, Any]			       =						model(_lowercase  ,labels=_lowercase  ,training=_lowercase			)
									self.parent.assertEqual(result.logits.shape  ,(self.batch_size, self.type_sequence_label_size)			)

									# test greyscale images
									snake_case_		:							Optional[Any]			       =						1
									snake_case_		:							int			       =						TFEfficientFormerForImageClassification(_lowercase			)

									snake_case_		:							List[str]			       =						floats_tensor([self.batch_size, 1, self.image_size, self.image_size]			)
									snake_case_		:							str			       =						model(_lowercase  ,labels=_lowercase			)
									self.parent.assertEqual(result.logits.shape  ,(self.batch_size, self.type_sequence_label_size)			)





							def 		a__   (  self		:str			):
									snake_case_		:							Any			       =						self.prepare_config_and_inputs()
									snake_case_		:							Tuple			       =						config_and_inputs
									snake_case_		:							Tuple			       =						{"""pixel_values""": pixel_values}
									return config, inputs_dict





@require_tf
class 						__UpperCamelCase	(						__snake_case						,  __snake_case						,  unittest.TestCase							):
							lowercase			:		Any   		=  (
							    (
							        TFEfficientFormerModel,
							        TFEfficientFormerForImageClassificationWithTeacher,
							        TFEfficientFormerForImageClassification,
							    )
							    if is_tf_available()
							    else ()
							)
							lowercase			:		Optional[int]   		=  (
							    {
							        'feature-extraction': TFEfficientFormerModel,
							        'image-classification': (
							            TFEfficientFormerForImageClassification,
							            TFEfficientFormerForImageClassificationWithTeacher,
							        ),
							    }
							    if is_tf_available()
							    else {}
							)

							lowercase			:		Optional[int]   		=  False

							lowercase			:		Any   		=  False
							lowercase			:		List[Any]   		=  False
							lowercase			:		Tuple   		=  False
							lowercase			:		Optional[int]   		=  False





							def 		a__   (  self		:str			):
									snake_case_		:							Tuple			       =						TFEfficientFormerModelTester(self			)
									snake_case_		:							Any			       =						ConfigTester(
									    self  ,config_class=_lowercase  ,has_text_modality=_lowercase  ,hidden_size=3_7			)





							def 		a__   (  self		:List[Any]			):
									self.config_tester.run_common_tests()





							@unittest.skip(reason="""EfficientFormer does not use inputs_embeds"""			)
							def 		a__   (  self		:Optional[Any]			):
									pass





							@unittest.skip(reason="""EfficientFormer does not support input and output embeddings"""			)
							def 		a__   (  self		:List[Any]			):
									pass





							def 		a__   (  self		:Union[str, Any]			):
									snake_case_		:							Optional[int]			       =						self.model_tester.prepare_config_and_inputs_for_common()

									for model_class in self.all_model_classes:
											snake_case_		:							Dict			       =						model_class(_lowercase			)
											snake_case_		:							Optional[Any]			       =						inspect.signature(model.call			)
											# signature.parameters is an OrderedDict => so arg_names order is deterministic
											snake_case_		:							Optional[Any]			       =						[*signature.parameters.keys()]

											snake_case_		:							Union[str, Any]			       =						["""pixel_values"""]
											self.assertListEqual(arg_names[:1]  ,_lowercase			)





							def 		a__   (  self		:Tuple			):

									def check_hidden_states_output(_UpperCamelCase		:Optional[int]  ,_UpperCamelCase		:Optional[int]  ,_UpperCamelCase		:Union[str, Any]			):
											snake_case_		:							Tuple			       =						model_class(_lowercase			)

											snake_case_		:							int			       =						model(**self._prepare_for_class(_lowercase  ,_lowercase			)  ,training=_lowercase			)
											snake_case_		:							Tuple			       =						outputs.encoder_hidden_states if config.is_encoder_decoder else outputs.hidden_states

											snake_case_		:							str			       =						getattr(
											    self.model_tester  ,"""expected_num_hidden_layers"""  ,self.model_tester.num_hidden_layers + 1			)
											self.assertEqual(len(_lowercase			)  ,_lowercase			)

											if hasattr(self.model_tester  ,"""encoder_seq_length"""			):
													snake_case_		:							Any			       =						self.model_tester.encoder_seq_length
													if hasattr(self.model_tester  ,"""chunk_length"""			) and self.model_tester.chunk_length > 1:
															snake_case_		:							int			       =						seq_length * self.model_tester.chunk_length
											else:
													snake_case_		:							Any			       =						self.model_tester.seq_length

											self.assertListEqual(
											    list(hidden_states[-1].shape[-2:]			)  ,[seq_length, self.model_tester.hidden_size]  ,)

											if config.is_encoder_decoder:
													snake_case_		:							Optional[int]			       =						outputs.decoder_hidden_states

													self.asseretIsInstance(_lowercase  ,(list, tuple)			)
													self.assertEqual(len(_lowercase			)  ,_lowercase			)
													snake_case_		:							Any			       =						getattr(self.model_tester  ,"""seq_length"""  ,_lowercase			)
													snake_case_		:							List[Any]			       =						getattr(self.model_tester  ,"""decoder_seq_length"""  ,_lowercase			)

													self.assertListEqual(
													    list(hidden_states[-1].shape[-2:]			)  ,[decoder_seq_length, self.model_tester.hidden_size]  ,)

									snake_case_		:							Union[str, Any]			       =						self.model_tester.prepare_config_and_inputs_for_common()

									for model_class in self.all_model_classes:
											snake_case_		:							Dict			       =						True
											check_hidden_states_output(_lowercase  ,_lowercase  ,_lowercase			)

											# check that output_hidden_states also work using config
											del inputs_dict["output_hidden_states"]
											snake_case_		:							int			       =						True

											check_hidden_states_output(_lowercase  ,_lowercase  ,_lowercase			)





							def 		a__   (  self		:Union[str, Any]  ,_UpperCamelCase		:Optional[Any]  ,_UpperCamelCase		:Dict  ,_UpperCamelCase		:int=False			):
									snake_case_		:							Any			       =						super()._prepare_for_class(_lowercase  ,_lowercase  ,return_labels=_lowercase			)

									if return_labels:
											if model_class.__name__ == "TFEfficientFormerForImageClassificationWithTeacher":
													del inputs_dict["labels"]

									return inputs_dict





							def 		a__   (  self		:List[str]			):
									snake_case_		:							Optional[Any]			       =						self.model_tester.prepare_config_and_inputs()
									self.model_tester.create_and_check_model(*_lowercase			)





							@unittest.skip(reason="""EfficientFormer does not implement masked image modeling yet"""			)
							def 		a__   (  self		:int			):
									snake_case_		:							Union[str, Any]			       =						self.model_tester.prepare_config_and_inputs()
									self.model_tester.create_and_check_for_masked_image_modeling(*_lowercase			)





							def 		a__   (  self		:Tuple			):
									snake_case_		:							Optional[Any]			       =						self.model_tester.prepare_config_and_inputs()
									self.model_tester.create_and_check_for_image_classification(*_lowercase			)





							@slow
							def 		a__   (  self		:int			):

									for model_name in TF_EFFICIENTFORMER_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
											snake_case_		:							Union[str, Any]			       =						TFEfficientFormerModel.from_pretrained(_lowercase			)
											self.assertIsNotNone(_lowercase			)





							def 		a__   (  self		:Optional[int]			):
									snake_case_		:							Optional[Any]			       =						self.model_tester.prepare_config_and_inputs_for_common()
									snake_case_		:							int			       =						True

									snake_case_		:							Optional[int]			       =						getattr(self.model_tester  ,"""seq_length"""  ,_lowercase			)
									snake_case_		:							Dict			       =						getattr(self.model_tester  ,"""encoder_seq_length"""  ,_lowercase			)
									snake_case_		:							Dict			       =						getattr(self.model_tester  ,"""key_length"""  ,_lowercase			)
									snake_case_		:							int			       =						getattr(self.model_tester  ,"""chunk_length"""  ,_lowercase			)

									if chunk_length is not None and hasattr(self.model_tester  ,"""num_hashes"""			):
											snake_case_		:							List[str]			       =						encoder_seq_length * self.model_tester.num_hashes

									for model_class in self.all_model_classes:
											snake_case_		:							List[Any]			       =						True
											snake_case_		:							Tuple			       =						False
											snake_case_		:							List[Any]			       =						True
											snake_case_		:							int			       =						model_class(_lowercase			)

											snake_case_		:							List[Any]			       =						model(**self._prepare_for_class(_lowercase  ,_lowercase			)  ,training=_lowercase			)
											snake_case_		:							Dict			       =						outputs.encoder_attentions if config.is_encoder_decoder else outputs.attentions
											self.assertEqual(len(_lowercase			)  ,self.model_tester.num_attention_outputs			)

											# check that output_attentions also work using config
											del inputs_dict["output_attentions"]
											snake_case_		:							Optional[Any]			       =						True
											snake_case_		:							List[str]			       =						model_class(_lowercase			)
											snake_case_		:							Dict			       =						model(**self._prepare_for_class(_lowercase  ,_lowercase			)  ,training=_lowercase			)

											snake_case_		:							int			       =						outputs.encoder_attentions if config.is_encoder_decoder else outputs.attentions
											self.assertEqual(len(_lowercase			)  ,self.model_tester.num_attention_outputs			)

											if chunk_length is not None:
													self.assertListEqual(
													    list(attentions[0].shape[-4:]			)  ,[self.model_tester.num_attention_heads, encoder_seq_length, chunk_length, encoder_key_length]  ,)
											else:
													self.assertListEqual(
													    list(attentions[0].shape[-3:]			)  ,[self.model_tester.num_attention_heads, encoder_seq_length, encoder_key_length]  ,)





							def 		a__   (  self		:Optional[int]			):
									snake_case_		:							List[str]			       =						self.model_tester.prepare_config_and_inputs_for_common()

									for model_class in self.all_model_classes:
											# Prepare our model
											snake_case_		:							Dict			       =						model_class(_lowercase			)
											# These are maximally general inputs for the model, with multiple None dimensions
											# Hopefully this will catch any conditionals that fail for flexible shapes
											snake_case_		:							Optional[Any]			       =						{
											    key: tf.keras.Input(shape=val.shape[1:]  ,dtype=val.dtype  ,name=_lowercase			)
											    for key, val in model.input_signature.items()
											    if key in model.dummy_inputs
											}
											snake_case_		:							Optional[Any]			       =						model(_lowercase			)
											self.assertTrue(outputs_dict is not None			)





def      UpperCAmelCase      (		):







		'''simple docstring'''
		snake_case_		:							int			       =						Image.open("""./tests/fixtures/tests_samples/COCO/000000039769.png""" )
		return image






@require_tf
@require_vision
class 						__UpperCamelCase	(						unittest.TestCase							):





							@cached_property
							def 		a__   (  self		:Optional[Any]			):
									return (
									    EfficientFormerImageProcessor.from_pretrained("""snap-research/efficientformer-l1-300"""			)
									    if is_vision_available()
									    else None
									)





							@slow
							def 		a__   (  self		:Dict			):
									snake_case_		:							str			       =						TFEfficientFormerForImageClassification.from_pretrained("""snap-research/efficientformer-l1-300"""			)
									snake_case_		:							Optional[Any]			       =						self.default_image_processor
									snake_case_		:							List[str]			       =						prepare_img()
									snake_case_		:							int			       =						image_processor(images=_lowercase  ,return_tensors="""tf"""			)
									# forward pass
									snake_case_		:							Optional[Any]			       =						model(**_lowercase  ,training=_lowercase			)
									# verify the logits
									snake_case_		:							str			       =						tf.TensorShape((1, 1_0_0_0)			)
									self.assertEqual(outputs.logits.shape  ,_lowercase			)
									snake_case_		:							Dict			       =						tf.constant([-0.05_55, 0.48_25, -0.08_52]			)
									self.assertTrue(np.allclose(outputs.logits[0, :3]  ,_lowercase  ,atol=1E-4			)			)





							@slow
							def 		a__   (  self		:Tuple			):
									snake_case_		:							Any			       =						TFEfficientFormerForImageClassificationWithTeacher.from_pretrained(
									    """snap-research/efficientformer-l1-300"""			)
									snake_case_		:							Any			       =						self.default_image_processor
									snake_case_		:							str			       =						prepare_img()
									snake_case_		:							str			       =						image_processor(images=_lowercase  ,return_tensors="""tf"""			)
									# forward pass
									snake_case_		:							List[Any]			       =						model(**_lowercase  ,training=_lowercase			)
									# verify the logits
									snake_case_		:							int			       =						tf.TensorShape((1, 1_0_0_0)			)
									self.assertEqual(outputs.logits.shape  ,_lowercase			)
									snake_case_		:							List[str]			       =						tf.constant([-0.13_12, 0.43_53, -1.04_99]			)
									self.assertTrue(np.allclose(outputs.logits[0, :3]  ,_lowercase  ,atol=1E-4			)			)



'''simple docstring'''






import unittest

import numpy as np
import torch
from torch import nn
from transformers import (
    CLIPImageProcessor,
    CLIPTextConfig,
    CLIPTextModelWithProjection,
    CLIPTokenizer,
    CLIPVisionConfig,
    CLIPVisionModelWithProjection,
)

from diffusers import KandinskyVaaPriorPipeline, PriorTransformer, UnCLIPScheduler
from diffusers.utils import torch_device
from diffusers.utils.testing_utils import enable_full_determinism, skip_mps

from ..test_pipelines_common import PipelineTesterMixin


enable_full_determinism()
class 						__UpperCamelCase	(						lowercase__						,  unittest.TestCase							):
							lowercase			:		List[str]   		=  KandinskyVaaPriorPipeline
							lowercase			:		Optional[Any]   		=  ['prompt']
							lowercase			:		Dict   		=  ['prompt', 'negative_prompt']
							lowercase			:		Dict   		=  [
							    'num_images_per_prompt',
							    'generator',
							    'num_inference_steps',
							    'latents',
							    'negative_prompt',
							    'guidance_scale',
							    'output_type',
							    'return_dict',
							]
							lowercase			:		int   		=  False





							@property
							def 		a__   (  self		:int			):
									return 3_2





							@property
							def 		a__   (  self		:Any			):
									return 3_2





							@property
							def 		a__   (  self		:Union[str, Any]			):
									return self.time_input_dim





							@property
							def 		a__   (  self		:int			):
									return self.time_input_dim * 4





							@property
							def 		a__   (  self		:Dict			):
									return 1_0_0





							@property
							def 		a__   (  self		:List[Any]			):
									snake_case_		:							List[Any]			       =						CLIPTokenizer.from_pretrained("""hf-internal-testing/tiny-random-clip"""			)
									return tokenizer





							@property
							def 		a__   (  self		:int			):
									torch.manual_seed(0			)
									snake_case_		:							Optional[Any]			       =						CLIPTextConfig(
									    bos_token_id=0  ,eos_token_id=2  ,hidden_size=self.text_embedder_hidden_size  ,projection_dim=self.text_embedder_hidden_size  ,intermediate_size=3_7  ,layer_norm_eps=1E-0_5  ,num_attention_heads=4  ,num_hidden_layers=5  ,pad_token_id=1  ,vocab_size=1_0_0_0  ,)
									return CLIPTextModelWithProjection(_UpperCamelCase			)





							@property
							def 		a__   (  self		:Dict			):
									torch.manual_seed(0			)

									snake_case_		:							Tuple			       =						{
									    """num_attention_heads""": 2,
									    """attention_head_dim""": 1_2,
									    """embedding_dim""": self.text_embedder_hidden_size,
									    """num_layers""": 1,
									}

									snake_case_		:							int			       =						PriorTransformer(**_UpperCamelCase			)
									# clip_std and clip_mean is initialized to be 0 so PriorTransformer.post_process_latents will always return 0 - set clip_std to be 1 so it won't return 0
									snake_case_		:							Any			       =						nn.Parameter(torch.ones(model.clip_std.shape			)			)
									return model





							@property
							def 		a__   (  self		:Optional[int]			):
									torch.manual_seed(0			)
									snake_case_		:							Any			       =						CLIPVisionConfig(
									    hidden_size=self.text_embedder_hidden_size  ,image_size=2_2_4  ,projection_dim=self.text_embedder_hidden_size  ,intermediate_size=3_7  ,num_attention_heads=4  ,num_channels=3  ,num_hidden_layers=5  ,patch_size=1_4  ,)

									snake_case_		:							Optional[Any]			       =						CLIPVisionModelWithProjection(_UpperCamelCase			)
									return model





							@property
							def 		a__   (  self		:List[Any]			):
									snake_case_		:							Any			       =						CLIPImageProcessor(
									    crop_size=2_2_4  ,do_center_crop=_UpperCamelCase  ,do_normalize=_UpperCamelCase  ,do_resize=_UpperCamelCase  ,image_mean=[0.48_14_54_66, 0.4_57_82_75, 0.40_82_10_73]  ,image_std=[0.26_86_29_54, 0.26_13_02_58, 0.27_57_77_11]  ,resample=3  ,size=2_2_4  ,)

									return image_processor





							def 		a__   (  self		:List[Any]			):
									snake_case_		:							Tuple			       =						self.dummy_prior
									snake_case_		:							Any			       =						self.dummy_image_encoder
									snake_case_		:							Optional[int]			       =						self.dummy_text_encoder
									snake_case_		:							Any			       =						self.dummy_tokenizer
									snake_case_		:							Union[str, Any]			       =						self.dummy_image_processor

									snake_case_		:							Tuple			       =						UnCLIPScheduler(
									    variance_type="""fixed_small_log"""  ,prediction_type="""sample"""  ,num_train_timesteps=1_0_0_0  ,clip_sample=_UpperCamelCase  ,clip_sample_range=10.0  ,)

									snake_case_		:							Tuple			       =						{
									    """prior""": prior,
									    """image_encoder""": image_encoder,
									    """text_encoder""": text_encoder,
									    """tokenizer""": tokenizer,
									    """scheduler""": scheduler,
									    """image_processor""": image_processor,
									}

									return components





							def 		a__   (  self		:Dict  ,_UpperCamelCase		:str  ,_UpperCamelCase		:Union[str, Any]=0			):
									if str(_UpperCamelCase			).startswith("""mps"""			):
											snake_case_		:							Optional[int]			       =						torch.manual_seed(_UpperCamelCase			)
									else:
											snake_case_		:							int			       =						torch.Generator(device=_UpperCamelCase			).manual_seed(_UpperCamelCase			)
									snake_case_		:							Dict			       =						{
									    """prompt""": """horse""",
									    """generator""": generator,
									    """guidance_scale""": 4.0,
									    """num_inference_steps""": 2,
									    """output_type""": """np""",
									}
									return inputs





							def 		a__   (  self		:int			):
									snake_case_		:							Union[str, Any]			       =						"""cpu"""

									snake_case_		:							int			       =						self.get_dummy_components()

									snake_case_		:							int			       =						self.pipeline_class(**_UpperCamelCase			)
									snake_case_		:							Union[str, Any]			       =						pipe.to(_UpperCamelCase			)

									pipe.set_progress_bar_config(disable=_UpperCamelCase			)

									snake_case_		:							Any			       =						pipe(**self.get_dummy_inputs(_UpperCamelCase			)			)
									snake_case_		:							List[Any]			       =						output.image_embeds

									snake_case_		:							List[Any]			       =						pipe(
									    **self.get_dummy_inputs(_UpperCamelCase			)  ,return_dict=_UpperCamelCase  ,)[0]

									snake_case_		:							Dict			       =						image[0, -1_0:]
									snake_case_		:							Optional[Any]			       =						image_from_tuple[0, -1_0:]

									assert image.shape == (1, 3_2)

									snake_case_		:							Optional[int]			       =						np.array(
									    [-0.05_32, 1.71_20, 0.36_56, -1.08_52, -0.89_46, -1.17_56, 0.43_48, 0.24_82, 0.51_46, -0.11_56]			)

									assert np.abs(image_slice.flatten() - expected_slice			).max() < 1E-2
									assert np.abs(image_from_tuple_slice.flatten() - expected_slice			).max() < 1E-2





							@skip_mps
							def 		a__   (  self		:List[Any]			):
									snake_case_		:							Any			       =						torch_device == """cpu"""
									snake_case_		:							Any			       =						True
									snake_case_		:							Dict			       =						False

									self._test_inference_batch_single_identical(
									    test_max_difference=_UpperCamelCase  ,relax_max_difference=_UpperCamelCase  ,test_mean_pixel_difference=_UpperCamelCase  ,)





							@skip_mps
							def 		a__   (  self		:str			):
									snake_case_		:							str			       =						torch_device == """cpu"""
									snake_case_		:							List[str]			       =						False

									self._test_attention_slicing_forward_pass(
									    test_max_difference=_UpperCamelCase  ,test_mean_pixel_difference=_UpperCamelCase  ,)