"""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  _snake_case     (					a__		):






						def       lowerCamelCase__     (       self      :			Optional[int]    ):
													__lowerCamelCase					:		List[str]		   =     self.config_class(**self.inputs_dict    )
													self.parent.assertTrue(hasattr(UpperCAmelCase							,					"hidden_sizes"    )    )
													self.parent.assertTrue(hasattr(UpperCAmelCase							,					"neck_hidden_sizes"    )    )
													self.parent.assertTrue(hasattr(UpperCAmelCase							,					"num_attention_heads"    )    )

class  _snake_case     :






						def __init__(       self      :			int							,					UpperCAmelCase      :			List[str]							,					UpperCAmelCase      :			Dict=13							,					UpperCAmelCase      :			Any=32							,					UpperCAmelCase      :			List[str]=2							,					UpperCAmelCase      :			Optional[Any]=3							,					UpperCAmelCase      :			Dict=640							,					UpperCAmelCase      :			int=4							,					UpperCAmelCase      :			str="silu"							,					UpperCAmelCase      :			Optional[int]=3							,					UpperCAmelCase      :			Optional[int]=32							,					UpperCAmelCase      :			List[Any]=0.1							,					UpperCAmelCase      :			List[str]=0.1							,					UpperCAmelCase      :			Optional[Any]=0.1							,					UpperCAmelCase      :			int=0.0_2							,					UpperCAmelCase      :			List[str]=True							,					UpperCAmelCase      :			str=True							,					UpperCAmelCase      :			Union[str, Any]=10							,					UpperCAmelCase      :			List[Any]=None							,					):
													__lowerCamelCase					:		Tuple		   =     parent
													__lowerCamelCase					:		str		   =     batch_size
													__lowerCamelCase					:		str		   =     image_size
													__lowerCamelCase					:		Optional[Any]		   =     patch_size
													__lowerCamelCase					:		Any		   =     num_channels
													__lowerCamelCase					:		Union[str, Any]		   =     last_hidden_size
													__lowerCamelCase					:		str		   =     num_attention_heads
													__lowerCamelCase					:		List[Any]		   =     hidden_act
													__lowerCamelCase					:		Any		   =     conv_kernel_size
													__lowerCamelCase					:		Any		   =     output_stride
													__lowerCamelCase					:		Any		   =     hidden_dropout_prob
													__lowerCamelCase					:		Dict		   =     attention_probs_dropout_prob
													__lowerCamelCase					:		Union[str, Any]		   =     classifier_dropout_prob
													__lowerCamelCase					:		Optional[Any]		   =     use_labels
													__lowerCamelCase					:		Optional[int]		   =     is_training
													__lowerCamelCase					:		Any		   =     num_labels
													__lowerCamelCase					:		Optional[Any]		   =     initializer_range
													__lowerCamelCase					:		Tuple		   =     scope






						def       lowerCamelCase__     (       self      :			Dict    ):
													__lowerCamelCase					:		List[str]		   =     floats_tensor([self.batch_size, self.num_channels, self.image_size, self.image_size]    )

													__lowerCamelCase					:		Optional[int]		   =     None
													__lowerCamelCase					:		str		   =     None
													if self.use_labels:
																				__lowerCamelCase					:		List[Any]		   =     ids_tensor([self.batch_size]							,					self.num_labels    )
																				__lowerCamelCase					:		Dict		   =     ids_tensor([self.batch_size, self.image_size, self.image_size]							,					self.num_labels    )

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

													return config, pixel_values, labels, pixel_labels






						def       lowerCamelCase__     (       self      :			Optional[int]    ):
													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      :			Dict							,					UpperCAmelCase      :			Optional[int]							,					UpperCAmelCase      :			Union[str, Any]							,					UpperCAmelCase      :			Dict							,					UpperCAmelCase      :			Dict    ):
													__lowerCamelCase					:		Union[str, Any]		   =     MobileViTModel(config=UpperCAmelCase    )
													model.to(UpperCAmelCase    )
													model.eval()
													__lowerCamelCase					:		Optional[Any]		   =     model(UpperCAmelCase    )
													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      :			Union[str, Any]							,					UpperCAmelCase      :			Any							,					UpperCAmelCase      :			Tuple							,					UpperCAmelCase      :			Union[str, Any]							,					UpperCAmelCase      :			Optional[int]    ):
													__lowerCamelCase					:		Tuple		   =     self.num_labels
													__lowerCamelCase					:		Any		   =     MobileViTForImageClassification(UpperCAmelCase    )
													model.to(UpperCAmelCase    )
													model.eval()
													__lowerCamelCase					:		Any		   =     model(UpperCAmelCase							,					labels=UpperCAmelCase    )
													self.parent.assertEqual(result.logits.shape							,					(self.batch_size, self.num_labels)    )






						def       lowerCamelCase__     (       self      :			Union[str, Any]							,					UpperCAmelCase      :			Dict							,					UpperCAmelCase      :			int							,					UpperCAmelCase      :			str							,					UpperCAmelCase      :			List[Any]    ):
													__lowerCamelCase					:		Union[str, Any]		   =     self.num_labels
													__lowerCamelCase					:		Optional[int]		   =     MobileViTForSemanticSegmentation(UpperCAmelCase    )
													model.to(UpperCAmelCase    )
													model.eval()
													__lowerCamelCase					:		List[Any]		   =     model(UpperCAmelCase    )
													self.parent.assertEqual(
													    result.logits.shape							,					(
													        self.batch_size,
													        self.num_labels,
													        self.image_size // self.output_stride,
													        self.image_size // self.output_stride,
													    )							,					)
													__lowerCamelCase					:		List[str]		   =     model(UpperCAmelCase							,					labels=UpperCAmelCase    )
													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      :			Tuple    ):
													__lowerCamelCase					:		Dict		   =     self.prepare_config_and_inputs()
													__lowerCamelCase   ,  __lowerCamelCase   ,  __lowerCamelCase   ,  __lowerCamelCase					:		Optional[Any]		   =     config_and_inputs
													__lowerCamelCase					:		str		   =     {"pixel_values": pixel_values}
													return config, inputs_dict

@require_torch
class  _snake_case     (					a__				, a__				, unittest.TestCase		):
						snake_case__			  =			(
						    (MobileViTModel, MobileViTForImageClassification, MobileViTForSemanticSegmentation)
						    if is_torch_available()
						    else ()
						)
						snake_case__			  =			(
						    {
						        "feature-extraction": MobileViTModel,
						        "image-classification": MobileViTForImageClassification,
						        "image-segmentation": MobileViTForSemanticSegmentation,
						    }
						    if is_torch_available()
						    else {}
						)

						snake_case__			  =			False
						snake_case__			  =			False
						snake_case__			  =			False
						snake_case__			  =			False






						def       lowerCamelCase__     (       self      :			Union[str, Any]    ):
													__lowerCamelCase					:		Any		   =     MobileViTModelTester(self    )
													__lowerCamelCase					:		Optional[int]		   =     MobileViTConfigTester(self							,					config_class=UpperCAmelCase							,					has_text_modality=UpperCAmelCase    )






						def       lowerCamelCase__     (       self      :			Any    ):
													self.config_tester.run_common_tests()






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






						@unittest.skip(reason="MobileViT does not support input and output embeddings"    )
						def       lowerCamelCase__     (       self      :			Optional[Any]    ):
													pass






						@unittest.skip(reason="MobileViT does not output attentions"    )
						def       lowerCamelCase__     (       self      :			str    ):
													pass






						def       lowerCamelCase__     (       self      :			Dict    ):
													__lowerCamelCase   ,  __lowerCamelCase					:		List[Any]		   =     self.model_tester.prepare_config_and_inputs_for_common()

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

																				__lowerCamelCase					:		Optional[Any]		   =     ["pixel_values"]
																				self.assertListEqual(arg_names[:1]							,					UpperCAmelCase    )






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






						def       lowerCamelCase__     (       self      :			Tuple    ):
													__lowerCamelCase					:		List[str]		   =     self.model_tester.prepare_config_and_inputs()
													self.model_tester.create_and_check_model(*UpperCAmelCase    )






						def       lowerCamelCase__     (       self      :			int    ):
													def check_hidden_states_output(UpperCAmelCase      :			Union[str, Any]							,					UpperCAmelCase      :			Any							,					UpperCAmelCase      :			Any    ):
																				__lowerCamelCase					:		Union[str, Any]		   =     model_class(UpperCAmelCase    )
																				model.to(UpperCAmelCase    )
																				model.eval()

																				with torch.no_grad():
																											__lowerCamelCase					:		List[Any]		   =     model(**self._prepare_for_class(UpperCAmelCase							,					UpperCAmelCase    )    )

																				__lowerCamelCase					:		Dict		   =     outputs.hidden_states

																				__lowerCamelCase					:		Tuple		   =     5
																				self.assertEqual(len(UpperCAmelCase    )							,					UpperCAmelCase    )

																				# MobileViT's feature maps are of shape (batch_size, num_channels, height, width)
																				# with the width and height being successively divided by 2.
																				__lowerCamelCase					:		Optional[int]		   =     2
																				for i in range(len(UpperCAmelCase    )    ):
																											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    )

													__lowerCamelCase   ,  __lowerCamelCase					:		Dict		   =     self.model_tester.prepare_config_and_inputs_for_common()

													for model_class in self.all_model_classes:
																				__lowerCamelCase					:		List[Any]		   =     True
																				check_hidden_states_output(UpperCAmelCase							,					UpperCAmelCase							,					UpperCAmelCase    )

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

																				check_hidden_states_output(UpperCAmelCase							,					UpperCAmelCase							,					UpperCAmelCase    )






						def       lowerCamelCase__     (       self      :			int    ):
													__lowerCamelCase					:		Tuple		   =     self.model_tester.prepare_config_and_inputs()
													self.model_tester.create_and_check_for_image_classification(*UpperCAmelCase    )






						def       lowerCamelCase__     (       self      :			Union[str, Any]    ):
													__lowerCamelCase					:		int		   =     self.model_tester.prepare_config_and_inputs()
													self.model_tester.create_and_check_for_semantic_segmentation(*UpperCAmelCase    )







						@slow
						def       lowerCamelCase__     (       self      :			int    ):
													for model_name in MOBILEVIT_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
																				__lowerCamelCase					:		Tuple		   =     MobileViTModel.from_pretrained(UpperCAmelCase    )
																				self.assertIsNotNone(UpperCAmelCase    )


def    lowercase_   (   ) ->      List[str]:



							'''simple docstring'''

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







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






						@cached_property
						def       lowerCamelCase__     (       self      :			Union[str, Any]    ):
													return MobileViTImageProcessor.from_pretrained("apple/mobilevit-xx-small"    ) if is_vision_available() else None






						@slow
						def       lowerCamelCase__     (       self      :			List[str]    ):
													__lowerCamelCase					:		str		   =     MobileViTForImageClassification.from_pretrained("apple/mobilevit-xx-small"    ).to(UpperCAmelCase    )

													__lowerCamelCase					:		Tuple		   =     self.default_image_processor
													__lowerCamelCase					:		List[Any]		   =     prepare_img()
													__lowerCamelCase					:		Union[str, Any]		   =     image_processor(images=UpperCAmelCase							,					return_tensors="pt"    ).to(UpperCAmelCase    )

													# forward pass
													with torch.no_grad():
																				__lowerCamelCase					:		Dict		   =     model(**UpperCAmelCase    )

													# verify the logits
													__lowerCamelCase					:		str		   =     torch.Size((1, 1000)    )
													self.assertEqual(outputs.logits.shape							,					UpperCAmelCase    )

													__lowerCamelCase					:		Optional[Any]		   =     torch.tensor([-1.9_3_6_4, -1.2_3_2_7, -0.4_6_5_3]    ).to(UpperCAmelCase    )

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






						@slow
						def       lowerCamelCase__     (       self      :			Union[str, Any]    ):
													__lowerCamelCase					:		int		   =     MobileViTForSemanticSegmentation.from_pretrained("apple/deeplabv3-mobilevit-xx-small"    )
													__lowerCamelCase					:		Dict		   =     model.to(UpperCAmelCase    )

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

													__lowerCamelCase					:		Dict		   =     prepare_img()
													__lowerCamelCase					:		List[str]		   =     image_processor(images=UpperCAmelCase							,					return_tensors="pt"    ).to(UpperCAmelCase    )

													# forward pass
													with torch.no_grad():
																				__lowerCamelCase					:		int		   =     model(**UpperCAmelCase    )
													__lowerCamelCase					:		int		   =     outputs.logits

													# verify the logits
													__lowerCamelCase					:		Any		   =     torch.Size((1, 21, 32, 32)    )
													self.assertEqual(logits.shape							,					UpperCAmelCase    )

													__lowerCamelCase					:		Union[str, Any]		   =     torch.tensor(
													    [
													        [[6.9_7_1_3, 6.9_7_8_6, 7.2_4_2_2], [7.2_8_9_3, 7.2_8_2_5, 7.4_4_4_6], [7.6_5_8_0, 7.8_7_9_7, 7.9_4_2_0]],
													        [[-1_0.6_8_6_9, -1_0.3_2_5_0, -1_0.3_4_7_1], [-1_0.4_2_2_8, -9.9_8_6_8, -9.7_1_3_2], [-1_1.0_4_0_5, -1_1.0_2_2_1, -1_0.7_3_1_8]],
													        [[-3.3_0_8_9, -2.8_5_3_9, -2.6_7_4_0], [-3.2_7_0_6, -2.5_6_2_1, -2.5_1_0_8], [-3.2_5_3_4, -2.6_6_1_5, -2.6_6_5_1]],
													    ]							,					device=UpperCAmelCase							,					)

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







						@slow
						def       lowerCamelCase__     (       self      :			List[str]    ):
													__lowerCamelCase					:		Tuple		   =     MobileViTForSemanticSegmentation.from_pretrained("apple/deeplabv3-mobilevit-xx-small"    )
													__lowerCamelCase					:		Dict		   =     model.to(UpperCAmelCase    )

													__lowerCamelCase					:		str		   =     MobileViTImageProcessor.from_pretrained("apple/deeplabv3-mobilevit-xx-small"    )

													__lowerCamelCase					:		int		   =     prepare_img()
													__lowerCamelCase					:		Union[str, Any]		   =     image_processor(images=UpperCAmelCase							,					return_tensors="pt"    ).to(UpperCAmelCase    )

													# forward pass
													with torch.no_grad():
																				__lowerCamelCase					:		Any		   =     model(**UpperCAmelCase    )

													__lowerCamelCase					:		Dict		   =     outputs.logits.detach().cpu()

													__lowerCamelCase					:		Union[str, Any]		   =     image_processor.post_process_semantic_segmentation(outputs=UpperCAmelCase							,					target_sizes=[(50, 60)]    )
													__lowerCamelCase					:		str		   =     torch.Size((50, 60)    )
													self.assertEqual(segmentation[0].shape							,					UpperCAmelCase    )

													__lowerCamelCase					:		Dict		   =     image_processor.post_process_semantic_segmentation(outputs=UpperCAmelCase    )
													__lowerCamelCase					:		List[Any]		   =     torch.Size((32, 32)    )
													self.assertEqual(segmentation[0].shape							,					UpperCAmelCase    )
"""simple docstring"""





import unittest

import numpy as np

from transformers.testing_utils import require_torch, require_vision
from transformers.utils import is_torch_available, is_vision_available

from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs


if is_torch_available():
				import torch

if is_vision_available():
				from PIL import Image

				from transformers import LevitImageProcessor
class  _snake_case     (					unittest.TestCase		):






						def __init__(       self      :			Optional[Any]							,					UpperCAmelCase      :			Tuple							,					UpperCAmelCase      :			Optional[int]=7							,					UpperCAmelCase      :			Any=3							,					UpperCAmelCase      :			str=18							,					UpperCAmelCase      :			str=30							,					UpperCAmelCase      :			Any=400							,					UpperCAmelCase      :			List[Any]=True							,					UpperCAmelCase      :			Optional[Any]=None							,					UpperCAmelCase      :			Optional[Any]=True							,					UpperCAmelCase      :			Dict=None							,					UpperCAmelCase      :			List[str]=True							,					UpperCAmelCase      :			int=[0.5, 0.5, 0.5]							,					UpperCAmelCase      :			Tuple=[0.5, 0.5, 0.5]							,					):
													__lowerCamelCase					:		Any		   =     size if size is not None else {"shortest_edge": 18}
													__lowerCamelCase					:		Dict		   =     crop_size if crop_size is not None else {"height": 18, "width": 18}
													__lowerCamelCase					:		List[str]		   =     parent
													__lowerCamelCase					:		int		   =     batch_size
													__lowerCamelCase					:		Any		   =     num_channels
													__lowerCamelCase					:		Tuple		   =     image_size
													__lowerCamelCase					:		int		   =     min_resolution
													__lowerCamelCase					:		List[Any]		   =     max_resolution
													__lowerCamelCase					:		List[str]		   =     do_resize
													__lowerCamelCase					:		str		   =     size
													__lowerCamelCase					:		Tuple		   =     do_center_crop
													__lowerCamelCase					:		Optional[int]		   =     crop_size
													__lowerCamelCase					:		Optional[Any]		   =     do_normalize
													__lowerCamelCase					:		Optional[Any]		   =     image_mean
													__lowerCamelCase					:		List[Any]		   =     image_std







						def       lowerCamelCase__     (       self      :			int    ):
													return {
													    "image_mean": self.image_mean,
													    "image_std": self.image_std,
													    "do_normalize": self.do_normalize,
													    "do_resize": self.do_resize,
													    "do_center_crop": self.do_center_crop,
													    "size": self.size,
													    "crop_size": self.crop_size,
													}

@require_torch
@require_vision
class  _snake_case     (					a__				, unittest.TestCase		):
						snake_case__			  =			LevitImageProcessor if is_vision_available() else None






						def       lowerCamelCase__     (       self      :			Any    ):
													__lowerCamelCase					:		Optional[int]		   =     LevitImageProcessingTester(self    )






						@property
						def       lowerCamelCase__     (       self      :			Union[str, Any]    ):
													return self.image_processor_tester.prepare_image_processor_dict()






						def       lowerCamelCase__     (       self      :			List[str]    ):
													__lowerCamelCase					:		Dict		   =     self.image_processing_class(**self.image_processor_dict    )
													self.assertTrue(hasattr(UpperCAmelCase							,					"image_mean"    )    )
													self.assertTrue(hasattr(UpperCAmelCase							,					"image_std"    )    )
													self.assertTrue(hasattr(UpperCAmelCase							,					"do_normalize"    )    )
													self.assertTrue(hasattr(UpperCAmelCase							,					"do_resize"    )    )
													self.assertTrue(hasattr(UpperCAmelCase							,					"do_center_crop"    )    )
													self.assertTrue(hasattr(UpperCAmelCase							,					"size"    )    )






						def       lowerCamelCase__     (       self      :			int    ):
													__lowerCamelCase					:		str		   =     self.image_processing_class.from_dict(self.image_processor_dict    )
													self.assertEqual(image_processor.size							,					{"shortest_edge": 18}    )
													self.assertEqual(image_processor.crop_size							,					{"height": 18, "width": 18}    )

													__lowerCamelCase					:		Tuple		   =     self.image_processing_class.from_dict(self.image_processor_dict							,					size=42							,					crop_size=84    )
													self.assertEqual(image_processor.size							,					{"shortest_edge": 42}    )
													self.assertEqual(image_processor.crop_size							,					{"height": 84, "width": 84}    )






						def       lowerCamelCase__     (       self      :			Dict    ):
													pass






						def       lowerCamelCase__     (       self      :			Any    ):
													# Initialize image_processing
													__lowerCamelCase					:		Any		   =     self.image_processing_class(**self.image_processor_dict    )
													# create random PIL images
													__lowerCamelCase					:		List[str]		   =     prepare_image_inputs(self.image_processor_tester							,					equal_resolution=UpperCAmelCase    )
													for image in image_inputs:
																				self.assertIsInstance(UpperCAmelCase							,					Image.Image    )

													# Test not batched input
													__lowerCamelCase					:		Dict		   =     image_processing(image_inputs[0]							,					return_tensors="pt"    ).pixel_values
													self.assertEqual(
													    encoded_images.shape							,					(
													        1,
													        self.image_processor_tester.num_channels,
													        self.image_processor_tester.crop_size["height"],
													        self.image_processor_tester.crop_size["width"],
													    )							,					)

													# Test batched
													__lowerCamelCase					:		int		   =     image_processing(UpperCAmelCase							,					return_tensors="pt"    ).pixel_values
													self.assertEqual(
													    encoded_images.shape							,					(
													        self.image_processor_tester.batch_size,
													        self.image_processor_tester.num_channels,
													        self.image_processor_tester.crop_size["height"],
													        self.image_processor_tester.crop_size["width"],
													    )							,					)






						def       lowerCamelCase__     (       self      :			Any    ):
													# Initialize image_processing
													__lowerCamelCase					:		Any		   =     self.image_processing_class(**self.image_processor_dict    )
													# create random numpy tensors
													__lowerCamelCase					:		Tuple		   =     prepare_image_inputs(self.image_processor_tester							,					equal_resolution=UpperCAmelCase							,					numpify=UpperCAmelCase    )
													for image in image_inputs:
																				self.assertIsInstance(UpperCAmelCase							,					np.ndarray    )

													# Test not batched input
													__lowerCamelCase					:		Optional[Any]		   =     image_processing(image_inputs[0]							,					return_tensors="pt"    ).pixel_values
													self.assertEqual(
													    encoded_images.shape							,					(
													        1,
													        self.image_processor_tester.num_channels,
													        self.image_processor_tester.crop_size["height"],
													        self.image_processor_tester.crop_size["width"],
													    )							,					)

													# Test batched
													__lowerCamelCase					:		Dict		   =     image_processing(UpperCAmelCase							,					return_tensors="pt"    ).pixel_values
													self.assertEqual(
													    encoded_images.shape							,					(
													        self.image_processor_tester.batch_size,
													        self.image_processor_tester.num_channels,
													        self.image_processor_tester.crop_size["height"],
													        self.image_processor_tester.crop_size["width"],
													    )							,					)







						def       lowerCamelCase__     (       self      :			Union[str, Any]    ):
													# Initialize image_processing
													__lowerCamelCase					:		int		   =     self.image_processing_class(**self.image_processor_dict    )
													# create random PyTorch tensors
													__lowerCamelCase					:		List[Any]		   =     prepare_image_inputs(self.image_processor_tester							,					equal_resolution=UpperCAmelCase							,					torchify=UpperCAmelCase    )
													for image in image_inputs:
																				self.assertIsInstance(UpperCAmelCase							,					torch.Tensor    )

													# Test not batched input
													__lowerCamelCase					:		List[Any]		   =     image_processing(image_inputs[0]							,					return_tensors="pt"    ).pixel_values
													self.assertEqual(
													    encoded_images.shape							,					(
													        1,
													        self.image_processor_tester.num_channels,
													        self.image_processor_tester.crop_size["height"],
													        self.image_processor_tester.crop_size["width"],
													    )							,					)

													# Test batched
													__lowerCamelCase					:		List[str]		   =     image_processing(UpperCAmelCase							,					return_tensors="pt"    ).pixel_values
													self.assertEqual(
													    encoded_images.shape							,					(
													        self.image_processor_tester.batch_size,
													        self.image_processor_tester.num_channels,
													        self.image_processor_tester.crop_size["height"],
													        self.image_processor_tester.crop_size["width"],
													    )							,					)