



"""simple docstring"""







import unittest

from transformers import AlbertConfig, is_torch_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, ids_tensor, random_attention_mask
from ...test_pipeline_mixin import PipelineTesterMixin


if is_torch_available():
	import torch

	from transformers import (
	    MODEL_FOR_PRETRAINING_MAPPING,
	    AlbertForMaskedLM,
	    AlbertForMultipleChoice,
	    AlbertForPreTraining,
	    AlbertForQuestionAnswering,
	    AlbertForSequenceClassification,
	    AlbertForTokenClassification,
	    AlbertModel,
	)
	from transformers.models.albert.modeling_albert import ALBERT_PRETRAINED_MODEL_ARCHIVE_LIST







class 					A_:







			"""simple docstring"""



			def __init__(	self				,   A				,   A=13				,   A=7				,   A=True				,   A=True				,   A=True				,   A=True				,   A=99				,   A=16				,   A=36				,   A=6				,   A=6				,   A=6				,   A=37				,   A="gelu"				,   A=0.1				,   A=0.1				,   A=512				,   A=16				,   A=2				,   A=0.0_2				,   A=3				,   A=4				,   A=None				,   ):
						_lowerCamelCase					:					Any	       =    parent
						_lowerCamelCase					:					Union[str, Any]	       =    batch_size
						_lowerCamelCase					:					int	       =    seq_length
						_lowerCamelCase					:					Any	       =    is_training
						_lowerCamelCase					:					str	       =    use_input_mask
						_lowerCamelCase					:					Dict	       =    use_token_type_ids
						_lowerCamelCase					:					Any	       =    use_labels
						_lowerCamelCase					:					Any	       =    vocab_size
						_lowerCamelCase					:					Dict	       =    embedding_size
						_lowerCamelCase					:					Dict	       =    hidden_size
						_lowerCamelCase					:					Dict	       =    num_hidden_layers
						_lowerCamelCase					:					Dict	       =    num_hidden_groups
						_lowerCamelCase					:					int	       =    num_attention_heads
						_lowerCamelCase					:					List[str]	       =    intermediate_size
						_lowerCamelCase					:					Any	       =    hidden_act
						_lowerCamelCase					:					Dict	       =    hidden_dropout_prob
						_lowerCamelCase					:					Any	       =    attention_probs_dropout_prob
						_lowerCamelCase					:					Tuple	       =    max_position_embeddings
						_lowerCamelCase					:					Tuple	       =    type_vocab_size
						_lowerCamelCase					:					List[Any]	       =    type_sequence_label_size
						_lowerCamelCase					:					Any	       =    initializer_range
						_lowerCamelCase					:					int	       =    num_labels
						_lowerCamelCase					:					Optional[int]	       =    num_choices
						_lowerCamelCase					:					Tuple	       =    scope
			def    _lowerCAmelCase		(	self							):
						_lowerCamelCase					:					Union[str, Any]	       =    ids_tensor([self.batch_size, self.seq_length]				,   self.vocab_size							)

						_lowerCamelCase					:					Tuple	       =    None
						if self.use_input_mask:
									_lowerCamelCase					:					Union[str, Any]	       =    random_attention_mask([self.batch_size, self.seq_length]							)

						_lowerCamelCase					:					Dict	       =    None
						if self.use_token_type_ids:
									_lowerCamelCase					:					int	       =    ids_tensor([self.batch_size, self.seq_length]				,   self.type_vocab_size							)

						_lowerCamelCase					:					Tuple	       =    None
						_lowerCamelCase					:					Dict	       =    None
						_lowerCamelCase					:					Tuple	       =    None
						if self.use_labels:
									_lowerCamelCase					:					Optional[int]	       =    ids_tensor([self.batch_size]				,   self.type_sequence_label_size							)
									_lowerCamelCase					:					Dict	       =    ids_tensor([self.batch_size, self.seq_length]				,   self.num_labels							)
									_lowerCamelCase					:					List[Any]	       =    ids_tensor([self.batch_size]				,   self.num_choices							)

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

						return config, input_ids, token_type_ids, input_mask, sequence_labels, token_labels, choice_labels
			def    _lowerCAmelCase		(	self							):
						return AlbertConfig(
						    vocab_size=self.vocab_size				,   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				,   max_position_embeddings=self.max_position_embeddings				,   type_vocab_size=self.type_vocab_size				,   initializer_range=self.initializer_range				,   num_hidden_groups=self.num_hidden_groups				,   )
			def    _lowerCAmelCase		(	self				,   A				,   A				,   A				,   A				,   A				,   A				,   A							):
						_lowerCamelCase					:					int	       =    AlbertModel(config=SCREAMING_SNAKE_CASE_							)
						model.to(SCREAMING_SNAKE_CASE_							)
						model.eval()
						_lowerCamelCase					:					Optional[int]	       =    model(SCREAMING_SNAKE_CASE_				,   attention_mask=SCREAMING_SNAKE_CASE_				,   token_type_ids=SCREAMING_SNAKE_CASE_							)
						_lowerCamelCase					:					List[Any]	       =    model(SCREAMING_SNAKE_CASE_				,   token_type_ids=SCREAMING_SNAKE_CASE_							)
						_lowerCamelCase					:					Union[str, Any]	       =    model(SCREAMING_SNAKE_CASE_							)
						self.parent.assertEqual(result.last_hidden_state.shape				,   (self.batch_size, self.seq_length, self.hidden_size)							)
						self.parent.assertEqual(result.pooler_output.shape				,   (self.batch_size, self.hidden_size)							)
			def    _lowerCAmelCase		(	self				,   A				,   A				,   A				,   A				,   A				,   A				,   A							):
						_lowerCamelCase					:					Any	       =    AlbertForPreTraining(config=SCREAMING_SNAKE_CASE_							)
						model.to(SCREAMING_SNAKE_CASE_							)
						model.eval()
						_lowerCamelCase					:					List[Any]	       =    model(
						    SCREAMING_SNAKE_CASE_				,   attention_mask=SCREAMING_SNAKE_CASE_				,   token_type_ids=SCREAMING_SNAKE_CASE_				,   labels=SCREAMING_SNAKE_CASE_				,   sentence_order_label=SCREAMING_SNAKE_CASE_				,   )
						self.parent.assertEqual(result.prediction_logits.shape				,   (self.batch_size, self.seq_length, self.vocab_size)							)
						self.parent.assertEqual(result.sop_logits.shape				,   (self.batch_size, config.num_labels)							)
			def    _lowerCAmelCase		(	self				,   A				,   A				,   A				,   A				,   A				,   A				,   A							):
						_lowerCamelCase					:					Optional[int]	       =    AlbertForMaskedLM(config=SCREAMING_SNAKE_CASE_							)
						model.to(SCREAMING_SNAKE_CASE_							)
						model.eval()
						_lowerCamelCase					:					Optional[Any]	       =    model(SCREAMING_SNAKE_CASE_				,   attention_mask=SCREAMING_SNAKE_CASE_				,   token_type_ids=SCREAMING_SNAKE_CASE_				,   labels=SCREAMING_SNAKE_CASE_							)
						self.parent.assertEqual(result.logits.shape				,   (self.batch_size, self.seq_length, self.vocab_size)							)
			def    _lowerCAmelCase		(	self				,   A				,   A				,   A				,   A				,   A				,   A				,   A							):
						_lowerCamelCase					:					Optional[Any]	       =    AlbertForQuestionAnswering(config=SCREAMING_SNAKE_CASE_							)
						model.to(SCREAMING_SNAKE_CASE_							)
						model.eval()
						_lowerCamelCase					:					Any	       =    model(
						    SCREAMING_SNAKE_CASE_				,   attention_mask=SCREAMING_SNAKE_CASE_				,   token_type_ids=SCREAMING_SNAKE_CASE_				,   start_positions=SCREAMING_SNAKE_CASE_				,   end_positions=SCREAMING_SNAKE_CASE_				,   )
						self.parent.assertEqual(result.start_logits.shape				,   (self.batch_size, self.seq_length)							)
						self.parent.assertEqual(result.end_logits.shape				,   (self.batch_size, self.seq_length)							)
			def    _lowerCAmelCase		(	self				,   A				,   A				,   A				,   A				,   A				,   A				,   A							):
						_lowerCamelCase					:					Optional[Any]	       =    self.num_labels
						_lowerCamelCase					:					List[Any]	       =    AlbertForSequenceClassification(SCREAMING_SNAKE_CASE_							)
						model.to(SCREAMING_SNAKE_CASE_							)
						model.eval()
						_lowerCamelCase					:					str	       =    model(SCREAMING_SNAKE_CASE_				,   attention_mask=SCREAMING_SNAKE_CASE_				,   token_type_ids=SCREAMING_SNAKE_CASE_				,   labels=SCREAMING_SNAKE_CASE_							)
						self.parent.assertEqual(result.logits.shape				,   (self.batch_size, self.num_labels)							)
			def    _lowerCAmelCase		(	self				,   A				,   A				,   A				,   A				,   A				,   A				,   A							):
						_lowerCamelCase					:					List[str]	       =    self.num_labels
						_lowerCamelCase					:					Union[str, Any]	       =    AlbertForTokenClassification(config=SCREAMING_SNAKE_CASE_							)
						model.to(SCREAMING_SNAKE_CASE_							)
						model.eval()
						_lowerCamelCase					:					List[str]	       =    model(SCREAMING_SNAKE_CASE_				,   attention_mask=SCREAMING_SNAKE_CASE_				,   token_type_ids=SCREAMING_SNAKE_CASE_				,   labels=SCREAMING_SNAKE_CASE_							)
						self.parent.assertEqual(result.logits.shape				,   (self.batch_size, self.seq_length, self.num_labels)							)
			def    _lowerCAmelCase		(	self				,   A				,   A				,   A				,   A				,   A				,   A				,   A							):
						_lowerCamelCase					:					Dict	       =    self.num_choices
						_lowerCamelCase					:					Dict	       =    AlbertForMultipleChoice(config=SCREAMING_SNAKE_CASE_							)
						model.to(SCREAMING_SNAKE_CASE_							)
						model.eval()
						_lowerCamelCase					:					str	       =    input_ids.unsqueeze(1							).expand(-1				,   self.num_choices				,   -1							).contiguous()
						_lowerCamelCase					:					str	       =    token_type_ids.unsqueeze(1							).expand(-1				,   self.num_choices				,   -1							).contiguous()
						_lowerCamelCase					:					List[Any]	       =    input_mask.unsqueeze(1							).expand(-1				,   self.num_choices				,   -1							).contiguous()
						_lowerCamelCase					:					Union[str, Any]	       =    model(
						    SCREAMING_SNAKE_CASE_				,   attention_mask=SCREAMING_SNAKE_CASE_				,   token_type_ids=SCREAMING_SNAKE_CASE_				,   labels=SCREAMING_SNAKE_CASE_				,   )
						self.parent.assertEqual(result.logits.shape				,   (self.batch_size, self.num_choices)							)

			def    _lowerCAmelCase		(	self							):
						_lowerCamelCase					:					Optional[Any]	       =    self.prepare_config_and_inputs()
						(
						    _lowerCamelCase							
						)					:					List[str]	       =    config_and_inputs
						_lowerCamelCase					:					Tuple	       =    {"""input_ids""": input_ids, """token_type_ids""": token_type_ids, """attention_mask""": input_mask}
						return config, inputs_dict







@require_torch
class 					A_(_lowerCAmelCase   ,   _lowerCAmelCase   ,   unittest.TestCase      ):







			"""simple docstring"""



			a_       :			int												=			(
			    (
			        AlbertModel,
			        AlbertForPreTraining,
			        AlbertForMaskedLM,
			        AlbertForMultipleChoice,
			        AlbertForSequenceClassification,
			        AlbertForTokenClassification,
			        AlbertForQuestionAnswering,
			    )
			    if is_torch_available()
			    else ()
			)
			a_       :			str												=			(
			    {
			        """feature-extraction""": AlbertModel,
			        """fill-mask""": AlbertForMaskedLM,
			        """question-answering""": AlbertForQuestionAnswering,
			        """text-classification""": AlbertForSequenceClassification,
			        """token-classification""": AlbertForTokenClassification,
			        """zero-shot""": AlbertForSequenceClassification,
			    }
			    if is_torch_available()
			    else {}
			)
			a_       :			int												=			True
			def    _lowerCAmelCase		(	self				,   A				,   A				,   A=False							):
						_lowerCamelCase					:					Tuple	       =    super()._prepare_for_class(SCREAMING_SNAKE_CASE_				,   SCREAMING_SNAKE_CASE_				,   return_labels=SCREAMING_SNAKE_CASE_							)

						if return_labels:
									if model_class in get_values(SCREAMING_SNAKE_CASE_							):
												_lowerCamelCase					:					Dict	       =    torch.zeros(
												    (self.model_tester.batch_size, self.model_tester.seq_length)				,   dtype=torch.long				,   device=SCREAMING_SNAKE_CASE_							)
												_lowerCamelCase					:					Optional[int]	       =    torch.zeros(
												    self.model_tester.batch_size				,   dtype=torch.long				,   device=SCREAMING_SNAKE_CASE_							)
						return inputs_dict
			def    _lowerCAmelCase		(	self							):
						_lowerCamelCase					:					Any	       =    AlbertModelTester(self							)
						_lowerCamelCase					:					Union[str, Any]	       =    ConfigTester(self				,   config_class=SCREAMING_SNAKE_CASE_				,   hidden_size=37							)
			def    _lowerCAmelCase		(	self							):
						self.config_tester.run_common_tests()
			def    _lowerCAmelCase		(	self							):
						_lowerCamelCase					:					List[Any]	       =    self.model_tester.prepare_config_and_inputs()
						self.model_tester.create_and_check_model(*SCREAMING_SNAKE_CASE_							)
			def    _lowerCAmelCase		(	self							):
						_lowerCamelCase					:					int	       =    self.model_tester.prepare_config_and_inputs()
						self.model_tester.create_and_check_for_pretraining(*SCREAMING_SNAKE_CASE_							)
			def    _lowerCAmelCase		(	self							):
						_lowerCamelCase					:					Tuple	       =    self.model_tester.prepare_config_and_inputs()
						self.model_tester.create_and_check_for_masked_lm(*SCREAMING_SNAKE_CASE_							)
			def    _lowerCAmelCase		(	self							):
						_lowerCamelCase					:					Optional[Any]	       =    self.model_tester.prepare_config_and_inputs()
						self.model_tester.create_and_check_for_multiple_choice(*SCREAMING_SNAKE_CASE_							)
			def    _lowerCAmelCase		(	self							):
						_lowerCamelCase					:					List[str]	       =    self.model_tester.prepare_config_and_inputs()
						self.model_tester.create_and_check_for_question_answering(*SCREAMING_SNAKE_CASE_							)
			def    _lowerCAmelCase		(	self							):
						_lowerCamelCase					:					Optional[int]	       =    self.model_tester.prepare_config_and_inputs()
						self.model_tester.create_and_check_for_sequence_classification(*SCREAMING_SNAKE_CASE_							)
			def    _lowerCAmelCase		(	self							):
						_lowerCamelCase					:					Optional[Any]	       =    self.model_tester.prepare_config_and_inputs()
						for type in ["absolute", "relative_key", "relative_key_query"]:
									_lowerCamelCase					:					Union[str, Any]	       =    type
									self.model_tester.create_and_check_model(*SCREAMING_SNAKE_CASE_							)

			@slow
			def    _lowerCAmelCase		(	self							):
						for model_name in ALBERT_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
									_lowerCamelCase					:					Dict	       =    AlbertModel.from_pretrained(SCREAMING_SNAKE_CASE_							)
									self.assertIsNotNone(SCREAMING_SNAKE_CASE_							)







@require_torch
class 					A_(unittest.TestCase      ):







			"""simple docstring"""



			@slow
			def    _lowerCAmelCase		(	self							):
						_lowerCamelCase					:					str	       =    AlbertModel.from_pretrained('albert-base-v2'							)
						_lowerCamelCase					:					List[str]	       =    torch.tensor([[0, 345, 232, 328, 740, 140, 1695, 69, 6078, 1588, 2]]							)
						_lowerCamelCase					:					List[str]	       =    torch.tensor([[0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]							)
						with torch.no_grad():
									_lowerCamelCase					:					Union[str, Any]	       =    model(SCREAMING_SNAKE_CASE_				,   attention_mask=SCREAMING_SNAKE_CASE_							)[0]
						_lowerCamelCase					:					List[str]	       =    torch.Size((1, 11, 768)							)
						self.assertEqual(output.shape				,   SCREAMING_SNAKE_CASE_							)
						_lowerCamelCase					:					Dict	       =    torch.tensor(
						    [[[-0.6_5_1_3, 1.5_0_3_5, -0.2_7_6_6], [-0.6_5_1_5, 1.5_0_4_6, -0.2_7_8_0], [-0.6_5_1_2, 1.5_0_4_9, -0.2_7_8_4]]]							)

						self.assertTrue(torch.allclose(output[:, 1:4, 1:4]				,   SCREAMING_SNAKE_CASE_				,   atol=1E-4							)							)










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 (
    center_crop,
    convert_to_rgb,
    get_resize_output_image_size,
    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


a      :  List[str]			     =			logging.get_logger(__name__)


if is_vision_available():
	import PIL







class 				_a				(   _lowerCAmelCase					):
			A      		=	['''pixel_values''']

			def __init__(self,   SCREAMING_SNAKE_CASE_ = True,   SCREAMING_SNAKE_CASE_ = None,   SCREAMING_SNAKE_CASE_ = PILImageResampling.BICUBIC,   SCREAMING_SNAKE_CASE_ = True,   SCREAMING_SNAKE_CASE_ = None,   SCREAMING_SNAKE_CASE_ = True,   SCREAMING_SNAKE_CASE_ = 1 / 255,   SCREAMING_SNAKE_CASE_ = True,   SCREAMING_SNAKE_CASE_ = None,   SCREAMING_SNAKE_CASE_ = None,   SCREAMING_SNAKE_CASE_ = True,   **SCREAMING_SNAKE_CASE_,   )       ->   None:
						super().__init__(**SCREAMING_SNAKE_CASE_					)
						UpperCAmelCase_:		Optional[Any]							      =     size if size is not None else {"""shortest_edge""": 224}
						UpperCAmelCase_:		int							      =     get_size_dict(SCREAMING_SNAKE_CASE_,   default_to_square=SCREAMING_SNAKE_CASE_					)
						UpperCAmelCase_:		Dict							      =     crop_size if crop_size is not None else {"""height""": 224, """width""": 224}
						UpperCAmelCase_:		Union[str, Any]							      =     get_size_dict(SCREAMING_SNAKE_CASE_,   default_to_square=SCREAMING_SNAKE_CASE_,   param_name="""crop_size"""					)

						UpperCAmelCase_:		Optional[int]							      =     do_resize
						UpperCAmelCase_:		Optional[int]							      =     size
						UpperCAmelCase_:		Optional[int]							      =     resample
						UpperCAmelCase_:		Tuple							      =     do_center_crop
						UpperCAmelCase_:		Optional[int]							      =     crop_size
						UpperCAmelCase_:		str							      =     do_rescale
						UpperCAmelCase_:		Optional[int]							      =     rescale_factor
						UpperCAmelCase_:		List[str]							      =     do_normalize
						UpperCAmelCase_:		Any							      =     image_mean if image_mean is not None else OPENAI_CLIP_MEAN
						UpperCAmelCase_:		Dict							      =     image_std if image_std is not None else OPENAI_CLIP_STD
						UpperCAmelCase_:		Any							      =     do_convert_rgb

			def      __snake_case       (self,   SCREAMING_SNAKE_CASE_,   SCREAMING_SNAKE_CASE_,   SCREAMING_SNAKE_CASE_ = PILImageResampling.BICUBIC,   SCREAMING_SNAKE_CASE_ = None,   **SCREAMING_SNAKE_CASE_,   )       ->   np.ndarray:
						UpperCAmelCase_:		Optional[Any]							      =     get_size_dict(SCREAMING_SNAKE_CASE_,   default_to_square=SCREAMING_SNAKE_CASE_					)
						if "shortest_edge" not in size:
									raise ValueError(f'The `size` parameter must contain the key `shortest_edge`. Got {size.keys()}'					)
						UpperCAmelCase_:		Optional[Any]							      =     get_resize_output_image_size(SCREAMING_SNAKE_CASE_,   size=size["""shortest_edge"""],   default_to_square=SCREAMING_SNAKE_CASE_					)
						return resize(SCREAMING_SNAKE_CASE_,   size=SCREAMING_SNAKE_CASE_,   resample=SCREAMING_SNAKE_CASE_,   data_format=SCREAMING_SNAKE_CASE_,   **SCREAMING_SNAKE_CASE_					)

			def      __snake_case       (self,   SCREAMING_SNAKE_CASE_,   SCREAMING_SNAKE_CASE_,   SCREAMING_SNAKE_CASE_ = None,   **SCREAMING_SNAKE_CASE_,   )       ->   np.ndarray:
						UpperCAmelCase_:		Any							      =     get_size_dict(SCREAMING_SNAKE_CASE_					)
						if "height" not in size or "width" not in size:
									raise ValueError(f'The `size` parameter must contain the keys (height, width). Got {size.keys()}'					)
						return center_crop(SCREAMING_SNAKE_CASE_,   size=(size["""height"""], size["""width"""]),   data_format=SCREAMING_SNAKE_CASE_,   **SCREAMING_SNAKE_CASE_					)

			def      __snake_case       (self,   SCREAMING_SNAKE_CASE_,   SCREAMING_SNAKE_CASE_,   SCREAMING_SNAKE_CASE_ = None,   **SCREAMING_SNAKE_CASE_,   )       ->   Union[str, Any]:
						return rescale(SCREAMING_SNAKE_CASE_,   scale=SCREAMING_SNAKE_CASE_,   data_format=SCREAMING_SNAKE_CASE_,   **SCREAMING_SNAKE_CASE_					)

			def      __snake_case       (self,   SCREAMING_SNAKE_CASE_,   SCREAMING_SNAKE_CASE_,   SCREAMING_SNAKE_CASE_,   SCREAMING_SNAKE_CASE_ = None,   **SCREAMING_SNAKE_CASE_,   )       ->   np.ndarray:
						return normalize(SCREAMING_SNAKE_CASE_,   mean=SCREAMING_SNAKE_CASE_,   std=SCREAMING_SNAKE_CASE_,   data_format=SCREAMING_SNAKE_CASE_,   **SCREAMING_SNAKE_CASE_					)

			def      __snake_case       (self,   SCREAMING_SNAKE_CASE_,   SCREAMING_SNAKE_CASE_ = None,   SCREAMING_SNAKE_CASE_ = None,   SCREAMING_SNAKE_CASE_ = None,   SCREAMING_SNAKE_CASE_ = None,   SCREAMING_SNAKE_CASE_ = None,   SCREAMING_SNAKE_CASE_ = None,   SCREAMING_SNAKE_CASE_ = None,   SCREAMING_SNAKE_CASE_ = None,   SCREAMING_SNAKE_CASE_ = None,   SCREAMING_SNAKE_CASE_ = None,   SCREAMING_SNAKE_CASE_ = None,   SCREAMING_SNAKE_CASE_ = None,   SCREAMING_SNAKE_CASE_ = ChannelDimension.FIRST,   **SCREAMING_SNAKE_CASE_,   )       ->   PIL.Image.Image:
						UpperCAmelCase_:		Tuple							      =     do_resize if do_resize is not None else self.do_resize
						UpperCAmelCase_:		Tuple							      =     size if size is not None else self.size
						UpperCAmelCase_:		str							      =     get_size_dict(SCREAMING_SNAKE_CASE_,   param_name="""size""",   default_to_square=SCREAMING_SNAKE_CASE_					)
						UpperCAmelCase_:		List[str]							      =     resample if resample is not None else self.resample
						UpperCAmelCase_:		Optional[int]							      =     do_center_crop if do_center_crop is not None else self.do_center_crop
						UpperCAmelCase_:		Tuple							      =     crop_size if crop_size is not None else self.crop_size
						UpperCAmelCase_:		int							      =     get_size_dict(SCREAMING_SNAKE_CASE_,   param_name="""crop_size""",   default_to_square=SCREAMING_SNAKE_CASE_					)
						UpperCAmelCase_:		Union[str, Any]							      =     do_rescale if do_rescale is not None else self.do_rescale
						UpperCAmelCase_:		int							      =     rescale_factor if rescale_factor is not None else self.rescale_factor
						UpperCAmelCase_:		Tuple							      =     do_normalize if do_normalize is not None else self.do_normalize
						UpperCAmelCase_:		Dict							      =     image_mean if image_mean is not None else self.image_mean
						UpperCAmelCase_:		int							      =     image_std if image_std is not None else self.image_std
						UpperCAmelCase_:		Union[str, Any]							      =     do_convert_rgb if do_convert_rgb is not None else self.do_convert_rgb

						UpperCAmelCase_:		List[str]							      =     make_list_of_images(SCREAMING_SNAKE_CASE_					)

						if not valid_images(SCREAMING_SNAKE_CASE_					):
									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:
									raise ValueError("""Size must be specified if do_resize is True."""					)

						if do_center_crop and crop_size is None:
									raise ValueError("""Crop size must be specified if do_center_crop 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:
									UpperCAmelCase_:		Any							      =     [convert_to_rgb(SCREAMING_SNAKE_CASE_					) for image in images]

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

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

						if do_center_crop:
									UpperCAmelCase_:		Dict							      =     [self.center_crop(image=SCREAMING_SNAKE_CASE_,   size=SCREAMING_SNAKE_CASE_					) for image in images]

						if do_rescale:
									UpperCAmelCase_:		Optional[Any]							      =     [self.rescale(image=SCREAMING_SNAKE_CASE_,   scale=SCREAMING_SNAKE_CASE_					) for image in images]

						if do_normalize:
									UpperCAmelCase_:		Dict							      =     [self.normalize(image=SCREAMING_SNAKE_CASE_,   mean=SCREAMING_SNAKE_CASE_,   std=SCREAMING_SNAKE_CASE_					) for image in images]

						UpperCAmelCase_:		Tuple							      =     [to_channel_dimension_format(SCREAMING_SNAKE_CASE_,   SCREAMING_SNAKE_CASE_					) for image in images]

						UpperCAmelCase_:		Union[str, Any]							      =     {"""pixel_values""": images}
						return BatchFeature(data=SCREAMING_SNAKE_CASE_,   tensor_type=SCREAMING_SNAKE_CASE_					)






