



from __future__ import annotations

import os
import tempfile
import unittest

from transformers import ConvBertConfig, is_tf_available
from transformers.testing_utils import require_tf, slow

from ...test_configuration_common import ConfigTester
from ...test_modeling_tf_common import TFModelTesterMixin, ids_tensor, random_attention_mask
from ...test_pipeline_mixin import PipelineTesterMixin


if is_tf_available():
				import tensorflow as tf

				from transformers import (
				    TFConvBertForMaskedLM,
				    TFConvBertForMultipleChoice,
				    TFConvBertForQuestionAnswering,
				    TFConvBertForSequenceClassification,
				    TFConvBertForTokenClassification,
				    TFConvBertModel,
				)



class        lowerCAmelCase__					:


				def __init__(							self      :  Any						, __UpperCamelCase      :  int						, __UpperCamelCase      :  Optional[Any]=13						, __UpperCamelCase      :  Optional[int]=7						, __UpperCamelCase      :  str=True						, __UpperCamelCase      :  Tuple=True						, __UpperCamelCase      :  Optional[int]=True						, __UpperCamelCase      :  Union[str, Any]=True						, __UpperCamelCase      :  Optional[Any]=99						, __UpperCamelCase      :  Any=32						, __UpperCamelCase      :  List[str]=2						, __UpperCamelCase      :  int=4						, __UpperCamelCase      :  Dict=37						, __UpperCamelCase      :  int="gelu"						, __UpperCamelCase      :  Optional[Any]=0.1						, __UpperCamelCase      :  Union[str, Any]=0.1						, __UpperCamelCase      :  List[Any]=512						, __UpperCamelCase      :  Union[str, Any]=16						, __UpperCamelCase      :  List[str]=2						, __UpperCamelCase      :  Union[str, Any]=0.0_2						, __UpperCamelCase      :  Tuple=3						, __UpperCamelCase      :  Any=4						, __UpperCamelCase      :  Dict=None						, )		->     str:
											A      						=    parent
											A      						=    13
											A      						=    7
											A      						=    True
											A      						=    True
											A      						=    True
											A      						=    True
											A      						=    99
											A      						=    384
											A      						=    2
											A      						=    4
											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      						=    128
											A      						=    2
											A      						=    9
											A      						=    1
											A      						=    None


				def __UpperCamelCase						(							self      :  str       )		->     List[str]:
											A      						=    ids_tensor([self.batch_size, self.seq_length]						, self.vocab_size       )

											A      						=    None
											if self.use_input_mask:
																		A      						=    random_attention_mask([self.batch_size, self.seq_length]       )

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

											A      						=    None
											A      						=    None
											A      						=    None
											if self.use_labels:
																		A      						=    ids_tensor([self.batch_size]						, self.type_sequence_label_size       )
																		A      						=    ids_tensor([self.batch_size, self.seq_length]						, self.num_labels       )
																		A      						=    ids_tensor([self.batch_size]						, self.num_choices       )

											A      						=    ConvBertConfig(
											    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						, return_dict=__UpperCamelCase						, )

											return config, input_ids, token_type_ids, input_mask, sequence_labels, token_labels, choice_labels


				def __UpperCamelCase						(							self      :  Union[str, Any]						, __UpperCamelCase      :  str						, __UpperCamelCase      :  List[str]						, __UpperCamelCase      :  Dict						, __UpperCamelCase      :  str						, __UpperCamelCase      :  Optional[int]						, __UpperCamelCase      :  List[Any]						, __UpperCamelCase      :  List[str]       )		->     Optional[int]:
											A      						=    TFConvBertModel(config=__UpperCamelCase       )
											A      						=    {'input_ids': input_ids, 'attention_mask': input_mask, 'token_type_ids': token_type_ids}

											A      						=    [input_ids, input_mask]
											A      						=    model(__UpperCamelCase       )

											A      						=    model(__UpperCamelCase       )

											self.parent.assertEqual(result.last_hidden_state.shape						, (self.batch_size, self.seq_length, self.hidden_size)       )


				def __UpperCamelCase						(							self      :  Union[str, Any]						, __UpperCamelCase      :  List[str]						, __UpperCamelCase      :  Union[str, Any]						, __UpperCamelCase      :  Union[str, Any]						, __UpperCamelCase      :  List[str]						, __UpperCamelCase      :  str						, __UpperCamelCase      :  Dict						, __UpperCamelCase      :  Any       )		->     List[str]:
											A      						=    TFConvBertForMaskedLM(config=__UpperCamelCase       )
											A      						=    {
											    'input_ids': input_ids,
											    'attention_mask': input_mask,
											    'token_type_ids': token_type_ids,
											}
											A      						=    model(__UpperCamelCase       )
											self.parent.assertEqual(result.logits.shape						, (self.batch_size, self.seq_length, self.vocab_size)       )


				def __UpperCamelCase						(							self      :  Union[str, Any]						, __UpperCamelCase      :  Dict						, __UpperCamelCase      :  Optional[int]						, __UpperCamelCase      :  List[str]						, __UpperCamelCase      :  List[str]						, __UpperCamelCase      :  List[Any]						, __UpperCamelCase      :  Union[str, Any]						, __UpperCamelCase      :  List[str]       )		->     List[str]:
											A      						=    self.num_labels
											A      						=    TFConvBertForSequenceClassification(config=__UpperCamelCase       )
											A      						=    {
											    'input_ids': input_ids,
											    'attention_mask': input_mask,
											    'token_type_ids': token_type_ids,
											}

											A      						=    model(__UpperCamelCase       )
											self.parent.assertEqual(result.logits.shape						, (self.batch_size, self.num_labels)       )


				def __UpperCamelCase						(							self      :  int						, __UpperCamelCase      :  Union[str, Any]						, __UpperCamelCase      :  Optional[Any]						, __UpperCamelCase      :  Dict						, __UpperCamelCase      :  List[Any]						, __UpperCamelCase      :  Optional[int]						, __UpperCamelCase      :  Optional[int]						, __UpperCamelCase      :  Optional[Any]       )		->     Any:
											A      						=    self.num_choices
											A      						=    TFConvBertForMultipleChoice(config=__UpperCamelCase       )
											A      						=    tf.tile(tf.expand_dims(__UpperCamelCase						, 1       )						, (1, self.num_choices, 1)       )
											A      						=    tf.tile(tf.expand_dims(__UpperCamelCase						, 1       )						, (1, self.num_choices, 1)       )
											A      						=    tf.tile(tf.expand_dims(__UpperCamelCase						, 1       )						, (1, self.num_choices, 1)       )
											A      						=    {
											    'input_ids': multiple_choice_inputs_ids,
											    'attention_mask': multiple_choice_input_mask,
											    'token_type_ids': multiple_choice_token_type_ids,
											}
											A      						=    model(__UpperCamelCase       )
											self.parent.assertEqual(result.logits.shape						, (self.batch_size, self.num_choices)       )


				def __UpperCamelCase						(							self      :  int						, __UpperCamelCase      :  List[str]						, __UpperCamelCase      :  int						, __UpperCamelCase      :  Dict						, __UpperCamelCase      :  Any						, __UpperCamelCase      :  List[Any]						, __UpperCamelCase      :  List[Any]						, __UpperCamelCase      :  Any       )		->     Union[str, Any]:
											A      						=    self.num_labels
											A      						=    TFConvBertForTokenClassification(config=__UpperCamelCase       )
											A      						=    {
											    'input_ids': input_ids,
											    'attention_mask': input_mask,
											    'token_type_ids': token_type_ids,
											}
											A      						=    model(__UpperCamelCase       )
											self.parent.assertEqual(result.logits.shape						, (self.batch_size, self.seq_length, self.num_labels)       )


				def __UpperCamelCase						(							self      :  Optional[int]						, __UpperCamelCase      :  List[Any]						, __UpperCamelCase      :  Optional[int]						, __UpperCamelCase      :  Optional[Any]						, __UpperCamelCase      :  Dict						, __UpperCamelCase      :  Dict						, __UpperCamelCase      :  Any						, __UpperCamelCase      :  Tuple       )		->     Dict:
											A      						=    TFConvBertForQuestionAnswering(config=__UpperCamelCase       )
											A      						=    {
											    'input_ids': input_ids,
											    'attention_mask': input_mask,
											    'token_type_ids': token_type_ids,
											}

											A      						=    model(__UpperCamelCase       )
											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 __UpperCamelCase						(							self      :  Tuple       )		->     int:
											A      						=    self.prepare_config_and_inputs()
											(
											    (
											    A
											)						,   (
											    A
											)						,   (
											    A
											)						,   (
											    A
											)						,   (
											    A
											)						,   (
											    A
											)						,   (
											    A
											)						,   
											)      						=    config_and_inputs
											A      						=    {'input_ids': input_ids, 'token_type_ids': token_type_ids, 'attention_mask': input_mask}
											return config, inputs_dict





@require_tf
class        lowerCAmelCase__					(  _lowerCamelCase ,				_lowerCamelCase ,				unittest.TestCase       ):
				A_   :     int								=     (
				    (
				        TFConvBertModel,
				        TFConvBertForMaskedLM,
				        TFConvBertForQuestionAnswering,
				        TFConvBertForSequenceClassification,
				        TFConvBertForTokenClassification,
				        TFConvBertForMultipleChoice,
				    )
				    if is_tf_available()
				    else ()
				)
				A_   :     Union[str, Any]								=     (
				    {
				        'feature-extraction': TFConvBertModel,
				        'fill-mask': TFConvBertForMaskedLM,
				        'question-answering': TFConvBertForQuestionAnswering,
				        'text-classification': TFConvBertForSequenceClassification,
				        'token-classification': TFConvBertForTokenClassification,
				        'zero-shot': TFConvBertForSequenceClassification,
				    }
				    if is_tf_available()
				    else {}
				)
				A_   :     Tuple								=     False
				A_   :     Optional[int]								=     False
				A_   :     List[str]								=     False


				def __UpperCamelCase						(							self      :  Optional[Any]       )		->     Optional[Any]:
											A      						=    TFConvBertModelTester(self       )
											A      						=    ConfigTester(self						, config_class=__UpperCamelCase						, hidden_size=37       )


				def __UpperCamelCase						(							self      :  int       )		->     List[Any]:
											self.config_tester.run_common_tests()


				def __UpperCamelCase						(							self      :  Any       )		->     Optional[Any]:
											A      						=    self.model_tester.prepare_config_and_inputs()
											self.model_tester.create_and_check_model(*__UpperCamelCase       )


				def __UpperCamelCase						(							self      :  int       )		->     int:
											A      						=    self.model_tester.prepare_config_and_inputs()
											self.model_tester.create_and_check_for_masked_lm(*__UpperCamelCase       )


				def __UpperCamelCase						(							self      :  Optional[Any]       )		->     int:
											A      						=    self.model_tester.prepare_config_and_inputs()
											self.model_tester.create_and_check_for_multiple_choice(*__UpperCamelCase       )


				def __UpperCamelCase						(							self      :  Dict       )		->     Dict:
											A      						=    self.model_tester.prepare_config_and_inputs()
											self.model_tester.create_and_check_for_question_answering(*__UpperCamelCase       )


				def __UpperCamelCase						(							self      :  str       )		->     str:
											A      						=    self.model_tester.prepare_config_and_inputs()
											self.model_tester.create_and_check_for_sequence_classification(*__UpperCamelCase       )


				def __UpperCamelCase						(							self      :  Optional[int]       )		->     Optional[int]:
											A      						=    self.model_tester.prepare_config_and_inputs()
											self.model_tester.create_and_check_for_token_classification(*__UpperCamelCase       )


				@slow
				def __UpperCamelCase						(							self      :  int       )		->     Tuple:
											A						,   A      						=    self.model_tester.prepare_config_and_inputs_for_common()
											A      						=    True
											A      						=    True

											if hasattr(__UpperCamelCase						, 'use_cache'       ):
																		A      						=    True

											A      						=    getattr(self.model_tester						, 'encoder_seq_length'						, self.model_tester.seq_length       )
											A      						=    getattr(self.model_tester						, 'key_length'						, __UpperCamelCase       )

											for model_class in self.all_model_classes:
																		A      						=    self._prepare_for_class(__UpperCamelCase						, __UpperCamelCase       )
																		A      						=    model_class(__UpperCamelCase       )
																		A      						=    len(model(__UpperCamelCase       )       )

																		with tempfile.TemporaryDirectory() as tmpdirname:
																									model.save_pretrained(__UpperCamelCase						, saved_model=__UpperCamelCase       )
																									A      						=    os.path.join(__UpperCamelCase						, 'saved_model'						, '1'       )
																									A      						=    tf.keras.models.load_model(__UpperCamelCase       )
																									A      						=    model(__UpperCamelCase       )

																									if self.is_encoder_decoder:
																																A      						=    outputs['encoder_hidden_states']
																																A      						=    outputs['encoder_attentions']
																									else:
																																A      						=    outputs['hidden_states']
																																A      						=    outputs['attentions']

																									self.assertEqual(len(__UpperCamelCase       )						, __UpperCamelCase       )

																									A      						=    getattr(
																									    self.model_tester						, 'expected_num_hidden_layers'						, self.model_tester.num_hidden_layers + 1       )

																									self.assertEqual(len(__UpperCamelCase       )						, __UpperCamelCase       )
																									self.assertListEqual(
																									    list(output_hidden_states[0].shape[-2:]       )						, [self.model_tester.seq_length, self.model_tester.hidden_size]						, )

																									self.assertEqual(len(__UpperCamelCase       )						, self.model_tester.num_hidden_layers       )
																									self.assertListEqual(
																									    list(output_attentions[0].shape[-3:]       )						, [self.model_tester.num_attention_heads / 2, encoder_seq_length, encoder_key_length]						, )


				@slow
				def __UpperCamelCase						(							self      :  List[str]       )		->     List[Any]:
											A      						=    TFConvBertModel.from_pretrained('YituTech/conv-bert-base'       )
											self.assertIsNotNone(__UpperCamelCase       )


				def __UpperCamelCase						(							self      :  List[Any]       )		->     Dict:
											A						,   A      						=    self.model_tester.prepare_config_and_inputs_for_common()
											A      						=    True
											A      						=    getattr(self.model_tester						, 'decoder_seq_length'						, self.model_tester.seq_length       )
											A      						=    getattr(self.model_tester						, 'encoder_seq_length'						, self.model_tester.seq_length       )
											A      						=    getattr(self.model_tester						, 'key_length'						, __UpperCamelCase       )
											A      						=    getattr(self.model_tester						, 'key_length'						, __UpperCamelCase       )

											def check_decoder_attentions_output(__UpperCamelCase      :  Optional[int]       ):
																		A      						=    len(__UpperCamelCase       )
																		self.assertEqual(out_len % 2						, 0       )
																		A      						=    outputs.decoder_attentions
																		self.assertEqual(len(__UpperCamelCase       )						, self.model_tester.num_hidden_layers       )
																		self.assertListEqual(
																		    list(decoder_attentions[0].shape[-3:]       )						, [self.model_tester.num_attention_heads / 2, decoder_seq_length, decoder_key_length]						, )

											def check_encoder_attentions_output(__UpperCamelCase      :  Optional[Any]       ):
																		A      						=    [
																		    t.numpy() for t in (outputs.encoder_attentions if config.is_encoder_decoder else outputs.attentions)
																		]
																		self.assertEqual(len(__UpperCamelCase       )						, self.model_tester.num_hidden_layers       )
																		self.assertListEqual(
																		    list(attentions[0].shape[-3:]       )						, [self.model_tester.num_attention_heads / 2, encoder_seq_length, encoder_key_length]						, )

											for model_class in self.all_model_classes:
																		A      						=    True
																		A      						=    False
																		A      						=    model_class(__UpperCamelCase       )
																		A      						=    model(self._prepare_for_class(__UpperCamelCase						, __UpperCamelCase       )       )
																		A      						=    len(__UpperCamelCase       )
																		self.assertEqual(config.output_hidden_states						, __UpperCamelCase       )
																		check_encoder_attentions_output(__UpperCamelCase       )

																		if self.is_encoder_decoder:
																									A      						=    model_class(__UpperCamelCase       )
																									A      						=    model(self._prepare_for_class(__UpperCamelCase						, __UpperCamelCase       )       )
																									self.assertEqual(config.output_hidden_states						, __UpperCamelCase       )
																									check_decoder_attentions_output(__UpperCamelCase       )

																		# Check that output attentions can also be changed via the config
																		del inputs_dict["output_attentions"]
																		A      						=    True
																		A      						=    model_class(__UpperCamelCase       )
																		A      						=    model(self._prepare_for_class(__UpperCamelCase						, __UpperCamelCase       )       )
																		self.assertEqual(config.output_hidden_states						, __UpperCamelCase       )
																		check_encoder_attentions_output(__UpperCamelCase       )

																		# Check attention is always last and order is fine
																		A      						=    True
																		A      						=    True
																		A      						=    model_class(__UpperCamelCase       )
																		A      						=    model(self._prepare_for_class(__UpperCamelCase						, __UpperCamelCase       )       )

																		self.assertEqual(out_len + (2 if self.is_encoder_decoder else 1)						, len(__UpperCamelCase       )       )
																		self.assertEqual(model.config.output_hidden_states						, __UpperCamelCase       )
																		check_encoder_attentions_output(__UpperCamelCase       )





@require_tf
class        lowerCAmelCase__					(  unittest.TestCase       ):


				@slow
				def __UpperCamelCase						(							self      :  Tuple       )		->     Optional[Any]:
											A      						=    TFConvBertModel.from_pretrained('YituTech/conv-bert-base'       )
											A      						=    tf.constant([[0, 1, 2, 3, 4, 5]]       )
											A      						=    model(__UpperCamelCase       )[0]

											A      						=    [1, 6, 768]
											self.assertEqual(output.shape						, __UpperCamelCase       )

											A      						=    tf.constant(
											    [
											        [
											            [-0.0_3_4_7_5_4_9_3, -0.4_6_8_6_0_3_4, -0.3_0_6_3_8_8_3_2],
											            [0.2_2_6_3_7_2_4_8, -0.2_6_9_8_8_6_4_6, -0.7_4_2_3_4_2_4],
											            [0.1_0_3_2_4_8_6_8, -0.4_5_0_1_3_5_0_8, -0.5_8_2_8_0_7_8_4],
											        ]
											    ]       )
											tf.debugging.assert_near(output[:, :3, :3]						, __UpperCamelCase						, 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 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


A						=			logging.get_logger(__name__)





class     lowerCAmelCase__     (				SCREAMING_SNAKE_CASE_			):


		'''simple docstring'''






		lowerCAmelCase_     =   ['pixel_values']
		def __init__(       self     :     List[str]     ,  snake_case__     :     bool = True     ,  snake_case__     :     Dict[str, int] = None     ,  snake_case__     :     PILImageResampling = PILImageResampling.BICUBIC     ,  snake_case__     :     bool = True     ,  snake_case__     :     Union[int, float] = 1 / 2_5_5     ,  snake_case__     :     bool = True     ,  snake_case__     :     Optional[Union[float, List[float]]] = None     ,  snake_case__     :     Optional[Union[float, List[float]]] = None     ,  snake_case__     :     bool = True     ,  **snake_case__     :     List[Any]     ,  )      ->	None:
				super().__init__(**snake_case__		)
				_lowerCamelCase				   =  size if size is not None else {'height': 3_8_4, 'width': 3_8_4}
				_lowerCamelCase				   =  get_size_dict(snake_case__     ,  default_to_square=snake_case__		)

				_lowerCamelCase				   =  do_resize
				_lowerCamelCase				   =  size
				_lowerCamelCase				   =  resample
				_lowerCamelCase				   =  do_rescale
				_lowerCamelCase				   =  rescale_factor
				_lowerCamelCase				   =  do_normalize
				_lowerCamelCase				   =  image_mean if image_mean is not None else OPENAI_CLIP_MEAN
				_lowerCamelCase				   =  image_std if image_std is not None else OPENAI_CLIP_STD
				_lowerCamelCase				   =  do_convert_rgb
		def   _snake_case       (       self     :     Union[str, Any]     ,  snake_case__     :     np.ndarray     ,  snake_case__     :     Dict[str, int]     ,  snake_case__     :     PILImageResampling = PILImageResampling.BICUBIC     ,  snake_case__     :     Optional[Union[str, ChannelDimension]] = None     ,  **snake_case__     :     Dict     ,  )      ->	np.ndarray:
				_lowerCamelCase				   =  get_size_dict(snake_case__     ,  default_to_square=snake_case__		)
				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()}"""		)
				_lowerCamelCase				   =  (size['height'], size['width'])
				return resize(snake_case__     ,  size=snake_case__     ,  resample=snake_case__     ,  data_format=snake_case__     ,  **snake_case__		)
		def   _snake_case       (       self     :     Dict     ,  snake_case__     :     np.ndarray     ,  snake_case__     :     Union[int, float]     ,  snake_case__     :     Optional[Union[str, ChannelDimension]] = None     ,  **snake_case__     :     Optional[int]     ,  )      ->	int:
				return rescale(snake_case__     ,  scale=snake_case__     ,  data_format=snake_case__     ,  **snake_case__		)
		def   _snake_case       (       self     :     Optional[Any]     ,  snake_case__     :     np.ndarray     ,  snake_case__     :     Union[float, List[float]]     ,  snake_case__     :     Union[float, List[float]]     ,  snake_case__     :     Optional[Union[str, ChannelDimension]] = None     ,  **snake_case__     :     Optional[int]     ,  )      ->	np.ndarray:
				return normalize(snake_case__     ,  mean=snake_case__     ,  std=snake_case__     ,  data_format=snake_case__     ,  **snake_case__		)



		def   _snake_case       (       self     :     List[str]     ,  snake_case__     :     ImageInput     ,  snake_case__     :     Optional[bool] = None     ,  snake_case__     :     Optional[Dict[str, int]] = None     ,  snake_case__     :     PILImageResampling = None     ,  snake_case__     :     Optional[bool] = None     ,  snake_case__     :     Optional[float] = None     ,  snake_case__     :     Optional[bool] = None     ,  snake_case__     :     Optional[Union[float, List[float]]] = None     ,  snake_case__     :     Optional[Union[float, List[float]]] = None     ,  snake_case__     :     Optional[Union[str, TensorType]] = None     ,  snake_case__     :     bool = None     ,  snake_case__     :     ChannelDimension = ChannelDimension.FIRST     ,  **snake_case__     :     str     ,  )      ->	PIL.Image.Image:
				_lowerCamelCase				   =  do_resize if do_resize is not None else self.do_resize
				_lowerCamelCase				   =  resample if resample is not None else self.resample
				_lowerCamelCase				   =  do_rescale if do_rescale is not None else self.do_rescale
				_lowerCamelCase				   =  rescale_factor if rescale_factor is not None else self.rescale_factor
				_lowerCamelCase				   =  do_normalize if do_normalize is not None else self.do_normalize
				_lowerCamelCase				   =  image_mean if image_mean is not None else self.image_mean
				_lowerCamelCase				   =  image_std if image_std is not None else self.image_std
				_lowerCamelCase				   =  do_convert_rgb if do_convert_rgb is not None else self.do_convert_rgb

				_lowerCamelCase				   =  size if size is not None else self.size
				_lowerCamelCase				   =  get_size_dict(snake_case__     ,  default_to_square=snake_case__		)

				_lowerCamelCase				   =  make_list_of_images(snake_case__		)

				if not valid_images(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 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:
						_lowerCamelCase				   =  [convert_to_rgb(snake_case__		) for image in images]

				# All transformations expect numpy arrays.
				_lowerCamelCase				   =  [to_numpy_array(snake_case__		) for image in images]

				if do_resize:
						_lowerCamelCase				   =  [self.resize(image=snake_case__     ,  size=snake_case__     ,  resample=snake_case__		) for image in images]

				if do_rescale:
						_lowerCamelCase				   =  [self.rescale(image=snake_case__     ,  scale=snake_case__		) for image in images]

				if do_normalize:
						_lowerCamelCase				   =  [self.normalize(image=snake_case__     ,  mean=snake_case__     ,  std=snake_case__		) for image in images]

				_lowerCamelCase				   =  [to_channel_dimension_format(snake_case__     ,  snake_case__		) for image in images]

				_lowerCamelCase				   =  BatchFeature(data={'pixel_values': images}     ,  tensor_type=snake_case__		)

				return encoded_outputs