






'''simple docstring'''
import inspect
import unittest

from transformers import MobileViTConfig
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 transformers import MobileViTForImageClassification, MobileViTForSemanticSegmentation, MobileViTModel
 from transformers.models.mobilevit.modeling_mobilevit import MOBILEVIT_PRETRAINED_MODEL_ARCHIVE_LIST


if is_vision_available():
 from PIL import Image

 from transformers import MobileViTImageProcessor


class        _UpperCAmelCase						(		a__			):




    def 				lowerCAmelCase__				(			self  :       Union[str, Any]			):






       '''simple docstring'''






       lowercase_	:    List[Any]           =     self.config_class(**self.inputs_dict			)
       self.parent.assertTrue(hasattr(lowerCAmelCase__  ,     "hidden_sizes"			)			)
       self.parent.assertTrue(hasattr(lowerCAmelCase__  ,     "neck_hidden_sizes"			)			)
       self.parent.assertTrue(hasattr(lowerCAmelCase__  ,     "num_attention_heads"			)			)


class        _UpperCAmelCase						:




    def __init__(			self  :       List[str]  ,     a  :       Optional[int]  ,     a  :       List[Any]=1_3  ,     a  :       List[Any]=3_2  ,     a  :       List[str]=2  ,     a  :       List[Any]=3  ,     a  :       Optional[Any]=6_4_0  ,     a  :       Optional[int]=4  ,     a  :       Optional[int]="silu"  ,     a  :       Optional[int]=3  ,     a  :       List[Any]=3_2  ,     a  :       Tuple=0.1  ,     a  :       Any=0.1  ,     a  :       List[Any]=0.1  ,     a  :       List[Any]=0.02  ,     a  :       int=True  ,     a  :       Optional[Any]=True  ,     a  :       Optional[Any]=1_0  ,     a  :       Union[str, Any]=None  ,     ):






       '''simple docstring'''






       lowercase_	:    List[Any]           =     parent
       lowercase_	:    Tuple           =     batch_size
       lowercase_	:    int           =     image_size
       lowercase_	:    Tuple           =     patch_size
       lowercase_	:    Tuple           =     num_channels
       lowercase_	:    str           =     last_hidden_size
       lowercase_	:    List[str]           =     num_attention_heads
       lowercase_	:    Optional[int]           =     hidden_act
       lowercase_	:    Dict           =     conv_kernel_size
       lowercase_	:    Any           =     output_stride
       lowercase_	:    Tuple           =     hidden_dropout_prob
       lowercase_	:    Union[str, Any]           =     attention_probs_dropout_prob
       lowercase_	:    str           =     classifier_dropout_prob
       lowercase_	:    List[Any]           =     use_labels
       lowercase_	:    Dict           =     is_training
       lowercase_	:    int           =     num_labels
       lowercase_	:    Tuple           =     initializer_range
       lowercase_	:    Optional[int]           =     scope




    def 				lowerCAmelCase__				(			self  :       Optional[int]			):






       '''simple docstring'''






       lowercase_	:    Optional[Any]           =     floats_tensor([self.batch_size, self.num_channels, self.image_size, self.image_size]			)

       lowercase_	:    int           =     None
       lowercase_	:    List[str]           =     None
       if self.use_labels:
          lowercase_	:    int           =     ids_tensor([self.batch_size]  ,     self.num_labels			)
          lowercase_	:    Tuple           =     ids_tensor([self.batch_size, self.image_size, self.image_size]  ,     self.num_labels			)

       lowercase_	:    Dict           =     self.get_config()

       return config, pixel_values, labels, pixel_labels




    def 				lowerCAmelCase__				(			self  :       Optional[Any]			):






       '''simple docstring'''






       return MobileViTConfig(
           image_size=self.image_size  ,     patch_size=self.patch_size  ,     num_channels=self.num_channels  ,     num_attention_heads=self.num_attention_heads  ,     hidden_act=self.hidden_act  ,     conv_kernel_size=self.conv_kernel_size  ,     output_stride=self.output_stride  ,     hidden_dropout_prob=self.hidden_dropout_prob  ,     attention_probs_dropout_prob=self.attention_probs_dropout_prob  ,     classifier_dropout_prob=self.classifier_dropout_prob  ,     initializer_range=self.initializer_range  ,     )




    def 				lowerCAmelCase__				(			self  :       Optional[Any]  ,     a  :       List[str]  ,     a  :       List[str]  ,     a  :       Tuple  ,     a  :       List[Any]			):






       '''simple docstring'''






       lowercase_	:    Tuple           =     MobileViTModel(config=lowerCAmelCase__			)
       model.to(lowerCAmelCase__			)
       model.eval()
       lowercase_	:    Any           =     model(lowerCAmelCase__			)
       self.parent.assertEqual(
           result.last_hidden_state.shape  ,     (
               self.batch_size,
               self.last_hidden_size,
               self.image_size // self.output_stride,
               self.image_size // self.output_stride,
           )  ,     )




    def 				lowerCAmelCase__				(			self  :       int  ,     a  :       List[Any]  ,     a  :       Optional[int]  ,     a  :       List[Any]  ,     a  :       Tuple			):






       '''simple docstring'''






       lowercase_	:    Optional[int]           =     self.num_labels
       lowercase_	:    Optional[Any]           =     MobileViTForImageClassification(lowerCAmelCase__			)
       model.to(lowerCAmelCase__			)
       model.eval()
       lowercase_	:    int           =     model(lowerCAmelCase__  ,     labels=lowerCAmelCase__			)
       self.parent.assertEqual(result.logits.shape  ,     (self.batch_size, self.num_labels)			)




    def 				lowerCAmelCase__				(			self  :       int  ,     a  :       Optional[int]  ,     a  :       Dict  ,     a  :       Union[str, Any]  ,     a  :       List[str]			):






       '''simple docstring'''






       lowercase_	:    List[str]           =     self.num_labels
       lowercase_	:    List[Any]           =     MobileViTForSemanticSegmentation(lowerCAmelCase__			)
       model.to(lowerCAmelCase__			)
       model.eval()
       lowercase_	:    Optional[Any]           =     model(lowerCAmelCase__			)
       self.parent.assertEqual(
           result.logits.shape  ,     (
               self.batch_size,
               self.num_labels,
               self.image_size // self.output_stride,
               self.image_size // self.output_stride,
           )  ,     )
       lowercase_	:    List[str]           =     model(lowerCAmelCase__  ,     labels=lowerCAmelCase__			)
       self.parent.assertEqual(
           result.logits.shape  ,     (
               self.batch_size,
               self.num_labels,
               self.image_size // self.output_stride,
               self.image_size // self.output_stride,
           )  ,     )





    def 				lowerCAmelCase__				(			self  :       List[str]			):






       '''simple docstring'''






       lowercase_	:    Tuple           =     self.prepare_config_and_inputs()
       lowercase_	:    Any           =     config_and_inputs
       lowercase_	:    Dict           =     {"pixel_values": pixel_values}
       return config, inputs_dict


@require_torch
class        _UpperCAmelCase						(		a__				,					a__				,					unittest.TestCase			):
    __lowerCamelCase:   str		       =    (
        (MobileViTModel, MobileViTForImageClassification, MobileViTForSemanticSegmentation)
        if is_torch_available()
        else ()
    )
    __lowerCamelCase:   List[Any]		       =    (
        {
            """feature-extraction""": MobileViTModel,
            """image-classification""": MobileViTForImageClassification,
            """image-segmentation""": MobileViTForSemanticSegmentation,
        }
        if is_torch_available()
        else {}
    )

    __lowerCamelCase:   Optional[int]		       =    False
    __lowerCamelCase:   List[str]		       =    False
    __lowerCamelCase:   List[str]		       =    False
    __lowerCamelCase:   Any		       =    False




    def 				lowerCAmelCase__				(			self  :       Any			):






       '''simple docstring'''






       lowercase_	:    Optional[Any]           =     MobileViTModelTester(self			)
       lowercase_	:    Union[str, Any]           =     MobileViTConfigTester(self  ,     config_class=lowerCAmelCase__  ,     has_text_modality=lowerCAmelCase__			)




    def 				lowerCAmelCase__				(			self  :       Optional[Any]			):






       '''simple docstring'''






       self.config_tester.run_common_tests()




    @unittest.skip(reason="MobileViT does not use inputs_embeds"			)
    def 				lowerCAmelCase__				(			self  :       Dict			):






       '''simple docstring'''






       pass




    @unittest.skip(reason="MobileViT does not support input and output embeddings"			)
    def 				lowerCAmelCase__				(			self  :       Tuple			):






       '''simple docstring'''






       pass




    @unittest.skip(reason="MobileViT does not output attentions"			)
    def 				lowerCAmelCase__				(			self  :       int			):






       '''simple docstring'''






       pass




    def 				lowerCAmelCase__				(			self  :       str			):






       '''simple docstring'''






       lowercase_	:    int           =     self.model_tester.prepare_config_and_inputs_for_common()

       for model_class in self.all_model_classes:
          lowercase_	:    Union[str, Any]           =     model_class(lowerCAmelCase__			)
          lowercase_	:    Dict           =     inspect.signature(model.forward			)
          # signature.parameters is an OrderedDict => so arg_names order is deterministic
          lowercase_	:    int           =     [*signature.parameters.keys()]

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




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






       '''simple docstring'''






       pass




    def 				lowerCAmelCase__				(			self  :       List[Any]			):






       '''simple docstring'''






       lowercase_	:    Union[str, Any]           =     self.model_tester.prepare_config_and_inputs()
       self.model_tester.create_and_check_model(*lowerCAmelCase__			)




    def 				lowerCAmelCase__				(			self  :       Union[str, Any]			):






       '''simple docstring'''






       def check_hidden_states_output(a  :       Optional[Any]  ,     a  :       Tuple  ,     a  :       Optional[int]			):
          lowercase_	:    Optional[int]           =     model_class(lowerCAmelCase__			)
          model.to(lowerCAmelCase__			)
          model.eval()

          with torch.no_grad():
             lowercase_	:    int           =     model(**self._prepare_for_class(lowerCAmelCase__  ,     lowerCAmelCase__			)			)

          lowercase_	:    Any           =     outputs.hidden_states

          lowercase_	:    int           =     5
          self.assertEqual(len(lowerCAmelCase__			)  ,     lowerCAmelCase__			)

          # MobileViT's feature maps are of shape (batch_size, num_channels, height, width)
          # with the width and height being successively divided by 2.
          lowercase_	:    int           =     2
          for i in range(len(lowerCAmelCase__			)			):
             self.assertListEqual(
                 list(hidden_states[i].shape[-2:]			)  ,     [self.model_tester.image_size // divisor, self.model_tester.image_size // divisor]  ,     )
             divisor *= 2

          self.assertEqual(self.model_tester.output_stride  ,     divisor // 2			)

       lowercase_	:    int           =     self.model_tester.prepare_config_and_inputs_for_common()

       for model_class in self.all_model_classes:
          lowercase_	:    Dict           =     True
          check_hidden_states_output(lowerCAmelCase__  ,     lowerCAmelCase__  ,     lowerCAmelCase__			)

          # check that output_hidden_states also work using config
          del inputs_dict["output_hidden_states"]
          lowercase_	:    Optional[Any]           =     True

          check_hidden_states_output(lowerCAmelCase__  ,     lowerCAmelCase__  ,     lowerCAmelCase__			)




    def 				lowerCAmelCase__				(			self  :       int			):






       '''simple docstring'''






       lowercase_	:    Any           =     self.model_tester.prepare_config_and_inputs()
       self.model_tester.create_and_check_for_image_classification(*lowerCAmelCase__			)




    def 				lowerCAmelCase__				(			self  :       str			):






       '''simple docstring'''






       lowercase_	:    List[Any]           =     self.model_tester.prepare_config_and_inputs()
       self.model_tester.create_and_check_for_semantic_segmentation(*lowerCAmelCase__			)





    @slow
    def 				lowerCAmelCase__				(			self  :       Optional[Any]			):






       '''simple docstring'''






       for model_name in MOBILEVIT_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
          lowercase_	:    str           =     MobileViTModel.from_pretrained(lowerCAmelCase__			)
          self.assertIsNotNone(lowerCAmelCase__			)




def 		__SCREAMING_SNAKE_CASE					(    ):


   """simple docstring"""




   lowercase_	:    str           =     Image.open("./tests/fixtures/tests_samples/COCO/000000039769.png"							)
   return image





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




    @cached_property
    def 				lowerCAmelCase__				(			self  :       List[Any]			):






       '''simple docstring'''






       return MobileViTImageProcessor.from_pretrained("apple/mobilevit-xx-small"			) if is_vision_available() else None




    @slow
    def 				lowerCAmelCase__				(			self  :       List[str]			):






       '''simple docstring'''






       lowercase_	:    List[str]           =     MobileViTForImageClassification.from_pretrained("apple/mobilevit-xx-small"			).to(lowerCAmelCase__			)

       lowercase_	:    Any           =     self.default_image_processor
       lowercase_	:    Dict           =     prepare_img()
       lowercase_	:    List[str]           =     image_processor(images=lowerCAmelCase__  ,     return_tensors="pt"			).to(lowerCAmelCase__			)

       # forward pass
       with torch.no_grad():
          lowercase_	:    List[str]           =     model(**lowerCAmelCase__			)

       # verify the logits
       lowercase_	:    Any           =     torch.Size((1, 1_0_0_0)			)
       self.assertEqual(outputs.logits.shape  ,     lowerCAmelCase__			)

       lowercase_	:    Optional[Any]           =     torch.tensor([-1.9364, -1.2327, -0.4653]			).to(lowerCAmelCase__			)

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




    @slow
    def 				lowerCAmelCase__				(			self  :       Optional[int]			):






       '''simple docstring'''






       lowercase_	:    Optional[Any]           =     MobileViTForSemanticSegmentation.from_pretrained("apple/deeplabv3-mobilevit-xx-small"			)
       lowercase_	:    int           =     model.to(lowerCAmelCase__			)

       lowercase_	:    Union[str, Any]           =     MobileViTImageProcessor.from_pretrained("apple/deeplabv3-mobilevit-xx-small"			)

       lowercase_	:    Optional[int]           =     prepare_img()
       lowercase_	:    Any           =     image_processor(images=lowerCAmelCase__  ,     return_tensors="pt"			).to(lowerCAmelCase__			)

       # forward pass
       with torch.no_grad():
          lowercase_	:    Tuple           =     model(**lowerCAmelCase__			)
       lowercase_	:    Union[str, Any]           =     outputs.logits

       # verify the logits
       lowercase_	:    Dict           =     torch.Size((1, 2_1, 3_2, 3_2)			)
       self.assertEqual(logits.shape  ,     lowerCAmelCase__			)

       lowercase_	:    List[str]           =     torch.tensor(
           [
               [[6.9713, 6.9786, 7.2422], [7.2893, 7.2825, 7.4446], [7.6580, 7.8797, 7.9420]],
               [[-10.6869, -10.3250, -10.3471], [-10.4228, -9.9868, -9.7132], [-11.0405, -11.0221, -10.7318]],
               [[-3.3089, -2.8539, -2.6740], [-3.2706, -2.5621, -2.5108], [-3.2534, -2.6615, -2.6651]],
           ]  ,     device=lowerCAmelCase__  ,     )

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





    @slow
    def 				lowerCAmelCase__				(			self  :       Dict			):






       '''simple docstring'''






       lowercase_	:    Optional[int]           =     MobileViTForSemanticSegmentation.from_pretrained("apple/deeplabv3-mobilevit-xx-small"			)
       lowercase_	:    Dict           =     model.to(lowerCAmelCase__			)

       lowercase_	:    Optional[Any]           =     MobileViTImageProcessor.from_pretrained("apple/deeplabv3-mobilevit-xx-small"			)

       lowercase_	:    Union[str, Any]           =     prepare_img()
       lowercase_	:    Tuple           =     image_processor(images=lowerCAmelCase__  ,     return_tensors="pt"			).to(lowerCAmelCase__			)

       # forward pass
       with torch.no_grad():
          lowercase_	:    Tuple           =     model(**lowerCAmelCase__			)

       lowercase_	:    Union[str, Any]           =     outputs.logits.detach().cpu()

       lowercase_	:    int           =     image_processor.post_process_semantic_segmentation(outputs=lowerCAmelCase__  ,     target_sizes=[(5_0, 6_0)]			)
       lowercase_	:    Tuple           =     torch.Size((5_0, 6_0)			)
       self.assertEqual(segmentation[0].shape  ,     lowerCAmelCase__			)

       lowercase_	:    Tuple           =     image_processor.post_process_semantic_segmentation(outputs=lowerCAmelCase__			)
       lowercase_	:    Optional[int]           =     torch.Size((3_2, 3_2)			)
       self.assertEqual(segmentation[0].shape  ,     lowerCAmelCase__			)












'''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						(		snake_case				,					unittest.TestCase			):
    __lowerCamelCase:   Dict		       =    KandinskyVaaPriorPipeline
    __lowerCamelCase:   Optional[int]		       =    ['prompt']
    __lowerCamelCase:   Any		       =    ['prompt', 'negative_prompt']
    __lowerCamelCase:   List[Any]		       =    [
        'num_images_per_prompt',
        'generator',
        'num_inference_steps',
        'latents',
        'negative_prompt',
        'guidance_scale',
        'output_type',
        'return_dict',
    ]
    __lowerCamelCase:   List[Any]		       =    False




    @property
    def 				lowerCAmelCase__				(			self  :       Optional[Any]			):






       '''simple docstring'''






       return 3_2




    @property
    def 				lowerCAmelCase__				(			self  :       Any			):






       '''simple docstring'''






       return 3_2




    @property
    def 				lowerCAmelCase__				(			self  :       Any			):






       '''simple docstring'''






       return self.time_input_dim




    @property
    def 				lowerCAmelCase__				(			self  :       str			):






       '''simple docstring'''






       return self.time_input_dim * 4




    @property
    def 				lowerCAmelCase__				(			self  :       Union[str, Any]			):






       '''simple docstring'''






       return 1_0_0




    @property
    def 				lowerCAmelCase__				(			self  :       List[Any]			):






       '''simple docstring'''






       lowercase_	:    Any           =     CLIPTokenizer.from_pretrained("hf-internal-testing/tiny-random-clip"			)
       return tokenizer




    @property
    def 				lowerCAmelCase__				(			self  :       Optional[Any]			):






       '''simple docstring'''






       torch.manual_seed(0			)
       lowercase_	:    Tuple           =     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-05  ,     num_attention_heads=4  ,     num_hidden_layers=5  ,     pad_token_id=1  ,     vocab_size=1_0_0_0  ,     )
       return CLIPTextModelWithProjection(a			)




    @property
    def 				lowerCAmelCase__				(			self  :       Tuple			):






       '''simple docstring'''






       torch.manual_seed(0			)

       lowercase_	:    List[str]           =     {
           "num_attention_heads": 2,
           "attention_head_dim": 1_2,
           "embedding_dim": self.text_embedder_hidden_size,
           "num_layers": 1,
       }

       lowercase_	:    Union[str, Any]           =     PriorTransformer(**a			)
       # 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
       lowercase_	:    List[Any]           =     nn.Parameter(torch.ones(model.clip_std.shape			)			)
       return model




    @property
    def 				lowerCAmelCase__				(			self  :       Tuple			):






       '''simple docstring'''






       torch.manual_seed(0			)
       lowercase_	:    Dict           =     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  ,     )

       lowercase_	:    Optional[Any]           =     CLIPVisionModelWithProjection(a			)
       return model




    @property
    def 				lowerCAmelCase__				(			self  :       List[str]			):






       '''simple docstring'''






       lowercase_	:    List[str]           =     CLIPImageProcessor(
           crop_size=2_2_4  ,     do_center_crop=a  ,     do_normalize=a  ,     do_resize=a  ,     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=2_2_4  ,     )

       return image_processor




    def 				lowerCAmelCase__				(			self  :       List[str]			):






       '''simple docstring'''






       lowercase_	:    Any           =     self.dummy_prior
       lowercase_	:    Optional[Any]           =     self.dummy_image_encoder
       lowercase_	:    List[Any]           =     self.dummy_text_encoder
       lowercase_	:    Any           =     self.dummy_tokenizer
       lowercase_	:    Optional[Any]           =     self.dummy_image_processor

       lowercase_	:    List[str]           =     UnCLIPScheduler(
           variance_type="fixed_small_log"  ,     prediction_type="sample"  ,     num_train_timesteps=1_0_0_0  ,     clip_sample=a  ,     clip_sample_range=10.0  ,     )

       lowercase_	:    List[Any]           =     {
           "prior": prior,
           "image_encoder": image_encoder,
           "text_encoder": text_encoder,
           "tokenizer": tokenizer,
           "scheduler": scheduler,
           "image_processor": image_processor,
       }

       return components




    def 				lowerCAmelCase__				(			self  :       Any  ,     a  :       Dict  ,     a  :       Dict=0			):






       '''simple docstring'''






       if str(a			).startswith("mps"			):
          lowercase_	:    int           =     torch.manual_seed(a			)
       else:
          lowercase_	:    Optional[Any]           =     torch.Generator(device=a			).manual_seed(a			)
       lowercase_	:    Any           =     {
           "prompt": "horse",
           "generator": generator,
           "guidance_scale": 4.0,
           "num_inference_steps": 2,
           "output_type": "np",
       }
       return inputs




    def 				lowerCAmelCase__				(			self  :       Union[str, Any]			):






       '''simple docstring'''






       lowercase_	:    str           =     "cpu"

       lowercase_	:    Any           =     self.get_dummy_components()

       lowercase_	:    int           =     self.pipeline_class(**a			)
       lowercase_	:    Any           =     pipe.to(a			)

       pipe.set_progress_bar_config(disable=a			)

       lowercase_	:    Any           =     pipe(**self.get_dummy_inputs(a			)			)
       lowercase_	:    List[Any]           =     output.image_embeds

       lowercase_	:    str           =     pipe(
           **self.get_dummy_inputs(a			)  ,     return_dict=a  ,     )[0]

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

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

       lowercase_	:    int           =     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 				lowerCAmelCase__				(			self  :       Optional[Any]			):






       '''simple docstring'''






       lowercase_	:    int           =     torch_device == "cpu"
       lowercase_	:    Tuple           =     True
       lowercase_	:    str           =     False

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





    @skip_mps
    def 				lowerCAmelCase__				(			self  :       Union[str, Any]			):






       '''simple docstring'''






       lowercase_	:    Any           =     torch_device == "cpu"
       lowercase_	:    int           =     False

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




