


import inspect
import unittest

from transformers import ViTConfig
from transformers.testing_utils import (
    require_accelerate,
    require_torch,
    require_torch_gpu,
    require_vision,
    slow,
    torch_device,
)
from transformers.utils import cached_property, is_torch_available, is_vision_available

from ...test_configuration_common import ConfigTester
from ...test_modeling_common import ModelTesterMixin, floats_tensor, ids_tensor
from ...test_pipeline_mixin import PipelineTesterMixin


if is_torch_available():
		import torch
		from torch import nn

		from transformers import ViTForImageClassification, ViTForMaskedImageModeling, ViTModel
		from transformers.models.vit.modeling_vit import VIT_PRETRAINED_MODEL_ARCHIVE_LIST


if is_vision_available():
		from PIL import Image

		from transformers import ViTImageProcessor



class 						_UpperCAmelCase      :






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

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






		def _snake_case		(						self				:     Union[str, Any]):
				SCREAMING_SNAKE_CASE_				:Tuple				     =						floats_tensor([self.batch_size, self.num_channels, self.image_size, self.image_size])

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

				SCREAMING_SNAKE_CASE_				:List[str]				     =						self.get_config()

				return config, pixel_values, labels






		def _snake_case		(						self				:     Tuple):
				return ViTConfig(
				    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   ,  encoder_stride=self.encoder_stride   ,  )






		def _snake_case		(						self				:     Optional[int]   ,  UpperCAmelCase				:     Tuple   ,  UpperCAmelCase				:     Tuple   ,  UpperCAmelCase				:     Any):
				SCREAMING_SNAKE_CASE_				:List[Any]				     =						ViTModel(config=UpperCAmelCase)
				model.to(UpperCAmelCase)
				model.eval()
				SCREAMING_SNAKE_CASE_				:Dict				     =						model(UpperCAmelCase)
				self.parent.assertEqual(result.last_hidden_state.shape   ,  (self.batch_size, self.seq_length, self.hidden_size))






		def _snake_case		(						self				:     Optional[int]   ,  UpperCAmelCase				:     Union[str, Any]   ,  UpperCAmelCase				:     Optional[Any]   ,  UpperCAmelCase				:     Any):
				SCREAMING_SNAKE_CASE_				:int				     =						ViTForMaskedImageModeling(config=UpperCAmelCase)
				model.to(UpperCAmelCase)
				model.eval()
				SCREAMING_SNAKE_CASE_				:str				     =						model(UpperCAmelCase)
				self.parent.assertEqual(
				    result.reconstruction.shape   ,  (self.batch_size, self.num_channels, self.image_size, self.image_size))

				# test greyscale images
				SCREAMING_SNAKE_CASE_				:int				     =						1
				SCREAMING_SNAKE_CASE_				:List[Any]				     =						ViTForMaskedImageModeling(UpperCAmelCase)
				model.to(UpperCAmelCase)
				model.eval()

				SCREAMING_SNAKE_CASE_				:int				     =						floats_tensor([self.batch_size, 1, self.image_size, self.image_size])
				SCREAMING_SNAKE_CASE_				:List[Any]				     =						model(UpperCAmelCase)
				self.parent.assertEqual(result.reconstruction.shape   ,  (self.batch_size, 1, self.image_size, self.image_size))






		def _snake_case		(						self				:     Union[str, Any]   ,  UpperCAmelCase				:     Union[str, Any]   ,  UpperCAmelCase				:     Dict   ,  UpperCAmelCase				:     Dict):
				SCREAMING_SNAKE_CASE_				:Tuple				     =						self.type_sequence_label_size
				SCREAMING_SNAKE_CASE_				:List[str]				     =						ViTForImageClassification(UpperCAmelCase)
				model.to(UpperCAmelCase)
				model.eval()
				SCREAMING_SNAKE_CASE_				:Dict				     =						model(UpperCAmelCase   ,  labels=UpperCAmelCase)
				self.parent.assertEqual(result.logits.shape   ,  (self.batch_size, self.type_sequence_label_size))

				# test greyscale images
				SCREAMING_SNAKE_CASE_				:List[str]				     =						1
				SCREAMING_SNAKE_CASE_				:str				     =						ViTForImageClassification(UpperCAmelCase)
				model.to(UpperCAmelCase)
				model.eval()

				SCREAMING_SNAKE_CASE_				:Optional[int]				     =						floats_tensor([self.batch_size, 1, self.image_size, self.image_size])
				SCREAMING_SNAKE_CASE_				:List[str]				     =						model(UpperCAmelCase)
				self.parent.assertEqual(result.logits.shape   ,  (self.batch_size, self.type_sequence_label_size))







		def _snake_case		(						self				:     Optional[Any]):
				SCREAMING_SNAKE_CASE_				:Union[str, Any]				     =						self.prepare_config_and_inputs()
				(
				    (
				    SCREAMING_SNAKE_CASE_
				)     ,				(
				    SCREAMING_SNAKE_CASE_
				)     ,				(
				    SCREAMING_SNAKE_CASE_
				)     ,				
				)				:Optional[Any]				     =						config_and_inputs
				SCREAMING_SNAKE_CASE_				:str				     =						{"pixel_values": pixel_values}
				return config, inputs_dict




@require_torch
class 						_UpperCAmelCase      (     lowercase		,		lowercase		,		unittest.TestCase							):
		lowerCamelCase_	:			List[str]       			=  (
		    (
		        ViTModel,
		        ViTForImageClassification,
		        ViTForMaskedImageModeling,
		    )
		    if is_torch_available()
		    else ()
		)
		lowerCamelCase_	:			str       			=  (
		    {"""feature-extraction""": ViTModel, """image-classification""": ViTForImageClassification}
		    if is_torch_available()
		    else {}
		)
		lowerCamelCase_	:			Optional[Any]       			=  True

		lowerCamelCase_	:			Optional[int]       			=  False
		lowerCamelCase_	:			Tuple       			=  False
		lowerCamelCase_	:			Union[str, Any]       			=  False






		def _snake_case		(						self				:     List[str]):
				SCREAMING_SNAKE_CASE_				:str				     =						ViTModelTester(self)
				SCREAMING_SNAKE_CASE_				:List[Any]				     =						ConfigTester(self   ,  config_class=UpperCAmelCase   ,  has_text_modality=UpperCAmelCase   ,  hidden_size=37)






		def _snake_case		(						self				:     Tuple):
				self.config_tester.run_common_tests()






		@unittest.skip(reason="ViT does not use inputs_embeds")
		def _snake_case		(						self				:     Tuple):
				pass






		def _snake_case		(						self				:     List[str]):
				SCREAMING_SNAKE_CASE_     ,				SCREAMING_SNAKE_CASE_				:List[str]				     =						self.model_tester.prepare_config_and_inputs_for_common()

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






		def _snake_case		(						self				:     Optional[int]):
				SCREAMING_SNAKE_CASE_     ,				SCREAMING_SNAKE_CASE_				:str				     =						self.model_tester.prepare_config_and_inputs_for_common()

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

						SCREAMING_SNAKE_CASE_				:List[str]				     =						["pixel_values"]
						self.assertListEqual(arg_names[:1]   ,  UpperCAmelCase)






		def _snake_case		(						self				:     Optional[int]):
				SCREAMING_SNAKE_CASE_				:List[Any]				     =						self.model_tester.prepare_config_and_inputs()
				self.model_tester.create_and_check_model(*UpperCAmelCase)






		def _snake_case		(						self				:     Dict):
				SCREAMING_SNAKE_CASE_				:int				     =						self.model_tester.prepare_config_and_inputs()
				self.model_tester.create_and_check_for_masked_image_modeling(*UpperCAmelCase)






		def _snake_case		(						self				:     Optional[int]):
				SCREAMING_SNAKE_CASE_				:int				     =						self.model_tester.prepare_config_and_inputs()
				self.model_tester.create_and_check_for_image_classification(*UpperCAmelCase)







		@slow
		def _snake_case		(						self				:     int):
				for model_name in VIT_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
						SCREAMING_SNAKE_CASE_				:List[str]				     =						ViTModel.from_pretrained(UpperCAmelCase)
						self.assertIsNotNone(UpperCAmelCase)




def     lowercase	(    ):



		'''simple docstring'''




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



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






		@cached_property
		def _snake_case		(						self				:     Optional[Any]):
				return ViTImageProcessor.from_pretrained("google/vit-base-patch16-224") if is_vision_available() else None






		@slow
		def _snake_case		(						self				:     List[str]):
				SCREAMING_SNAKE_CASE_				:str				     =						ViTForImageClassification.from_pretrained("google/vit-base-patch16-224").to(UpperCAmelCase)

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

				# forward pass
				with torch.no_grad():
						SCREAMING_SNAKE_CASE_				:int				     =						model(**UpperCAmelCase)

				# verify the logits
				SCREAMING_SNAKE_CASE_				:Optional[int]				     =						torch.Size((1, 10_00))
				self.assertEqual(outputs.logits.shape   ,  UpperCAmelCase)

				SCREAMING_SNAKE_CASE_				:Any				     =						torch.tensor([-0.2744, 0.8215, -0.0836]).to(UpperCAmelCase)

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






		@slow
		def _snake_case		(						self				:     str):
				# ViT models have an `interpolate_pos_encoding` argument in their forward method,
				# allowing to interpolate the pre-trained position embeddings in order to use
				# the model on higher resolutions. The DINO model by Facebook AI leverages this
				# to visualize self-attention on higher resolution images.
				SCREAMING_SNAKE_CASE_				:Tuple				     =						ViTModel.from_pretrained("facebook/dino-vits8").to(UpperCAmelCase)

				SCREAMING_SNAKE_CASE_				:str				     =						ViTImageProcessor.from_pretrained("facebook/dino-vits8"   ,  size=4_80)
				SCREAMING_SNAKE_CASE_				:str				     =						prepare_img()
				SCREAMING_SNAKE_CASE_				:Tuple				     =						image_processor(images=UpperCAmelCase   ,  return_tensors="pt")
				SCREAMING_SNAKE_CASE_				:List[str]				     =						inputs.pixel_values.to(UpperCAmelCase)

				# forward pass
				with torch.no_grad():
						SCREAMING_SNAKE_CASE_				:int				     =						model(UpperCAmelCase   ,  interpolate_pos_encoding=UpperCAmelCase)

				# verify the logits
				SCREAMING_SNAKE_CASE_				:List[Any]				     =						torch.Size((1, 36_01, 3_84))
				self.assertEqual(outputs.last_hidden_state.shape   ,  UpperCAmelCase)

				SCREAMING_SNAKE_CASE_				:Any				     =						torch.tensor(
				    [[4.2340, 4.3906, -6.6692], [4.5463, 1.8928, -6.7257], [4.4429, 0.8496, -5.8585]]).to(UpperCAmelCase)

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







		@slow
		@require_accelerate
		@require_torch_gpu
		def _snake_case		(						self				:     Optional[int]):
				SCREAMING_SNAKE_CASE_				:str				     =						ViTModel.from_pretrained("facebook/dino-vits8"   ,  torch_dtype=torch.floataa   ,  device_map="auto")
				SCREAMING_SNAKE_CASE_				:int				     =						self.default_image_processor

				SCREAMING_SNAKE_CASE_				:Tuple				     =						prepare_img()
				SCREAMING_SNAKE_CASE_				:List[str]				     =						image_processor(images=UpperCAmelCase   ,  return_tensors="pt")
				SCREAMING_SNAKE_CASE_				:Optional[Any]				     =						inputs.pixel_values.to(UpperCAmelCase)

				# forward pass to make sure inference works in fp16
				with torch.no_grad():
						SCREAMING_SNAKE_CASE_				:str				     =						model(UpperCAmelCase)










from typing import Dict, List, Optional, Union

import numpy as np

from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict
from ...image_transforms import convert_to_rgb, normalize, rescale, resize, to_channel_dimension_format
from ...image_utils import (
    OPENAI_CLIP_MEAN,
    OPENAI_CLIP_STD,
    ChannelDimension,
    ImageInput,
    PILImageResampling,
    make_list_of_images,
    to_numpy_array,
    valid_images,
)
from ...utils import TensorType, is_vision_available, logging


if is_vision_available():
		import PIL


SCREAMING_SNAKE_CASE__     					=			logging.get_logger(__name__)



class 						_UpperCAmelCase      (     lowercase							):
		lowerCamelCase_	:			Dict       			=  ["""pixel_values"""]






		def __init__(						self				:     Tuple   ,  UpperCAmelCase				:     bool = True   ,  UpperCAmelCase				:     Dict[str, int] = None   ,  UpperCAmelCase				:     PILImageResampling = PILImageResampling.BICUBIC   ,  UpperCAmelCase				:     bool = True   ,  UpperCAmelCase				:     Union[int, float] = 1 / 2_55   ,  UpperCAmelCase				:     bool = True   ,  UpperCAmelCase				:     Optional[Union[float, List[float]]] = None   ,  UpperCAmelCase				:     Optional[Union[float, List[float]]] = None   ,  UpperCAmelCase				:     bool = True   ,  **UpperCAmelCase				:     Any   ,  ):
				super().__init__(**UpperCAmelCase)
				SCREAMING_SNAKE_CASE_				:List[Any]				     =						size if size is not None else {"height": 3_84, "width": 3_84}
				SCREAMING_SNAKE_CASE_				:str				     =						get_size_dict(UpperCAmelCase   ,  default_to_square=UpperCAmelCase)

				SCREAMING_SNAKE_CASE_				:Optional[Any]				     =						do_resize
				SCREAMING_SNAKE_CASE_				:int				     =						size
				SCREAMING_SNAKE_CASE_				:int				     =						resample
				SCREAMING_SNAKE_CASE_				:Union[str, Any]				     =						do_rescale
				SCREAMING_SNAKE_CASE_				:Union[str, Any]				     =						rescale_factor
				SCREAMING_SNAKE_CASE_				:Union[str, Any]				     =						do_normalize
				SCREAMING_SNAKE_CASE_				:List[Any]				     =						image_mean if image_mean is not None else OPENAI_CLIP_MEAN
				SCREAMING_SNAKE_CASE_				:Dict				     =						image_std if image_std is not None else OPENAI_CLIP_STD
				SCREAMING_SNAKE_CASE_				:List[Any]				     =						do_convert_rgb






		def _snake_case		(						self				:     int   ,  UpperCAmelCase				:     np.ndarray   ,  UpperCAmelCase				:     Dict[str, int]   ,  UpperCAmelCase				:     PILImageResampling = PILImageResampling.BICUBIC   ,  UpperCAmelCase				:     Optional[Union[str, ChannelDimension]] = None   ,  **UpperCAmelCase				:     Any   ,  ):
				SCREAMING_SNAKE_CASE_				:Optional[int]				     =						get_size_dict(UpperCAmelCase   ,  default_to_square=UpperCAmelCase)
				if "height" not in size or "width" not in size:
						raise ValueError(F"The `size` dictionary must contain the keys `height` and `width`. Got {size.keys()}")
				SCREAMING_SNAKE_CASE_				:List[Any]				     =						(size["height"], size["width"])
				return resize(UpperCAmelCase   ,  size=UpperCAmelCase   ,  resample=UpperCAmelCase   ,  data_format=UpperCAmelCase   ,  **UpperCAmelCase)






		def _snake_case		(						self				:     Optional[Any]   ,  UpperCAmelCase				:     np.ndarray   ,  UpperCAmelCase				:     Union[int, float]   ,  UpperCAmelCase				:     Optional[Union[str, ChannelDimension]] = None   ,  **UpperCAmelCase				:     List[str]   ,  ):
				return rescale(UpperCAmelCase   ,  scale=UpperCAmelCase   ,  data_format=UpperCAmelCase   ,  **UpperCAmelCase)






		def _snake_case		(						self				:     Optional[Any]   ,  UpperCAmelCase				:     np.ndarray   ,  UpperCAmelCase				:     Union[float, List[float]]   ,  UpperCAmelCase				:     Union[float, List[float]]   ,  UpperCAmelCase				:     Optional[Union[str, ChannelDimension]] = None   ,  **UpperCAmelCase				:     Optional[Any]   ,  ):
				return normalize(UpperCAmelCase   ,  mean=UpperCAmelCase   ,  std=UpperCAmelCase   ,  data_format=UpperCAmelCase   ,  **UpperCAmelCase)







		def _snake_case		(						self				:     List[Any]   ,  UpperCAmelCase				:     ImageInput   ,  UpperCAmelCase				:     Optional[bool] = None   ,  UpperCAmelCase				:     Optional[Dict[str, int]] = None   ,  UpperCAmelCase				:     PILImageResampling = None   ,  UpperCAmelCase				:     Optional[bool] = None   ,  UpperCAmelCase				:     Optional[float] = None   ,  UpperCAmelCase				:     Optional[bool] = None   ,  UpperCAmelCase				:     Optional[Union[float, List[float]]] = None   ,  UpperCAmelCase				:     Optional[Union[float, List[float]]] = None   ,  UpperCAmelCase				:     Optional[Union[str, TensorType]] = None   ,  UpperCAmelCase				:     bool = None   ,  UpperCAmelCase				:     ChannelDimension = ChannelDimension.FIRST   ,  **UpperCAmelCase				:     Dict   ,  ):
				SCREAMING_SNAKE_CASE_				:Union[str, Any]				     =						do_resize if do_resize is not None else self.do_resize
				SCREAMING_SNAKE_CASE_				:Tuple				     =						resample if resample is not None else self.resample
				SCREAMING_SNAKE_CASE_				:List[Any]				     =						do_rescale if do_rescale is not None else self.do_rescale
				SCREAMING_SNAKE_CASE_				:Union[str, Any]				     =						rescale_factor if rescale_factor is not None else self.rescale_factor
				SCREAMING_SNAKE_CASE_				:Dict				     =						do_normalize if do_normalize is not None else self.do_normalize
				SCREAMING_SNAKE_CASE_				:List[str]				     =						image_mean if image_mean is not None else self.image_mean
				SCREAMING_SNAKE_CASE_				:Optional[int]				     =						image_std if image_std is not None else self.image_std
				SCREAMING_SNAKE_CASE_				:Tuple				     =						do_convert_rgb if do_convert_rgb is not None else self.do_convert_rgb

				SCREAMING_SNAKE_CASE_				:Dict				     =						size if size is not None else self.size
				SCREAMING_SNAKE_CASE_				:Tuple				     =						get_size_dict(UpperCAmelCase   ,  default_to_square=UpperCAmelCase)

				SCREAMING_SNAKE_CASE_				:Tuple				     =						make_list_of_images(UpperCAmelCase)

				if not valid_images(UpperCAmelCase):
						raise ValueError(
						    "Invalid image type. Must be of type PIL.Image.Image, numpy.ndarray, "
						    "torch.Tensor, tf.Tensor or jax.ndarray.")

				if do_resize and size is None or resample is None:
						raise ValueError("Size and resample must be specified if do_resize is True.")

				if do_rescale and rescale_factor is None:
						raise ValueError("Rescale factor must be specified if do_rescale is True.")

				if do_normalize and (image_mean is None or image_std is None):
						raise ValueError("Image mean and std must be specified if do_normalize is True.")

				# PIL RGBA images are converted to RGB
				if do_convert_rgb:
						SCREAMING_SNAKE_CASE_				:Union[str, Any]				     =						[convert_to_rgb(UpperCAmelCase) for image in images]

				# All transformations expect numpy arrays.
				SCREAMING_SNAKE_CASE_				:List[str]				     =						[to_numpy_array(UpperCAmelCase) for image in images]

				if do_resize:
						SCREAMING_SNAKE_CASE_				:List[str]				     =						[self.resize(image=UpperCAmelCase   ,  size=UpperCAmelCase   ,  resample=UpperCAmelCase) for image in images]

				if do_rescale:
						SCREAMING_SNAKE_CASE_				:Union[str, Any]				     =						[self.rescale(image=UpperCAmelCase   ,  scale=UpperCAmelCase) for image in images]

				if do_normalize:
						SCREAMING_SNAKE_CASE_				:Union[str, Any]				     =						[self.normalize(image=UpperCAmelCase   ,  mean=UpperCAmelCase   ,  std=UpperCAmelCase) for image in images]

				SCREAMING_SNAKE_CASE_				:Optional[Any]				     =						[to_channel_dimension_format(UpperCAmelCase   ,  UpperCAmelCase) for image in images]

				SCREAMING_SNAKE_CASE_				:Optional[int]				     =						BatchFeature(data={"pixel_values": images}   ,  tensor_type=UpperCAmelCase)

				return encoded_outputs






