



import inspect
import unittest

from transformers import SegformerConfig, is_torch_available, is_vision_available
from transformers.models.auto import get_values
from transformers.testing_utils import require_torch, slow, torch_device

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 (
           MODEL_MAPPING,
           SegformerForImageClassification,
           SegformerForSemanticSegmentation,
           SegformerModel,
       )
       from transformers.models.segformer.modeling_segformer import SEGFORMER_PRETRAINED_MODEL_ARCHIVE_LIST


if is_vision_available():
       from PIL import Image

       from transformers import SegformerImageProcessor
class 				_snake_case			(					__UpperCAmelCase):




    def 							A__      (						self					:						Tuple						):
       lowercase__					  =				self.config_class(**self.inputs_dict						)
       self.parent.assertTrue(hasattr(__lowercase,					"hidden_sizes"						)						)
       self.parent.assertTrue(hasattr(__lowercase,					"num_attention_heads"						)						)
       self.parent.assertTrue(hasattr(__lowercase,					"num_encoder_blocks"						)						)
class 				_snake_case			:




    def __init__(						self					:						int,					__lowercase					:						Optional[Any],					__lowercase					:						Union[str, Any]=13,					__lowercase					:						Optional[Any]=64,					__lowercase					:						Union[str, Any]=3,					__lowercase					:						Optional[Any]=4,					__lowercase					:						Union[str, Any]=[2, 2, 2, 2],					__lowercase					:						List[str]=[8, 4, 2, 1],					__lowercase					:						Optional[Any]=[16, 32, 64, 128],					__lowercase					:						List[str]=[1, 4, 8, 16],					__lowercase					:						int=[1, 2, 4, 8],					__lowercase					:						Optional[Any]=True,					__lowercase					:						List[str]=True,					__lowercase					:						List[Any]="gelu",					__lowercase					:						List[Any]=0.1,					__lowercase					:						List[Any]=0.1,					__lowercase					:						Dict=0.02,					__lowercase					:						Dict=3,					__lowercase					:						List[str]=None,					):
       lowercase__					  =				parent
       lowercase__					  =				batch_size
       lowercase__					  =				image_size
       lowercase__					  =				num_channels
       lowercase__					  =				num_encoder_blocks
       lowercase__					  =				sr_ratios
       lowercase__					  =				depths
       lowercase__					  =				hidden_sizes
       lowercase__					  =				downsampling_rates
       lowercase__					  =				num_attention_heads
       lowercase__					  =				is_training
       lowercase__					  =				use_labels
       lowercase__					  =				hidden_act
       lowercase__					  =				hidden_dropout_prob
       lowercase__					  =				attention_probs_dropout_prob
       lowercase__					  =				initializer_range
       lowercase__					  =				num_labels
       lowercase__					  =				scope




    def 							A__      (						self					:						List[Any]						):
       lowercase__					  =				floats_tensor([self.batch_size, self.num_channels, self.image_size, self.image_size]						)

       lowercase__					  =				None
       if self.use_labels:
          lowercase__					  =				ids_tensor([self.batch_size, self.image_size, self.image_size],					self.num_labels						)

       lowercase__					  =				self.get_config()
       return config, pixel_values, labels




    def 							A__      (						self					:						Any						):
       return SegformerConfig(
           image_size=self.image_size,					num_channels=self.num_channels,					num_encoder_blocks=self.num_encoder_blocks,					depths=self.depths,					hidden_sizes=self.hidden_sizes,					num_attention_heads=self.num_attention_heads,					hidden_act=self.hidden_act,					hidden_dropout_prob=self.hidden_dropout_prob,					attention_probs_dropout_prob=self.attention_probs_dropout_prob,					initializer_range=self.initializer_range,					)




    def 							A__      (						self					:						List[str],					__lowercase					:						List[str],					__lowercase					:						Any,					__lowercase					:						str						):
       lowercase__					  =				SegformerModel(config=__lowercase						)
       model.to(__lowercase						)
       model.eval()
       lowercase__					  =				model(__lowercase						)
       lowercase__					  =				lowercase__					  =				self.image_size // (self.downsampling_rates[-1] * 2)
       self.parent.assertEqual(
           result.last_hidden_state.shape,					(self.batch_size, self.hidden_sizes[-1], expected_height, expected_width)						)




    def 							A__      (						self					:						Union[str, Any],					__lowercase					:						List[str],					__lowercase					:						Any,					__lowercase					:						Optional[int]						):
       lowercase__					  =				self.num_labels
       lowercase__					  =				SegformerForSemanticSegmentation(__lowercase						)
       model.to(__lowercase						)
       model.eval()
       lowercase__					  =				model(__lowercase						)
       self.parent.assertEqual(
           result.logits.shape,					(self.batch_size, self.num_labels, self.image_size // 4, self.image_size // 4)						)
       lowercase__					  =				model(__lowercase,					labels=__lowercase						)
       self.parent.assertEqual(
           result.logits.shape,					(self.batch_size, self.num_labels, self.image_size // 4, self.image_size // 4)						)
       self.parent.assertGreater(result.loss,					0.0						)




    def 							A__      (						self					:						str,					__lowercase					:						Tuple,					__lowercase					:						Dict,					__lowercase					:						Optional[int]						):
       lowercase__					  =				1
       lowercase__					  =				SegformerForSemanticSegmentation(config=__lowercase						)
       model.to(__lowercase						)
       model.eval()
       lowercase__					  =				torch.randint(0,					1,					(self.batch_size, self.image_size, self.image_size)						).to(__lowercase						)
       lowercase__					  =				model(__lowercase,					labels=__lowercase						)
       self.parent.assertGreater(result.loss,					0.0						)




    def 							A__      (						self					:						Optional[int]						):
       lowercase__					  =				self.prepare_config_and_inputs()
       lowercase__  ,       lowercase__  ,       lowercase__					  =				config_and_inputs
       lowercase__					  =				{"pixel_values": pixel_values}
       return config, inputs_dict
@require_torch
class 				_snake_case			(					__UpperCAmelCase    ,	__UpperCAmelCase    ,	unittest.TestCase):
    UpperCamelCase__				:					Optional[int]     		=(
        (
            SegformerModel,
            SegformerForSemanticSegmentation,
            SegformerForImageClassification,
        )
        if is_torch_available()
        else ()
    )
    UpperCamelCase__				:					List[Any]     		=(
        {
            """feature-extraction""": SegformerModel,
            """image-classification""": SegformerForImageClassification,
            """image-segmentation""": SegformerForSemanticSegmentation,
        }
        if is_torch_available()
        else {}
    )

    UpperCamelCase__				:					int     		=True
    UpperCamelCase__				:					Optional[Any]     		=False
    UpperCamelCase__				:					Optional[int]     		=False
    UpperCamelCase__				:					Dict     		=False




    def 							A__      (						self					:						Dict						):
       lowercase__					  =				SegformerModelTester(self						)
       lowercase__					  =				SegformerConfigTester(self,					config_class=__lowercase						)




    def 							A__      (						self					:						str						):
       self.config_tester.run_common_tests()




    def 							A__      (						self					:						List[str]						):
       lowercase__					  =				self.model_tester.prepare_config_and_inputs()
       self.model_tester.create_and_check_model(*__lowercase						)




    def 							A__      (						self					:						List[Any]						):
       lowercase__					  =				self.model_tester.prepare_config_and_inputs()
       self.model_tester.create_and_check_for_binary_image_segmentation(*__lowercase						)




    def 							A__      (						self					:						List[str]						):
       lowercase__					  =				self.model_tester.prepare_config_and_inputs()
       self.model_tester.create_and_check_for_image_segmentation(*__lowercase						)




    @unittest.skip("SegFormer does not use inputs_embeds"						)
    def 							A__      (						self					:						Optional[int]						):
       pass




    @unittest.skip("SegFormer does not have get_input_embeddings method and get_output_embeddings methods"						)
    def 							A__      (						self					:						Any						):
       pass




    def 							A__      (						self					:						Optional[Any]						):
       lowercase__  ,       lowercase__					  =				self.model_tester.prepare_config_and_inputs_for_common()

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

          lowercase__					  =				["pixel_values"]
          self.assertListEqual(arg_names[:1],					__lowercase						)




    def 							A__      (						self					:						str						):
       lowercase__  ,       lowercase__					  =				self.model_tester.prepare_config_and_inputs_for_common()
       lowercase__					  =				True

       for model_class in self.all_model_classes:
          lowercase__					  =				True
          lowercase__					  =				False
          lowercase__					  =				True
          lowercase__					  =				model_class(__lowercase						)
          model.to(__lowercase						)
          model.eval()
          with torch.no_grad():
             lowercase__					  =				model(**self._prepare_for_class(__lowercase,					__lowercase						)						)
          lowercase__					  =				outputs.attentions

          lowercase__					  =				sum(self.model_tester.depths						)
          self.assertEqual(len(__lowercase						),					__lowercase						)

          # check that output_attentions also work using config
          del inputs_dict["output_attentions"]
          lowercase__					  =				True
          lowercase__					  =				model_class(__lowercase						)
          model.to(__lowercase						)
          model.eval()
          with torch.no_grad():
             lowercase__					  =				model(**self._prepare_for_class(__lowercase,					__lowercase						)						)
          lowercase__					  =				outputs.attentions

          self.assertEqual(len(__lowercase						),					__lowercase						)

          # verify the first attentions (first block, first layer)
          lowercase__					  =				(self.model_tester.image_size // 4) ** 2
          lowercase__					  =				(self.model_tester.image_size // (4 * self.model_tester.sr_ratios[0])) ** 2
          self.assertListEqual(
              list(attentions[0].shape[-3:]						),					[self.model_tester.num_attention_heads[0], expected_seq_len, expected_reduced_seq_len],					)

          # verify the last attentions (last block, last layer)
          lowercase__					  =				(self.model_tester.image_size // 32) ** 2
          lowercase__					  =				(self.model_tester.image_size // (32 * self.model_tester.sr_ratios[-1])) ** 2
          self.assertListEqual(
              list(attentions[-1].shape[-3:]						),					[self.model_tester.num_attention_heads[-1], expected_seq_len, expected_reduced_seq_len],					)
          lowercase__					  =				len(__lowercase						)

          # Check attention is always last and order is fine
          lowercase__					  =				True
          lowercase__					  =				True
          lowercase__					  =				model_class(__lowercase						)
          model.to(__lowercase						)
          model.eval()
          with torch.no_grad():
             lowercase__					  =				model(**self._prepare_for_class(__lowercase,					__lowercase						)						)

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

          lowercase__					  =				outputs.attentions

          self.assertEqual(len(__lowercase						),					__lowercase						)
          # verify the first attentions (first block, first layer)
          lowercase__					  =				(self.model_tester.image_size // 4) ** 2
          lowercase__					  =				(self.model_tester.image_size // (4 * self.model_tester.sr_ratios[0])) ** 2
          self.assertListEqual(
              list(self_attentions[0].shape[-3:]						),					[self.model_tester.num_attention_heads[0], expected_seq_len, expected_reduced_seq_len],					)




    def 							A__      (						self					:						List[str]						):

       def check_hidden_states_output(__lowercase					:						Dict,					__lowercase					:						Optional[Any],					__lowercase					:						Union[str, Any]						):
          lowercase__					  =				model_class(__lowercase						)
          model.to(__lowercase						)
          model.eval()

          with torch.no_grad():
             lowercase__					  =				model(**self._prepare_for_class(__lowercase,					__lowercase						)						)

          lowercase__					  =				outputs.hidden_states

          lowercase__					  =				self.model_tester.num_encoder_blocks
          self.assertEqual(len(__lowercase						),					__lowercase						)

          # verify the first hidden states (first block)
          self.assertListEqual(
              list(hidden_states[0].shape[-3:]						),					[
                  self.model_tester.hidden_sizes[0],
                  self.model_tester.image_size // 4,
                  self.model_tester.image_size // 4,
              ],					)

       lowercase__  ,       lowercase__					  =				self.model_tester.prepare_config_and_inputs_for_common()

       for model_class in self.all_model_classes:
          lowercase__					  =				True
          check_hidden_states_output(__lowercase,					__lowercase,					__lowercase						)

          # check that output_hidden_states also work using config
          del inputs_dict["output_hidden_states"]
          lowercase__					  =				True

          check_hidden_states_output(__lowercase,					__lowercase,					__lowercase						)




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

       if not self.model_tester.is_training:
          return

       lowercase__  ,       lowercase__					  =				self.model_tester.prepare_config_and_inputs_for_common()
       lowercase__					  =				True

       for model_class in self.all_model_classes:
          if model_class in get_values(__lowercase						):
             continue

          lowercase__					  =				model_class(__lowercase						)
          model.to(__lowercase						)
          model.train()
          lowercase__					  =				self._prepare_for_class(__lowercase,					__lowercase,					return_labels=__lowercase						)
          lowercase__					  =				model(**__lowercase						).loss
          loss.backward()




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




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

       for model_name in SEGFORMER_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
          lowercase__					  =				SegformerModel.from_pretrained(__lowercase						)
          self.assertIsNotNone(__lowercase						)



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




@require_torch
class 				_snake_case			(					unittest.TestCase):




    @slow
    def 							A__      (						self					:						Tuple						):
       lowercase__					  =				SegformerImageProcessor(
           image_scale=(512, 512),					keep_ratio=__lowercase,					align=__lowercase,					do_random_crop=__lowercase						)
       lowercase__					  =				SegformerForSemanticSegmentation.from_pretrained("nvidia/segformer-b0-finetuned-ade-512-512"						).to(
           __lowercase						)

       lowercase__					  =				prepare_img()
       lowercase__					  =				image_processor(images=__lowercase,					return_tensors="pt"						)
       lowercase__					  =				encoded_inputs.pixel_values.to(__lowercase						)

       with torch.no_grad():
          lowercase__					  =				model(__lowercase						)

       lowercase__					  =				torch.Size((1, model.config.num_labels, 128, 128)						)
       self.assertEqual(outputs.logits.shape,					__lowercase						)

       lowercase__					  =				torch.tensor(
           [
               [[-4.6310, -5.5232, -6.2356], [-5.1921, -6.1444, -6.5996], [-5.4424, -6.2790, -6.7574]],
               [[-12.1391, -13.3122, -13.9554], [-12.8732, -13.9352, -14.3563], [-12.9438, -13.8226, -14.2513]],
               [[-12.5134, -13.4686, -14.4915], [-12.8669, -14.4343, -14.7758], [-13.2523, -14.5819, -15.0694]],
           ]						).to(__lowercase						)
       self.assertTrue(torch.allclose(outputs.logits[0, :3, :3, :3],					__lowercase,					atol=1e-4						)						)




    @slow
    def 							A__      (						self					:						List[Any]						):
       lowercase__					  =				SegformerImageProcessor(
           image_scale=(512, 512),					keep_ratio=__lowercase,					align=__lowercase,					do_random_crop=__lowercase						)
       lowercase__					  =				SegformerForSemanticSegmentation.from_pretrained(
           "nvidia/segformer-b1-finetuned-cityscapes-1024-1024"						).to(__lowercase						)

       lowercase__					  =				prepare_img()
       lowercase__					  =				image_processor(images=__lowercase,					return_tensors="pt"						)
       lowercase__					  =				encoded_inputs.pixel_values.to(__lowercase						)

       with torch.no_grad():
          lowercase__					  =				model(__lowercase						)

       lowercase__					  =				torch.Size((1, model.config.num_labels, 128, 128)						)
       self.assertEqual(outputs.logits.shape,					__lowercase						)

       lowercase__					  =				torch.tensor(
           [
               [[-13.5748, -13.9111, -12.6500], [-14.3500, -15.3683, -14.2328], [-14.7532, -16.0424, -15.6087]],
               [[-17.1651, -15.8725, -12.9653], [-17.2580, -17.3718, -14.8223], [-16.6058, -16.8783, -16.7452]],
               [[-3.6456, -3.0209, -1.4203], [-3.0797, -3.1959, -2.0000], [-1.8757, -1.9217, -1.6997]],
           ]						).to(__lowercase						)
       self.assertTrue(torch.allclose(outputs.logits[0, :3, :3, :3],					__lowercase,					atol=1e-1						)						)




    @slow
    def 							A__      (						self					:						List[Any]						):
       lowercase__					  =				SegformerImageProcessor(
           image_scale=(512, 512),					keep_ratio=__lowercase,					align=__lowercase,					do_random_crop=__lowercase						)
       lowercase__					  =				SegformerForSemanticSegmentation.from_pretrained("nvidia/segformer-b0-finetuned-ade-512-512"						).to(
           __lowercase						)

       lowercase__					  =				prepare_img()
       lowercase__					  =				image_processor(images=__lowercase,					return_tensors="pt"						)
       lowercase__					  =				encoded_inputs.pixel_values.to(__lowercase						)

       with torch.no_grad():
          lowercase__					  =				model(__lowercase						)

       lowercase__					  =				outputs.logits.detach().cpu()

       lowercase__					  =				image_processor.post_process_semantic_segmentation(outputs=__lowercase,					target_sizes=[(500, 300)]						)
       lowercase__					  =				torch.Size((500, 300)						)
       self.assertEqual(segmentation[0].shape,					__lowercase						)

       lowercase__					  =				image_processor.post_process_semantic_segmentation(outputs=__lowercase						)
       lowercase__					  =				torch.Size((128, 128)						)
       self.assertEqual(segmentation[0].shape,					__lowercase						)









import unittest

import numpy as np

from transformers.testing_utils import is_flaky, 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 DonutImageProcessor
class 				_snake_case			(					unittest.TestCase):




				def __init__(						self					:						Dict,					__lowercase					:						int,					__lowercase					:						Union[str, Any]=7,					__lowercase					:						Union[str, Any]=3,					__lowercase					:						Any=18,					__lowercase					:						Union[str, Any]=30,					__lowercase					:						Any=400,					__lowercase					:						List[str]=True,					__lowercase					:						Dict=None,					__lowercase					:						List[str]=True,					__lowercase					:						int=False,					__lowercase					:						Union[str, Any]=True,					__lowercase					:						str=True,					__lowercase					:						Optional[int]=[0.5, 0.5, 0.5],					__lowercase					:						List[Any]=[0.5, 0.5, 0.5],					):
							lowercase__					  =				parent
							lowercase__					  =				batch_size
							lowercase__					  =				num_channels
							lowercase__					  =				image_size
							lowercase__					  =				min_resolution
							lowercase__					  =				max_resolution
							lowercase__					  =				do_resize
							lowercase__					  =				size if size is not None else {"height": 18, "width": 20}
							lowercase__					  =				do_thumbnail
							lowercase__					  =				do_align_axis
							lowercase__					  =				do_pad
							lowercase__					  =				do_normalize
							lowercase__					  =				image_mean
							lowercase__					  =				image_std




				def 							A__      (						self					:						Optional[Any]						):
							return {
							    "do_resize": self.do_resize,
							    "size": self.size,
							    "do_thumbnail": self.do_thumbnail,
							    "do_align_long_axis": self.do_align_axis,
							    "do_pad": self.do_pad,
							    "do_normalize": self.do_normalize,
							    "image_mean": self.image_mean,
							    "image_std": self.image_std,
							}
@require_torch
@require_vision
class 				_snake_case			(					lowercase__    ,	unittest.TestCase):
				UpperCamelCase__				:					Optional[int]     		=DonutImageProcessor if is_vision_available() else None




				def 							A__      (						self					:						str						):
							lowercase__					  =				DonutImageProcessingTester(self						)




				@property
				def 							A__      (						self					:						List[str]						):
							return self.image_processor_tester.prepare_image_processor_dict()




				def 							A__      (						self					:						Optional[Any]						):
							lowercase__					  =				self.image_processing_class(**self.image_processor_dict						)
							self.assertTrue(hasattr(__lowercase,					"do_resize"						)						)
							self.assertTrue(hasattr(__lowercase,					"size"						)						)
							self.assertTrue(hasattr(__lowercase,					"do_thumbnail"						)						)
							self.assertTrue(hasattr(__lowercase,					"do_align_long_axis"						)						)
							self.assertTrue(hasattr(__lowercase,					"do_pad"						)						)
							self.assertTrue(hasattr(__lowercase,					"do_normalize"						)						)
							self.assertTrue(hasattr(__lowercase,					"image_mean"						)						)
							self.assertTrue(hasattr(__lowercase,					"image_std"						)						)




				def 							A__      (						self					:						str						):
							lowercase__					  =				self.image_processing_class.from_dict(self.image_processor_dict						)
							self.assertEqual(image_processor.size,					{"height": 18, "width": 20}						)

							lowercase__					  =				self.image_processing_class.from_dict(self.image_processor_dict,					size=42						)
							self.assertEqual(image_processor.size,					{"height": 42, "width": 42}						)

							# Previous config had dimensions in (width, height) order
							lowercase__					  =				self.image_processing_class.from_dict(self.image_processor_dict,					size=(42, 84)						)
							self.assertEqual(image_processor.size,					{"height": 84, "width": 42}						)




				def 							A__      (						self					:						List[str]						):
							pass




				@is_flaky()
				def 							A__      (						self					:						Dict						):
							# Initialize image_processing
							lowercase__					  =				self.image_processing_class(**self.image_processor_dict						)
							# create random PIL images
							lowercase__					  =				prepare_image_inputs(self.image_processor_tester,					equal_resolution=__lowercase						)
							for image in image_inputs:
										self.assertIsInstance(__lowercase,					Image.Image						)

							# Test not batched input
							lowercase__					  =				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.size["height"],
							        self.image_processor_tester.size["width"],
							    ),					)

							# Test batched
							lowercase__					  =				image_processing(__lowercase,					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.size["height"],
							        self.image_processor_tester.size["width"],
							    ),					)




				@is_flaky()
				def 							A__      (						self					:						Optional[Any]						):
							# Initialize image_processing
							lowercase__					  =				self.image_processing_class(**self.image_processor_dict						)
							# create random numpy tensors
							lowercase__					  =				prepare_image_inputs(self.image_processor_tester,					equal_resolution=__lowercase,					numpify=__lowercase						)
							for image in image_inputs:
										self.assertIsInstance(__lowercase,					np.ndarray						)

							# Test not batched input
							lowercase__					  =				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.size["height"],
							        self.image_processor_tester.size["width"],
							    ),					)

							# Test batched
							lowercase__					  =				image_processing(__lowercase,					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.size["height"],
							        self.image_processor_tester.size["width"],
							    ),					)




				@is_flaky()
				def 							A__      (						self					:						Tuple						):
							# Initialize image_processing
							lowercase__					  =				self.image_processing_class(**self.image_processor_dict						)
							# create random PyTorch tensors
							lowercase__					  =				prepare_image_inputs(self.image_processor_tester,					equal_resolution=__lowercase,					torchify=__lowercase						)
							for image in image_inputs:
										self.assertIsInstance(__lowercase,					torch.Tensor						)

							# Test not batched input
							lowercase__					  =				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.size["height"],
							        self.image_processor_tester.size["width"],
							    ),					)

							# Test batched
							lowercase__					  =				image_processing(__lowercase,					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.size["height"],
							        self.image_processor_tester.size["width"],
							    ),					)




