



import inspect
import unittest

import numpy as np

from transformers import BeitConfig
from transformers.testing_utils import require_flax, require_vision, slow
from transformers.utils import cached_property, is_flax_available, is_vision_available

from ...test_configuration_common import ConfigTester
from ...test_modeling_flax_common import FlaxModelTesterMixin, floats_tensor, ids_tensor


if is_flax_available():
						import jax

						from transformers import FlaxBeitForImageClassification, FlaxBeitForMaskedImageModeling, FlaxBeitModel

if is_vision_available():
						from PIL import Image

						from transformers import BeitImageProcessor


class 				_a						(       unittest.TestCase			):





							'''simple docstring'''

							def __init__(							self ,					__UpperCAmelCase ,					__UpperCAmelCase=100 ,					__UpperCAmelCase=13 ,					__UpperCAmelCase=30 ,					__UpperCAmelCase=2 ,					__UpperCAmelCase=3 ,					__UpperCAmelCase=True ,					__UpperCAmelCase=True ,					__UpperCAmelCase=32 ,					__UpperCAmelCase=5 ,					__UpperCAmelCase=4 ,					__UpperCAmelCase=37 ,					__UpperCAmelCase="gelu" ,					__UpperCAmelCase=0.1 ,					__UpperCAmelCase=0.1 ,					__UpperCAmelCase=10 ,					__UpperCAmelCase=0.0_2 ,					__UpperCAmelCase=3 ,					):







											"""simple docstring"""



											a__	:							List[Any]      						= parent
											a__	:							List[Any]      						= vocab_size
											a__	:							int      						= batch_size
											a__	:							Optional[int]      						= image_size
											a__	:							str      						= patch_size
											a__	:							Dict      						= num_channels
											a__	:							str      						= is_training
											a__	:							int      						= use_labels
											a__	:							Tuple      						= hidden_size
											a__	:							Union[str, Any]      						= num_hidden_layers
											a__	:							Optional[int]      						= num_attention_heads
											a__	:							List[str]      						= intermediate_size
											a__	:							str      						= hidden_act
											a__	:							str      						= hidden_dropout_prob
											a__	:							Dict      						= attention_probs_dropout_prob
											a__	:							int      						= type_sequence_label_size
											a__	:							Any      						= initializer_range

											# in BeiT, the seq length equals the number of patches + 1 (we add 1 for the [CLS] token)
											a__	:							List[Any]      						= (image_size // patch_size) ** 2
											a__	:							Optional[int]      						= num_patches + 1



							def 		_A	(							self				):







											"""simple docstring"""



											a__	:							str      						= floats_tensor([self.batch_size, self.num_channels, self.image_size, self.image_size]				)

											a__	:							Optional[int]      						= None
											if self.use_labels:
															a__	:							Optional[Any]      						= ids_tensor([self.batch_size] ,					self.type_sequence_label_size				)

											a__	:							str      						= BeitConfig(
											    vocab_size=self.vocab_size ,					image_size=self.image_size ,					patch_size=self.patch_size ,					num_channels=self.num_channels ,					hidden_size=self.hidden_size ,					num_hidden_layers=self.num_hidden_layers ,					num_attention_heads=self.num_attention_heads ,					intermediate_size=self.intermediate_size ,					hidden_act=self.hidden_act ,					hidden_dropout_prob=self.hidden_dropout_prob ,					attention_probs_dropout_prob=self.attention_probs_dropout_prob ,					is_decoder=__UpperCAmelCase ,					initializer_range=self.initializer_range ,					)

											return config, pixel_values, labels



							def 		_A	(							self ,					__UpperCAmelCase ,					__UpperCAmelCase ,					__UpperCAmelCase				):







											"""simple docstring"""



											a__	:							List[Any]      						= FlaxBeitModel(config=__UpperCAmelCase				)
											a__	:							str      						= model(__UpperCAmelCase				)
											self.parent.assertEqual(result.last_hidden_state.shape ,					(self.batch_size, self.seq_length, self.hidden_size)				)



							def 		_A	(							self ,					__UpperCAmelCase ,					__UpperCAmelCase ,					__UpperCAmelCase				):







											"""simple docstring"""



											a__	:							Dict      						= FlaxBeitForMaskedImageModeling(config=__UpperCAmelCase				)
											a__	:							Any      						= model(__UpperCAmelCase				)
											self.parent.assertEqual(result.logits.shape ,					(self.batch_size, self.seq_length - 1, self.vocab_size)				)



							def 		_A	(							self ,					__UpperCAmelCase ,					__UpperCAmelCase ,					__UpperCAmelCase				):







											"""simple docstring"""



											a__	:							Optional[Any]      						= self.type_sequence_label_size
											a__	:							Optional[Any]      						= FlaxBeitForImageClassification(config=__UpperCAmelCase				)
											a__	:							Any      						= model(__UpperCAmelCase				)
											self.parent.assertEqual(result.logits.shape ,					(self.batch_size, self.type_sequence_label_size)				)

											# test greyscale images
											a__	:							List[Any]      						= 1
											a__	:							List[str]      						= FlaxBeitForImageClassification(__UpperCAmelCase				)

											a__	:							Optional[int]      						= floats_tensor([self.batch_size, 1, self.image_size, self.image_size]				)
											a__	:							Optional[Any]      						= model(__UpperCAmelCase				)




							def 		_A	(							self				):







											"""simple docstring"""



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





@require_flax
class 				_a						(       SCREAMING_SNAKE_CASE       ,  unittest.TestCase			):





							'''simple docstring'''

							A				:Any =       (
							    (FlaxBeitModel, FlaxBeitForImageClassification, FlaxBeitForMaskedImageModeling) if is_flax_available() else ()
							)



							def 		_A	(							self				):







											"""simple docstring"""



											a__	:							Dict      						= FlaxBeitModelTester(self				)
											a__	:							Optional[int]      						= ConfigTester(self ,					config_class=__UpperCAmelCase ,					has_text_modality=__UpperCAmelCase ,					hidden_size=37				)



							def 		_A	(							self				):







											"""simple docstring"""



											self.config_tester.run_common_tests()



							def 		_A	(							self				):







											"""simple docstring"""



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

											for model_class in self.all_model_classes:
															a__	:							Dict      						= model_class(__UpperCAmelCase				)
															a__	:							Dict      						= inspect.signature(model.__call__				)
															# signature.parameters is an OrderedDict => so arg_names order is deterministic
															a__	:							int      						= [*signature.parameters.keys()]

															a__	:							Tuple      						= ["pixel_values"]
															self.assertListEqual(arg_names[:1] ,					__UpperCAmelCase				)



							def 		_A	(							self				):







											"""simple docstring"""



											a__						,   a__	:							Tuple      						= self.model_tester.prepare_config_and_inputs_for_common()

											for model_class in self.all_model_classes:
															with self.subTest(model_class.__name__				):
																			a__	:							List[str]      						= self._prepare_for_class(__UpperCAmelCase ,					__UpperCAmelCase				)
																			a__	:							List[str]      						= model_class(__UpperCAmelCase				)

																			@jax.jit
																			def model_jitted(__UpperCAmelCase ,					**__UpperCAmelCase				):
																							return model(pixel_values=__UpperCAmelCase ,					**__UpperCAmelCase				)

																			with self.subTest("JIT Enabled"				):
																							a__	:							Union[str, Any]      						= model_jitted(**__UpperCAmelCase				).to_tuple()

																			with self.subTest("JIT Disabled"				):
																							with jax.disable_jit():
																											a__	:							List[Any]      						= model_jitted(**__UpperCAmelCase				).to_tuple()

																			self.assertEqual(len(__UpperCAmelCase				) ,					len(__UpperCAmelCase				)				)
																			for jitted_output, output in zip(__UpperCAmelCase ,					__UpperCAmelCase				):
																							self.assertEqual(jitted_output.shape ,					output.shape				)



							def 		_A	(							self				):







											"""simple docstring"""



											a__	:							Optional[Any]      						= self.model_tester.prepare_config_and_inputs()
											self.model_tester.create_and_check_model(*__UpperCAmelCase				)



							def 		_A	(							self				):







											"""simple docstring"""



											a__	:							Union[str, Any]      						= self.model_tester.prepare_config_and_inputs()
											self.model_tester.create_and_check_for_masked_lm(*__UpperCAmelCase				)



							def 		_A	(							self				):







											"""simple docstring"""



											a__	:							List[Any]      						= self.model_tester.prepare_config_and_inputs()
											self.model_tester.create_and_check_for_image_classification(*__UpperCAmelCase				)




							@slow
							def 		_A	(							self				):







											"""simple docstring"""



											for model_class_name in self.all_model_classes:
															a__	:							Tuple      						= model_class_name.from_pretrained("microsoft/beit-base-patch16-224"				)
															a__	:							int      						= model(np.ones((1, 3, 224, 224)				)				)
															self.assertIsNotNone(__UpperCAmelCase				)






def     SCREAMING_SNAKE_CASE(      )	->						str:
				a__	:							Optional[int]      						= Image.open("./tests/fixtures/tests_samples/COCO/000000039769.png" )
				return image






@require_vision
@require_flax
class 				_a						(       unittest.TestCase			):





							'''simple docstring'''

							@cached_property
							def 		_A	(							self				):







											"""simple docstring"""



											return BeitImageProcessor.from_pretrained("microsoft/beit-base-patch16-224"				) if is_vision_available() else None



							@slow
							def 		_A	(							self				):







											"""simple docstring"""



											a__	:							Union[str, Any]      						= FlaxBeitForMaskedImageModeling.from_pretrained("microsoft/beit-base-patch16-224-pt22k"				)

											a__	:							Tuple      						= self.default_image_processor
											a__	:							List[str]      						= prepare_img()
											a__	:							Dict      						= image_processor(images=__UpperCAmelCase ,					return_tensors="np"				).pixel_values

											# prepare bool_masked_pos
											a__	:							Optional[int]      						= np.ones((1, 196) ,					dtype=__UpperCAmelCase				)

											# forward pass
											a__	:							Any      						= model(pixel_values=__UpperCAmelCase ,					bool_masked_pos=__UpperCAmelCase				)
											a__	:							List[Any]      						= outputs.logits

											# verify the logits
											a__	:							Union[str, Any]      						= (1, 196, 8192)
											self.assertEqual(logits.shape ,					__UpperCAmelCase				)

											a__	:							Optional[int]      						= np.array(
											    [[-3.2_4_3_7, 0.5_0_7_2, -1_3.9_1_7_4], [-3.2_4_5_6, 0.4_9_4_8, -1_3.9_4_0_1], [-3.2_0_3_3, 0.5_1_2_1, -1_3.8_5_5_0]]				)

											self.assertTrue(np.allclose(logits[bool_masked_pos][:3, :3] ,					__UpperCAmelCase ,					atol=1E-2				)				)



							@slow
							def 		_A	(							self				):







											"""simple docstring"""



											a__	:							Dict      						= FlaxBeitForImageClassification.from_pretrained("microsoft/beit-base-patch16-224"				)

											a__	:							str      						= self.default_image_processor
											a__	:							str      						= prepare_img()
											a__	:							Optional[Any]      						= image_processor(images=__UpperCAmelCase ,					return_tensors="np"				)

											# forward pass
											a__	:							List[Any]      						= model(**__UpperCAmelCase				)
											a__	:							Optional[int]      						= outputs.logits

											# verify the logits
											a__	:							int      						= (1, 1000)
											self.assertEqual(logits.shape ,					__UpperCAmelCase				)

											a__	:							Union[str, Any]      						= np.array([-1.2_3_8_5, -1.0_9_8_7, -1.0_1_0_8]				)

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

											a__	:							Optional[Any]      						= 281
											self.assertEqual(logits.argmax(-1				).item() ,					__UpperCAmelCase				)




							@slow
							def 		_A	(							self				):







											"""simple docstring"""



											a__	:							Optional[Any]      						= FlaxBeitForImageClassification.from_pretrained("microsoft/beit-large-patch16-224-pt22k-ft22k"				)

											a__	:							Any      						= self.default_image_processor
											a__	:							List[Any]      						= prepare_img()
											a__	:							Dict      						= image_processor(images=__UpperCAmelCase ,					return_tensors="np"				)

											# forward pass
											a__	:							Optional[int]      						= model(**__UpperCAmelCase				)
											a__	:							Union[str, Any]      						= outputs.logits

											# verify the logits
											a__	:							Optional[Any]      						= (1, 2_1841)
											self.assertEqual(logits.shape ,					__UpperCAmelCase				)

											a__	:							str      						= np.array([1.6_8_8_1, -0.2_7_8_7, 0.5_9_0_1]				)

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

											a__	:							Optional[int]      						= 2396
											self.assertEqual(logits.argmax(-1				).item() ,					__UpperCAmelCase				)







import unittest

import numpy as np
import requests

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

						from transformers.pytorch_utils import is_torch_greater_or_equal_than_1_11
else:
						lowerCamelCase		       =      False

if is_vision_available():
						from PIL import Image

						from transformers import PixaStructImageProcessor


class 				_a						(       unittest.TestCase			):





							'''simple docstring'''

							def __init__(							self ,					__UpperCAmelCase ,					__UpperCAmelCase=7 ,					__UpperCAmelCase=3 ,					__UpperCAmelCase=18 ,					__UpperCAmelCase=30 ,					__UpperCAmelCase=400 ,					__UpperCAmelCase=None ,					__UpperCAmelCase=True ,					__UpperCAmelCase=True ,					__UpperCAmelCase=None ,					):







											"""simple docstring"""



											a__	:							str      						= size if size is not None else {"height": 20, "width": 20}
											a__	:							Optional[int]      						= parent
											a__	:							Union[str, Any]      						= batch_size
											a__	:							List[Any]      						= num_channels
											a__	:							Union[str, Any]      						= image_size
											a__	:							List[str]      						= min_resolution
											a__	:							int      						= max_resolution
											a__	:							int      						= size
											a__	:							List[str]      						= do_normalize
											a__	:							Any      						= do_convert_rgb
											a__	:							Optional[Any]      						= [512, 1024, 2048, 4096]
											a__	:							Any      						= patch_size if patch_size is not None else {"height": 16, "width": 16}



							def 		_A	(							self				):







											"""simple docstring"""



											return {"do_normalize": self.do_normalize, "do_convert_rgb": self.do_convert_rgb}




							def 		_A	(							self				):







											"""simple docstring"""



											a__	:							str      						= "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/transformers/tasks/australia.jpg"
											a__	:							Union[str, Any]      						= Image.open(requests.get(__UpperCAmelCase ,					stream=__UpperCAmelCase				).raw				).convert("RGB"				)
											return raw_image





@unittest.skipIf(
    not is_torch_greater_or_equal_than_1_11       ,  reason="`Pix2StructImageProcessor` requires `torch>=1.11.0`."       ,  )
@require_torch
@require_vision
class 				_a						(       SCREAMING_SNAKE_CASE       ,  unittest.TestCase			):





							'''simple docstring'''

							A				:List[str] =       PixaStructImageProcessor if is_vision_available() else None



							def 		_A	(							self				):







											"""simple docstring"""



											a__	:							Any      						= PixaStructImageProcessingTester(self				)



							@property
							def 		_A	(							self				):







											"""simple docstring"""



											return self.image_processor_tester.prepare_image_processor_dict()



							def 		_A	(							self				):







											"""simple docstring"""



											a__	:							Union[str, Any]      						= self.image_processing_class(**self.image_processor_dict				)
											self.assertTrue(hasattr(__UpperCAmelCase ,					"do_normalize"				)				)
											self.assertTrue(hasattr(__UpperCAmelCase ,					"do_convert_rgb"				)				)



							def 		_A	(							self				):







											"""simple docstring"""



											a__	:							Tuple      						= self.image_processor_tester.prepare_dummy_image()

											a__	:							Any      						= self.image_processing_class(**self.image_processor_dict				)
											a__	:							List[str]      						= 2048

											a__	:							Union[str, Any]      						= image_processor(__UpperCAmelCase ,					return_tensors="pt" ,					max_patches=__UpperCAmelCase				)
											self.assertTrue(torch.allclose(inputs.flattened_patches.mean() ,					torch.tensor(0.0_6_0_6				) ,					atol=1E-3 ,					rtol=1E-3				)				)



							def 		_A	(							self				):







											"""simple docstring"""



											a__	:							int      						= self.image_processing_class(**self.image_processor_dict				)
											# create random PIL images
											a__	:							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
											a__	:							List[Any]      						= (
											    (self.image_processor_tester.patch_size["height"] * self.image_processor_tester.patch_size["width"])
											    * self.image_processor_tester.num_channels
											) + 2

											for max_patch in self.image_processor_tester.max_patches:
															# Test not batched input
															a__	:							Optional[Any]      						= image_processor(
															    image_inputs[0] ,					return_tensors="pt" ,					max_patches=__UpperCAmelCase				).flattened_patches
															self.assertEqual(
															    encoded_images.shape ,					(1, max_patch, expected_hidden_dim) ,					)

															# Test batched
															a__	:							Optional[Any]      						= image_processor(
															    __UpperCAmelCase ,					return_tensors="pt" ,					max_patches=__UpperCAmelCase				).flattened_patches
															self.assertEqual(
															    encoded_images.shape ,					(self.image_processor_tester.batch_size, max_patch, expected_hidden_dim) ,					)



							def 		_A	(							self				):







											"""simple docstring"""



											a__	:							Union[str, Any]      						= self.image_processing_class(**self.image_processor_dict				)
											# create random PIL images
											a__	:							Any      						= prepare_image_inputs(self.image_processor_tester ,					equal_resolution=__UpperCAmelCase				)
											for image in image_inputs:
															self.assertIsInstance(__UpperCAmelCase ,					Image.Image				)

											# Test not batched input
											a__	:							Optional[int]      						= (
											    (self.image_processor_tester.patch_size["height"] * self.image_processor_tester.patch_size["width"])
											    * self.image_processor_tester.num_channels
											) + 2

											a__	:							int      						= True

											for max_patch in self.image_processor_tester.max_patches:
															# Test not batched input
															with self.assertRaises(__UpperCAmelCase				):
																			a__	:							List[str]      						= image_processor(
																			    image_inputs[0] ,					return_tensors="pt" ,					max_patches=__UpperCAmelCase				).flattened_patches

															a__	:							Tuple      						= "Hello"

															a__	:							Union[str, Any]      						= image_processor(
															    image_inputs[0] ,					return_tensors="pt" ,					max_patches=__UpperCAmelCase ,					header_text=__UpperCAmelCase				).flattened_patches
															self.assertEqual(
															    encoded_images.shape ,					(1, max_patch, expected_hidden_dim) ,					)

															# Test batched
															a__	:							Optional[int]      						= image_processor(
															    __UpperCAmelCase ,					return_tensors="pt" ,					max_patches=__UpperCAmelCase ,					header_text=__UpperCAmelCase				).flattened_patches
															self.assertEqual(
															    encoded_images.shape ,					(self.image_processor_tester.batch_size, max_patch, expected_hidden_dim) ,					)



							def 		_A	(							self				):







											"""simple docstring"""



											a__	:							str      						= self.image_processing_class(**self.image_processor_dict				)
											# create random numpy tensors
											a__	:							Tuple      						= prepare_image_inputs(self.image_processor_tester ,					equal_resolution=__UpperCAmelCase ,					numpify=__UpperCAmelCase				)
											for image in image_inputs:
															self.assertIsInstance(__UpperCAmelCase ,					np.ndarray				)

											a__	:							List[str]      						= (
											    (self.image_processor_tester.patch_size["height"] * self.image_processor_tester.patch_size["width"])
											    * self.image_processor_tester.num_channels
											) + 2

											for max_patch in self.image_processor_tester.max_patches:
															# Test not batched input
															a__	:							Any      						= image_processor(
															    image_inputs[0] ,					return_tensors="pt" ,					max_patches=__UpperCAmelCase				).flattened_patches
															self.assertEqual(
															    encoded_images.shape ,					(1, max_patch, expected_hidden_dim) ,					)

															# Test batched
															a__	:							str      						= image_processor(
															    __UpperCAmelCase ,					return_tensors="pt" ,					max_patches=__UpperCAmelCase				).flattened_patches
															self.assertEqual(
															    encoded_images.shape ,					(self.image_processor_tester.batch_size, max_patch, expected_hidden_dim) ,					)




							def 		_A	(							self				):







											"""simple docstring"""



											a__	:							List[Any]      						= self.image_processing_class(**self.image_processor_dict				)
											# create random PyTorch tensors
											a__	:							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
											a__	:							Optional[Any]      						= (
											    (self.image_processor_tester.patch_size["height"] * self.image_processor_tester.patch_size["width"])
											    * self.image_processor_tester.num_channels
											) + 2

											for max_patch in self.image_processor_tester.max_patches:
															# Test not batched input
															a__	:							str      						= image_processor(
															    image_inputs[0] ,					return_tensors="pt" ,					max_patches=__UpperCAmelCase				).flattened_patches
															self.assertEqual(
															    encoded_images.shape ,					(1, max_patch, expected_hidden_dim) ,					)

															# Test batched
															a__	:							Optional[int]      						= image_processor(
															    __UpperCAmelCase ,					return_tensors="pt" ,					max_patches=__UpperCAmelCase				).flattened_patches
															self.assertEqual(
															    encoded_images.shape ,					(self.image_processor_tester.batch_size, max_patch, expected_hidden_dim) ,					)





@unittest.skipIf(
    not is_torch_greater_or_equal_than_1_11       ,  reason="`Pix2StructImageProcessor` requires `torch>=1.11.0`."       ,  )
@require_torch
@require_vision
class 				_a						(       SCREAMING_SNAKE_CASE       ,  unittest.TestCase			):





							'''simple docstring'''

							A				:List[str] =       PixaStructImageProcessor if is_vision_available() else None



							def 		_A	(							self				):







											"""simple docstring"""



											a__	:							Dict      						= PixaStructImageProcessingTester(self ,					num_channels=4				)
											a__	:							Tuple      						= 3



							@property
							def 		_A	(							self				):







											"""simple docstring"""



											return self.image_processor_tester.prepare_image_processor_dict()



							def 		_A	(							self				):







											"""simple docstring"""



											a__	:							Optional[int]      						= self.image_processing_class(**self.image_processor_dict				)
											self.assertTrue(hasattr(__UpperCAmelCase ,					"do_normalize"				)				)
											self.assertTrue(hasattr(__UpperCAmelCase ,					"do_convert_rgb"				)				)




							def 		_A	(							self				):







											"""simple docstring"""



											a__	:							Dict      						= self.image_processing_class(**self.image_processor_dict				)
											# create random PIL images
											a__	:							Union[str, Any]      						= prepare_image_inputs(self.image_processor_tester ,					equal_resolution=__UpperCAmelCase				)
											for image in image_inputs:
															self.assertIsInstance(__UpperCAmelCase ,					Image.Image				)

											# Test not batched input
											a__	:							str      						= (
											    (self.image_processor_tester.patch_size["height"] * self.image_processor_tester.patch_size["width"])
											    * (self.image_processor_tester.num_channels - 1)
											) + 2

											for max_patch in self.image_processor_tester.max_patches:
															# Test not batched input
															a__	:							List[str]      						= image_processor(
															    image_inputs[0] ,					return_tensors="pt" ,					max_patches=__UpperCAmelCase				).flattened_patches
															self.assertEqual(
															    encoded_images.shape ,					(1, max_patch, expected_hidden_dim) ,					)

															# Test batched
															a__	:							int      						= image_processor(
															    __UpperCAmelCase ,					return_tensors="pt" ,					max_patches=__UpperCAmelCase				).flattened_patches
															self.assertEqual(
															    encoded_images.shape ,					(self.image_processor_tester.batch_size, max_patch, expected_hidden_dim) ,					)


