


'''simple docstring'''







import copy
import inspect
import unittest

import numpy as np
from huggingface_hub import hf_hub_download

from transformers import VideoMAEConfig
from transformers.models.auto import get_values
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 (
			    MODEL_FOR_VIDEO_CLASSIFICATION_MAPPING,
			    VideoMAEForPreTraining,
			    VideoMAEForVideoClassification,
			    VideoMAEModel,
			)
			from transformers.models.videomae.modeling_videomae import VIDEOMAE_PRETRAINED_MODEL_ARCHIVE_LIST


if is_vision_available():
			from transformers import VideoMAEImageProcessor


class 			__lowerCamelCase			:
				"""simple docstring"""


				def __init__(  self      :							Any				,							SCREAMING_SNAKE_CASE      :							str				,							SCREAMING_SNAKE_CASE      :							Optional[int]=13				,							SCREAMING_SNAKE_CASE      :							List[Any]=10				,							SCREAMING_SNAKE_CASE      :							Union[str, Any]=3				,							SCREAMING_SNAKE_CASE      :							Optional[Any]=2				,							SCREAMING_SNAKE_CASE      :							Dict=2				,							SCREAMING_SNAKE_CASE      :							Optional[int]=2				,							SCREAMING_SNAKE_CASE      :							str=True				,							SCREAMING_SNAKE_CASE      :							Any=True				,							SCREAMING_SNAKE_CASE      :							Dict=32				,							SCREAMING_SNAKE_CASE      :							Dict=5				,							SCREAMING_SNAKE_CASE      :							int=4				,							SCREAMING_SNAKE_CASE      :							Optional[Any]=37				,							SCREAMING_SNAKE_CASE      :							List[Any]="gelu"				,							SCREAMING_SNAKE_CASE      :							Tuple=0.1				,							SCREAMING_SNAKE_CASE      :							List[str]=0.1				,							SCREAMING_SNAKE_CASE      :							str=10				,							SCREAMING_SNAKE_CASE      :							Union[str, Any]=0.02				,							SCREAMING_SNAKE_CASE      :							Optional[int]=0.9				,							SCREAMING_SNAKE_CASE      :							List[str]=None				,							):
											_A					:     Optional[Any]     = parent
											_A					:     Any     = batch_size
											_A					:     Any     = image_size
											_A					:     str     = num_channels
											_A					:     List[str]     = patch_size
											_A					:     str     = tubelet_size
											_A					:     List[Any]     = num_frames
											_A					:     Union[str, Any]     = is_training
											_A					:     List[Any]     = use_labels
											_A					:     Union[str, Any]     = hidden_size
											_A					:     Optional[int]     = num_hidden_layers
											_A					:     Tuple     = num_attention_heads
											_A					:     str     = intermediate_size
											_A					:     List[str]     = hidden_act
											_A					:     Tuple     = hidden_dropout_prob
											_A					:     Optional[Any]     = attention_probs_dropout_prob
											_A					:     Dict     = type_sequence_label_size
											_A					:     str     = initializer_range
											_A					:     List[str]     = mask_ratio
											_A					:     Optional[int]     = scope

											# in VideoMAE, the number of tokens equals num_frames/tubelet_size * num_patches per frame
											_A					:     Optional[int]     = (image_size // patch_size) ** 2
											_A					:     str     = (num_frames // tubelet_size) * self.num_patches_per_frame

											# use this variable to define bool_masked_pos
											_A					:     List[str]     = int(mask_ratio * self.seq_length)


				def        A   (  self      :							Union[str, Any]):
											_A					:     Optional[Any]     = floats_tensor(
											    [self.batch_size, self.num_frames, self.num_channels, self.image_size, self.image_size])

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

											_A					:     Optional[int]     = self.get_config()

											return config, pixel_values, labels


				def        A   (  self      :							Optional[int]):
											return VideoMAEConfig(
											    image_size=self.image_size				,							patch_size=self.patch_size				,							num_channels=self.num_channels				,							num_frames=self.num_frames				,							tubelet_size=self.tubelet_size				,							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				,							)


				def        A   (  self      :							str				,							SCREAMING_SNAKE_CASE      :							List[Any]				,							SCREAMING_SNAKE_CASE      :							List[Any]				,							SCREAMING_SNAKE_CASE      :							Tuple):
											_A					:     int     = VideoMAEModel(config=UpperCamelCase__)
											model.to(UpperCamelCase__)
											model.eval()
											_A					:     Optional[int]     = model(UpperCamelCase__)
											self.parent.assertEqual(result.last_hidden_state.shape				,							(self.batch_size, self.seq_length, self.hidden_size))


				def        A   (  self      :							Tuple				,							SCREAMING_SNAKE_CASE      :							int				,							SCREAMING_SNAKE_CASE      :							List[str]				,							SCREAMING_SNAKE_CASE      :							Any):
											_A					:     Tuple     = VideoMAEForPreTraining(UpperCamelCase__)
											model.to(UpperCamelCase__)
											model.eval()
											# important: each video needs to have the same number of masked patches
											# hence we define a single mask, which we then repeat for each example in the batch
											_A					:     Any     = torch.ones((self.num_masks,))
											_A					:     Tuple     = torch.cat([mask, torch.zeros(self.seq_length - mask.size(0))])
											_A					:     Optional[Any]     = mask.expand(self.batch_size				,							-1).bool()

											_A					:     Optional[Any]     = model(UpperCamelCase__				,							UpperCamelCase__)
											# model only returns predictions for masked patches
											_A					:     Tuple     = mask.sum().item()
											_A					:     str     = 3 * self.tubelet_size * self.patch_size**2
											self.parent.assertEqual(result.logits.shape				,							(self.batch_size, num_masked_patches, decoder_num_labels))


				def        A   (  self      :							Optional[Any]):
											_A					:     Union[str, Any]     = self.prepare_config_and_inputs()
											_A  ,			_A  ,			_A					:     Optional[Any]     = config_and_inputs
											_A					:     List[str]     = {'pixel_values': pixel_values}
											return config, inputs_dict




@require_torch
class 			__lowerCamelCase			(	_snake_case    , _snake_case    , unittest.TestCase	):
				"""simple docstring"""
				a													=   (
				    (VideoMAEModel, VideoMAEForPreTraining, VideoMAEForVideoClassification) if is_torch_available() else ()
				)
				a													=   (
				    {"feature-extraction": VideoMAEModel, "video-classification": VideoMAEForVideoClassification}
				    if is_torch_available()
				    else {}
				)

				a													=   False
				a													=   False
				a													=   False
				a													=   False


				def        A   (  self      :							List[Any]):
											_A					:     Tuple     = VideoMAEModelTester(self)
											_A					:     List[str]     = ConfigTester(self				,							config_class=UpperCamelCase__				,							has_text_modality=UpperCamelCase__				,							hidden_size=37)


				def        A   (  self      :							Union[str, Any]				,							SCREAMING_SNAKE_CASE      :							Union[str, Any]				,							SCREAMING_SNAKE_CASE      :							Optional[Any]				,							SCREAMING_SNAKE_CASE      :							Optional[int]=False):
											_A					:     str     = copy.deepcopy(UpperCamelCase__)

											if model_class == VideoMAEForPreTraining:
																		# important: each video needs to have the same number of masked patches
																		# hence we define a single mask, which we then repeat for each example in the batch
																		_A					:     Any     = torch.ones((self.model_tester.num_masks,))
																		_A					:     Any     = torch.cat([mask, torch.zeros(self.model_tester.seq_length - mask.size(0))])
																		_A					:     Optional[Any]     = mask.expand(self.model_tester.batch_size				,							-1).bool()
																		_A					:     str     = bool_masked_pos.to(UpperCamelCase__)

											if return_labels:
																		if model_class in [
																		    *get_values(UpperCamelCase__),
																		]:
																									_A					:     str     = torch.zeros(
																									    self.model_tester.batch_size				,							dtype=torch.long				,							device=UpperCamelCase__)

											return inputs_dict


				def        A   (  self      :							List[str]):
											self.config_tester.run_common_tests()


				@unittest.skip(reason='VideoMAE does not use inputs_embeds')
				def        A   (  self      :							int):
											pass


				def        A   (  self      :							List[str]):
											_A  ,			_A					:     Optional[int]     = self.model_tester.prepare_config_and_inputs_for_common()

											for model_class in self.all_model_classes:
																		_A					:     Union[str, Any]     = model_class(UpperCamelCase__)
																		self.assertIsInstance(model.get_input_embeddings()				,							(nn.Module))
																		_A					:     Tuple     = model.get_output_embeddings()
																		self.assertTrue(x is None or isinstance(UpperCamelCase__				,							nn.Linear))


				def        A   (  self      :							List[str]):
											_A  ,			_A					:     List[str]     = self.model_tester.prepare_config_and_inputs_for_common()

											for model_class in self.all_model_classes:
																		_A					:     Tuple     = model_class(UpperCamelCase__)
																		_A					:     Optional[int]     = inspect.signature(model.forward)
																		# signature.parameters is an OrderedDict => so arg_names order is deterministic
																		_A					:     Optional[Any]     = [*signature.parameters.keys()]

																		_A					:     str     = ['pixel_values']
																		self.assertListEqual(arg_names[:1]				,							UpperCamelCase__)


				def        A   (  self      :							List[Any]):
											_A					:     Tuple     = self.model_tester.prepare_config_and_inputs()
											self.model_tester.create_and_check_model(*UpperCamelCase__)


				def        A   (  self      :							Tuple):
											_A					:     Optional[Any]     = self.model_tester.prepare_config_and_inputs()
											self.model_tester.create_and_check_for_pretraining(*UpperCamelCase__)


				@slow
				def        A   (  self      :							List[str]):
											for model_name in VIDEOMAE_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
																		_A					:     List[Any]     = VideoMAEModel.from_pretrained(UpperCamelCase__)
																		self.assertIsNotNone(UpperCamelCase__)


				def        A   (  self      :							List[str]):
											if not self.has_attentions:
																		pass

											else:
																		_A  ,			_A					:     Dict     = self.model_tester.prepare_config_and_inputs_for_common()
																		_A					:     List[Any]     = True

																		for model_class in self.all_model_classes:
																									_A					:     Union[str, Any]     = self.model_tester.seq_length - self.model_tester.num_masks
																									_A					:     Union[str, Any]     = (
																									    num_visible_patches if model_class == VideoMAEForPreTraining else self.model_tester.seq_length
																									)

																									_A					:     str     = True
																									_A					:     Tuple     = False
																									_A					:     Any     = True
																									_A					:     List[Any]     = model_class(UpperCamelCase__)
																									model.to(UpperCamelCase__)
																									model.eval()
																									with torch.no_grad():
																																_A					:     Tuple     = model(**self._prepare_for_class(UpperCamelCase__				,							UpperCamelCase__))
																									_A					:     Dict     = outputs.attentions
																									self.assertEqual(len(UpperCamelCase__)				,							self.model_tester.num_hidden_layers)

																									# check that output_attentions also work using config
																									del inputs_dict["output_attentions"]
																									_A					:     Dict     = True
																									_A					:     str     = model_class(UpperCamelCase__)
																									model.to(UpperCamelCase__)
																									model.eval()
																									with torch.no_grad():
																																_A					:     Any     = model(**self._prepare_for_class(UpperCamelCase__				,							UpperCamelCase__))
																									_A					:     List[Any]     = outputs.attentions
																									self.assertEqual(len(UpperCamelCase__)				,							self.model_tester.num_hidden_layers)

																									self.assertListEqual(
																									    list(attentions[0].shape[-3:])				,							[self.model_tester.num_attention_heads, seq_len, seq_len]				,							)
																									_A					:     int     = len(UpperCamelCase__)

																									# Check attention is always last and order is fine
																									_A					:     Optional[Any]     = True
																									_A					:     Any     = True
																									_A					:     List[str]     = model_class(UpperCamelCase__)
																									model.to(UpperCamelCase__)
																									model.eval()
																									with torch.no_grad():
																																_A					:     int     = model(**self._prepare_for_class(UpperCamelCase__				,							UpperCamelCase__))

																									self.assertEqual(out_len + 1				,							len(UpperCamelCase__))

																									_A					:     str     = outputs.attentions

																									self.assertEqual(len(UpperCamelCase__)				,							self.model_tester.num_hidden_layers)
																									self.assertListEqual(
																									    list(self_attentions[0].shape[-3:])				,							[self.model_tester.num_attention_heads, seq_len, seq_len]				,							)


				def        A   (  self      :							Dict):
											def check_hidden_states_output(SCREAMING_SNAKE_CASE      :							Dict				,							SCREAMING_SNAKE_CASE      :							str				,							SCREAMING_SNAKE_CASE      :							Dict):
																		_A					:     Union[str, Any]     = model_class(UpperCamelCase__)
																		model.to(UpperCamelCase__)
																		model.eval()

																		with torch.no_grad():
																									_A					:     Optional[Any]     = model(**self._prepare_for_class(UpperCamelCase__				,							UpperCamelCase__))

																		_A					:     Optional[Any]     = outputs.hidden_states
																		_A					:     int     = self.model_tester.num_hidden_layers + 1
																		self.assertEqual(len(UpperCamelCase__)				,							UpperCamelCase__)

																		_A					:     int     = self.model_tester.seq_length - self.model_tester.num_masks
																		_A					:     List[Any]     = num_visible_patches if model_class == VideoMAEForPreTraining else self.model_tester.seq_length

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

											_A  ,			_A					:     List[str]     = self.model_tester.prepare_config_and_inputs_for_common()

											for model_class in self.all_model_classes:
																		_A					:     Any     = True
																		check_hidden_states_output(UpperCamelCase__				,							UpperCamelCase__				,							UpperCamelCase__)

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

																		check_hidden_states_output(UpperCamelCase__				,							UpperCamelCase__				,							UpperCamelCase__)


				@unittest.skip('Will be fixed soon by reducing the size of the model used for common tests.')
				def        A   (  self      :							List[Any]):
											pass






def 				lowerCAmelCase__	(    ):
							_A					:     str     = hf_hub_download(
							    repo_id='hf-internal-testing/spaghetti-video'  ,filename='eating_spaghetti.npy'  ,repo_type='dataset'       )
							_A					:     Union[str, Any]     = np.load(UpperCAmelCase__       )
							return list(UpperCAmelCase__       )


@require_torch
@require_vision
class 			__lowerCamelCase			(	unittest.TestCase	):
				"""simple docstring"""


				@cached_property
				def        A   (  self      :							Tuple):
											return (
											    VideoMAEImageProcessor(image_mean=[0.5, 0.5, 0.5]				,							image_std=[0.5, 0.5, 0.5])
											    if is_vision_available()
											    else None
											)


				@slow
				def        A   (  self      :							Tuple):
											_A					:     Dict     = VideoMAEForVideoClassification.from_pretrained('MCG-NJU/videomae-base-finetuned-kinetics').to(
											    UpperCamelCase__)

											_A					:     Any     = self.default_image_processor
											_A					:     Optional[int]     = prepare_video()
											_A					:     str     = image_processor(UpperCamelCase__				,							return_tensors='pt').to(UpperCamelCase__)

											# forward pass
											with torch.no_grad():
																		_A					:     Optional[int]     = model(**UpperCamelCase__)

											# verify the logits
											_A					:     int     = torch.Size((1, 400))
											self.assertEqual(outputs.logits.shape				,							UpperCamelCase__)

											_A					:     List[str]     = torch.tensor([0.3669, -0.0688, -0.2421]).to(UpperCamelCase__)

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


				@slow
				def        A   (  self      :							Any):
											_A					:     Dict     = VideoMAEForPreTraining.from_pretrained('MCG-NJU/videomae-base-short').to(UpperCamelCase__)

											_A					:     str     = self.default_image_processor
											_A					:     Any     = prepare_video()
											_A					:     Optional[Any]     = image_processor(UpperCamelCase__				,							return_tensors='pt').to(UpperCamelCase__)

											# add boolean mask, indicating which patches to mask
											_A					:     Tuple     = hf_hub_download(repo_id='hf-internal-testing/bool-masked-pos'				,							filename='bool_masked_pos.pt')
											_A					:     str     = torch.load(UpperCamelCase__)

											# forward pass
											with torch.no_grad():
																		_A					:     Optional[Any]     = model(**UpperCamelCase__)

											# verify the logits
											_A					:     Optional[Any]     = torch.Size([1, 1408, 1536])
											_A					:     List[Any]     = torch.tensor(
											    [[0.7994, 0.9612, 0.8508], [0.7401, 0.8958, 0.8302], [0.5862, 0.7468, 0.7325]]				,							device=UpperCamelCase__)
											self.assertEqual(outputs.logits.shape				,							UpperCamelCase__)
											self.assertTrue(torch.allclose(outputs.logits[0, :3, :3]				,							UpperCamelCase__				,							atol=1e-4))

											# verify the loss (`config.norm_pix_loss` = `True`)
											_A					:     Optional[int]     = torch.tensor([0.5142]				,							device=UpperCamelCase__)
											self.assertTrue(torch.allclose(outputs.loss				,							UpperCamelCase__				,							atol=1e-4))

											# verify the loss (`config.norm_pix_loss` = `False`)
											_A					:     str     = VideoMAEForPreTraining.from_pretrained('MCG-NJU/videomae-base-short'				,							norm_pix_loss=UpperCamelCase__).to(
											    UpperCamelCase__)

											with torch.no_grad():
																		_A					:     Any     = model(**UpperCamelCase__)

											_A					:     Any     = torch.tensor(torch.tensor([0.6469])				,							device=UpperCamelCase__)
											self.assertTrue(torch.allclose(outputs.loss				,							UpperCamelCase__				,							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 			__lowerCamelCase			(	a_    , unittest.TestCase	):
    """simple docstring"""
    a													=   KandinskyVaaPriorPipeline
    a													=   ["prompt"]
    a													=   ["prompt", "negative_prompt"]
    a													=   [
        "num_images_per_prompt",
        "generator",
        "num_inference_steps",
        "latents",
        "negative_prompt",
        "guidance_scale",
        "output_type",
        "return_dict",
    ]
    a													=   False


    @property
    def        A   (  self      :							List[str]):
           return 32


    @property
    def        A   (  self      :							List[Any]):
           return 32


    @property
    def        A   (  self      :							Dict):
           return self.time_input_dim


    @property
    def        A   (  self      :							Tuple):
           return self.time_input_dim * 4


    @property
    def        A   (  self      :							Optional[int]):
           return 100


    @property
    def        A   (  self      :							Dict):
           _A					:     Tuple     = CLIPTokenizer.from_pretrained('hf-internal-testing/tiny-random-clip')
           return tokenizer


    @property
    def        A   (  self      :							Optional[Any]):
           torch.manual_seed(0)
           _A					:     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=37				,							layer_norm_eps=1e-05				,							num_attention_heads=4				,							num_hidden_layers=5				,							pad_token_id=1				,							vocab_size=1000				,							)
           return CLIPTextModelWithProjection(SCREAMING_SNAKE_CASE)


    @property
    def        A   (  self      :							List[Any]):
           torch.manual_seed(0)

           _A					:     Optional[Any]     = {
               'num_attention_heads': 2,
               'attention_head_dim': 12,
               'embedding_dim': self.text_embedder_hidden_size,
               'num_layers': 1,
           }

           _A					:     Any     = PriorTransformer(**SCREAMING_SNAKE_CASE)
           # 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
           _A					:     str     = nn.Parameter(torch.ones(model.clip_std.shape))
           return model


    @property
    def        A   (  self      :							List[str]):
           torch.manual_seed(0)
           _A					:     List[Any]     = CLIPVisionConfig(
               hidden_size=self.text_embedder_hidden_size				,							image_size=224				,							projection_dim=self.text_embedder_hidden_size				,							intermediate_size=37				,							num_attention_heads=4				,							num_channels=3				,							num_hidden_layers=5				,							patch_size=14				,							)

           _A					:     Union[str, Any]     = CLIPVisionModelWithProjection(SCREAMING_SNAKE_CASE)
           return model


    @property
    def        A   (  self      :							int):
           _A					:     Optional[Any]     = CLIPImageProcessor(
               crop_size=224				,							do_center_crop=SCREAMING_SNAKE_CASE				,							do_normalize=SCREAMING_SNAKE_CASE				,							do_resize=SCREAMING_SNAKE_CASE				,							image_mean=[0.4814_5466, 0.457_8275, 0.4082_1073]				,							image_std=[0.2686_2954, 0.2613_0258, 0.2757_7711]				,							resample=3				,							size=224				,							)

           return image_processor


    def        A   (  self      :							Optional[Any]):
           _A					:     Optional[int]     = self.dummy_prior
           _A					:     Dict     = self.dummy_image_encoder
           _A					:     Dict     = self.dummy_text_encoder
           _A					:     str     = self.dummy_tokenizer
           _A					:     Optional[Any]     = self.dummy_image_processor

           _A					:     Optional[Any]     = UnCLIPScheduler(
               variance_type='fixed_small_log'				,							prediction_type='sample'				,							num_train_timesteps=1000				,							clip_sample=SCREAMING_SNAKE_CASE				,							clip_sample_range=10.0				,							)

           _A					:     Dict     = {
               'prior': prior,
               'image_encoder': image_encoder,
               'text_encoder': text_encoder,
               'tokenizer': tokenizer,
               'scheduler': scheduler,
               'image_processor': image_processor,
           }

           return components


    def        A   (  self      :							Tuple				,							SCREAMING_SNAKE_CASE      :							List[Any]				,							SCREAMING_SNAKE_CASE      :							List[str]=0):
           if str(SCREAMING_SNAKE_CASE).startswith('mps'):
                  _A					:     Dict     = torch.manual_seed(SCREAMING_SNAKE_CASE)
           else:
                  _A					:     int     = torch.Generator(device=SCREAMING_SNAKE_CASE).manual_seed(SCREAMING_SNAKE_CASE)
           _A					:     List[Any]     = {
               'prompt': 'horse',
               'generator': generator,
               'guidance_scale': 4.0,
               'num_inference_steps': 2,
               'output_type': 'np',
           }
           return inputs


    def        A   (  self      :							List[Any]):
           _A					:     str     = 'cpu'

           _A					:     Tuple     = self.get_dummy_components()

           _A					:     List[Any]     = self.pipeline_class(**SCREAMING_SNAKE_CASE)
           _A					:     Any     = pipe.to(SCREAMING_SNAKE_CASE)

           pipe.set_progress_bar_config(disable=SCREAMING_SNAKE_CASE)

           _A					:     Dict     = pipe(**self.get_dummy_inputs(SCREAMING_SNAKE_CASE))
           _A					:     str     = output.image_embeds

           _A					:     Optional[int]     = pipe(
               **self.get_dummy_inputs(SCREAMING_SNAKE_CASE)				,							return_dict=SCREAMING_SNAKE_CASE				,							)[0]

           _A					:     Optional[int]     = image[0, -10:]
           _A					:     int     = image_from_tuple[0, -10:]

           assert image.shape == (1, 32)

           _A					:     Dict     = np.array(
               [-0.0532, 1.7120, 0.3656, -1.0852, -0.8946, -1.1756, 0.4348, 0.2482, 0.5146, -0.1156])

           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      :							Any):
           _A					:     Tuple     = torch_device == 'cpu'
           _A					:     Optional[int]     = True
           _A					:     Tuple     = False

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


    @skip_mps
    def        A   (  self      :							int):
           _A					:     Tuple     = torch_device == 'cpu'
           _A					:     Optional[Any]     = False

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






