from __future__ import annotations

import unittest

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

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


if is_tf_available():
				import numpy
				import tensorflow as tf

				from transformers.models.esm.modeling_tf_esm import (
				    TF_ESM_PRETRAINED_MODEL_ARCHIVE_LIST,
				    TFEsmForMaskedLM,
				    TFEsmForSequenceClassification,
				    TFEsmForTokenClassification,
				    TFEsmModel,
				)




class 	__snake_case	:





						'''simple docstring'''






						def __init__(					self     :				int    ,  _UpperCamelCase     :				Any    ,  )				->Any:


										"""simple docstring"""


										_lowerCamelCase     :		List[str] 						=						parent
										_lowerCamelCase     :		Dict 						=						13
										_lowerCamelCase     :		Tuple 						=						7
										_lowerCamelCase     :		Any 						=						True
										_lowerCamelCase     :		Tuple 						=						True
										_lowerCamelCase     :		Tuple 						=						True
										_lowerCamelCase     :		Dict 						=						99
										_lowerCamelCase     :		List[str] 						=						32
										_lowerCamelCase     :		int 						=						2
										_lowerCamelCase     :		Optional[Any] 						=						4
										_lowerCamelCase     :		Tuple 						=						37
										_lowerCamelCase     :		Optional[int] 						=						"""gelu"""
										_lowerCamelCase     :		Union[str, Any] 						=						0.1
										_lowerCamelCase     :		Tuple 						=						0.1
										_lowerCamelCase     :		Union[str, Any] 						=						512
										_lowerCamelCase     :		Any 						=						16
										_lowerCamelCase     :		List[Any] 						=						2
										_lowerCamelCase     :		Any 						=						0.0_2
										_lowerCamelCase     :		List[str] 						=						3
										_lowerCamelCase     :		int 						=						4
										_lowerCamelCase     :		Optional[int] 						=						None



						def 	_SCREAMING_SNAKE_CASE    (					self     :				List[Any])				->List[Any]:


										"""simple docstring"""


										_lowerCamelCase     :		int 						=						ids_tensor([self.batch_size, self.seq_length]    ,  self.vocab_size)

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

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

										_lowerCamelCase     :		Dict 						=						EsmConfig(
										    vocab_size=self.vocab_size    ,  hidden_size=self.hidden_size    ,  num_hidden_layers=self.num_hidden_layers    ,  pad_token_id=1    ,  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 config, input_ids, input_mask, sequence_labels, token_labels, choice_labels



						def 	_SCREAMING_SNAKE_CASE    (					self     :				List[Any])				->Optional[int]:


										"""simple docstring"""


										(
										    (
										    _lowerCamelCase      
										)						,							(
										    _lowerCamelCase      
										)						,							(
										    _lowerCamelCase      
										)						,							(
										    _lowerCamelCase      
										)						,							(
										    _lowerCamelCase      
										)						,							(
										    _lowerCamelCase      
										)						,							      
										)     :		int 						=						self.prepare_config_and_inputs()

										_lowerCamelCase     :		Tuple 						=						True
										_lowerCamelCase     :		str 						=						floats_tensor([self.batch_size, self.seq_length, self.hidden_size])
										_lowerCamelCase     :		List[str] 						=						ids_tensor([self.batch_size, self.seq_length]    ,  vocab_size=2)

										return (
										    config,
										    input_ids,
										    input_mask,
										    sequence_labels,
										    token_labels,
										    choice_labels,
										    encoder_hidden_states,
										    encoder_attention_mask,
										)



						def 	_SCREAMING_SNAKE_CASE    (					self     :				int    ,  _UpperCamelCase     :				int    ,  _UpperCamelCase     :				Optional[Any]    ,  _UpperCamelCase     :				int    ,  _UpperCamelCase     :				Any    ,  _UpperCamelCase     :				Union[str, Any]    ,  _UpperCamelCase     :				List[str])				->str:


										"""simple docstring"""


										_lowerCamelCase     :		Optional[int] 						=						TFEsmModel(config=lowerCamelCase_)
										_lowerCamelCase     :		Union[str, Any] 						=						{"""input_ids""": input_ids, """attention_mask""": input_mask}
										_lowerCamelCase     :		List[str] 						=						model(lowerCamelCase_)

										_lowerCamelCase     :		str 						=						[input_ids, input_mask]
										_lowerCamelCase     :		str 						=						model(lowerCamelCase_)

										_lowerCamelCase     :		Tuple 						=						model(lowerCamelCase_)

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



						def 	_SCREAMING_SNAKE_CASE    (					self     :				str    ,  _UpperCamelCase     :				str    ,  _UpperCamelCase     :				List[Any]    ,  _UpperCamelCase     :				int    ,  _UpperCamelCase     :				str    ,  _UpperCamelCase     :				Optional[Any]    ,  _UpperCamelCase     :				List[Any]    ,  _UpperCamelCase     :				str    ,  _UpperCamelCase     :				Dict    ,  )				->Tuple:


										"""simple docstring"""


										_lowerCamelCase     :		str 						=						True

										_lowerCamelCase     :		Any 						=						TFEsmModel(config=lowerCamelCase_)
										_lowerCamelCase     :		str 						=						{
										    """input_ids""": input_ids,
										    """attention_mask""": input_mask,
										    """encoder_hidden_states""": encoder_hidden_states,
										    """encoder_attention_mask""": encoder_attention_mask,
										}
										_lowerCamelCase     :		List[str] 						=						model(lowerCamelCase_)

										_lowerCamelCase     :		Dict 						=						[input_ids, input_mask]
										_lowerCamelCase     :		Tuple 						=						model(lowerCamelCase_    ,  encoder_hidden_states=lowerCamelCase_)

										# Also check the case where encoder outputs are not passed
										_lowerCamelCase     :		str 						=						model(lowerCamelCase_    ,  attention_mask=lowerCamelCase_)

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



						def 	_SCREAMING_SNAKE_CASE    (					self     :				Dict    ,  _UpperCamelCase     :				List[Any]    ,  _UpperCamelCase     :				str    ,  _UpperCamelCase     :				List[str]    ,  _UpperCamelCase     :				List[Any]    ,  _UpperCamelCase     :				int    ,  _UpperCamelCase     :				Tuple)				->Dict:


										"""simple docstring"""


										_lowerCamelCase     :		Any 						=						TFEsmForMaskedLM(config=lowerCamelCase_)
										_lowerCamelCase     :		int 						=						model([input_ids, input_mask])
										self.parent.assertEqual(result.logits.shape    ,  (self.batch_size, self.seq_length, self.vocab_size))



						def 	_SCREAMING_SNAKE_CASE    (					self     :				Union[str, Any]    ,  _UpperCamelCase     :				Dict    ,  _UpperCamelCase     :				Optional[int]    ,  _UpperCamelCase     :				List[str]    ,  _UpperCamelCase     :				Tuple    ,  _UpperCamelCase     :				Optional[Any]    ,  _UpperCamelCase     :				int)				->str:


										"""simple docstring"""


										_lowerCamelCase     :		Optional[int] 						=						self.num_labels
										_lowerCamelCase     :		Union[str, Any] 						=						TFEsmForTokenClassification(config=lowerCamelCase_)
										_lowerCamelCase     :		int 						=						{"""input_ids""": input_ids, """attention_mask""": input_mask}
										_lowerCamelCase     :		str 						=						model(lowerCamelCase_)
										self.parent.assertEqual(result.logits.shape    ,  (self.batch_size, self.seq_length, self.num_labels))




						def 	_SCREAMING_SNAKE_CASE    (					self     :				Optional[Any])				->List[Any]:


										"""simple docstring"""


										_lowerCamelCase     :		Dict 						=						self.prepare_config_and_inputs()
										(
										    (
										    _lowerCamelCase      
										)						,							(
										    _lowerCamelCase      
										)						,							(
										    _lowerCamelCase      
										)						,							(
										    _lowerCamelCase      
										)						,							(
										    _lowerCamelCase      
										)						,							(
										    _lowerCamelCase      
										)						,							      
										)     :		int 						=						config_and_inputs
										_lowerCamelCase     :		List[str] 						=						{"""input_ids""": input_ids, """attention_mask""": input_mask}
										return config, inputs_dict





@require_tf
class 	__snake_case	( a__ ,  a__ ,  unittest.TestCase		):





						'''simple docstring'''






						_snake_case    		=       (
						    (
						        TFEsmModel,
						        TFEsmForMaskedLM,
						        TFEsmForSequenceClassification,
						        TFEsmForTokenClassification,
						    )
						    if is_tf_available()
						    else ()
						)
						_snake_case    		=       (
						    {
						        "feature-extraction": TFEsmModel,
						        "fill-mask": TFEsmForMaskedLM,
						        "text-classification": TFEsmForSequenceClassification,
						        "token-classification": TFEsmForTokenClassification,
						        "zero-shot": TFEsmForSequenceClassification,
						    }
						    if is_tf_available()
						    else {}
						)
						_snake_case    		=       False
						_snake_case    		=       False



						def 	_SCREAMING_SNAKE_CASE    (					self     :				Optional[Any])				->Dict:


										"""simple docstring"""


										_lowerCamelCase     :		Optional[Any] 						=						TFEsmModelTester(self)
										_lowerCamelCase     :		Tuple 						=						ConfigTester(self    ,  config_class=lowerCamelCase_    ,  hidden_size=37)



						def 	_SCREAMING_SNAKE_CASE    (					self     :				Union[str, Any])				->Tuple:


										"""simple docstring"""


										self.config_tester.run_common_tests()



						def 	_SCREAMING_SNAKE_CASE    (					self     :				Dict)				->List[Any]:


										"""simple docstring"""


										_lowerCamelCase     :		int 						=						self.model_tester.prepare_config_and_inputs()
										self.model_tester.create_and_check_model(*lowerCamelCase_)



						def 	_SCREAMING_SNAKE_CASE    (					self     :				str)				->List[str]:


										"""simple docstring"""


										_lowerCamelCase     :		List[Any] 						=						self.model_tester.prepare_config_and_inputs_for_decoder()
										self.model_tester.create_and_check_model_as_decoder(*lowerCamelCase_)



						def 	_SCREAMING_SNAKE_CASE    (					self     :				Any)				->Tuple:


										"""simple docstring"""


										_lowerCamelCase     :		int 						=						self.model_tester.prepare_config_and_inputs()
										self.model_tester.create_and_check_for_masked_lm(*lowerCamelCase_)



						def 	_SCREAMING_SNAKE_CASE    (					self     :				Optional[Any])				->Dict:


										"""simple docstring"""


										_lowerCamelCase     :		Union[str, Any] 						=						self.model_tester.prepare_config_and_inputs()
										self.model_tester.create_and_check_for_token_classification(*lowerCamelCase_)



						@slow
						def 	_SCREAMING_SNAKE_CASE    (					self     :				Dict)				->List[str]:


										"""simple docstring"""


										for model_name in TF_ESM_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
														_lowerCamelCase     :		Tuple 						=						TFEsmModel.from_pretrained(lowerCamelCase_)
														self.assertIsNotNone(lowerCamelCase_)



						@unittest.skip("""Protein models do not support embedding resizing.""")
						def 	_SCREAMING_SNAKE_CASE    (					self     :				Tuple)				->int:


										"""simple docstring"""


										pass



						@unittest.skip("""Protein models do not support embedding resizing.""")
						def 	_SCREAMING_SNAKE_CASE    (					self     :				str)				->Tuple:


										"""simple docstring"""


										pass




						def 	_SCREAMING_SNAKE_CASE    (					self     :				Optional[int])				->List[str]:


										"""simple docstring"""


										_lowerCamelCase						,							_lowerCamelCase     :		List[str] 						=						self.model_tester.prepare_config_and_inputs_for_common()

										for model_class in self.all_model_classes:
														_lowerCamelCase     :		List[str] 						=						model_class(lowerCamelCase_)
														assert isinstance(model.get_input_embeddings()    ,  tf.keras.layers.Layer)
														if model_class is TFEsmForMaskedLM:
																		# Output embedding test differs from the main test because they're a matrix, not a layer
																		_lowerCamelCase     :		Optional[Any] 						=						model.get_bias()
																		assert isinstance(lowerCamelCase_    ,  lowerCamelCase_)
																		for k, v in name.items():
																						assert isinstance(lowerCamelCase_    ,  tf.Variable)
														else:
																		_lowerCamelCase     :		int 						=						model.get_output_embeddings()
																		assert x is None
																		_lowerCamelCase     :		str 						=						model.get_bias()
																		assert name is None





@require_tf
class 	__snake_case	( unittest.TestCase		):





						'''simple docstring'''






						@slow
						def 	_SCREAMING_SNAKE_CASE    (					self     :				Optional[Any])				->Dict:


										"""simple docstring"""


										_lowerCamelCase     :		List[Any] 						=						TFEsmForMaskedLM.from_pretrained("""facebook/esm2_t6_8M_UR50D""")

										_lowerCamelCase     :		str 						=						tf.constant([[0, 1, 2, 3, 4, 5]])
										_lowerCamelCase     :		Dict 						=						model(lowerCamelCase_)[0]
										_lowerCamelCase     :		Dict 						=						[1, 6, 33]
										self.assertEqual(list(output.numpy().shape)    ,  lowerCamelCase_)
										# compare the actual values for a slice.
										_lowerCamelCase     :		Optional[Any] 						=						tf.constant(
										    [
										        [
										            [8.9_2_1_5_1_8, -1_0.5_8_9_8_1_4, -6.4_6_7_1_3_0_7],
										            [-6.3_9_6_7_1_5_6, -1_3.9_1_1_3_7_7, -1.1_2_1_1_9_1_5],
										            [-7.7_8_1_2_4_7, -1_3.9_5_1_5_5_7, -3.7_4_0_5_9_2],
										        ]
										    ])
										self.assertTrue(numpy.allclose(output[:, :3, :3].numpy()    ,  expected_slice.numpy()    ,  atol=1E-2))




						@slow
						def 	_SCREAMING_SNAKE_CASE    (					self     :				Tuple)				->Tuple:


										"""simple docstring"""


										_lowerCamelCase     :		Tuple 						=						TFEsmModel.from_pretrained("""facebook/esm2_t6_8M_UR50D""")

										_lowerCamelCase     :		int 						=						tf.constant([[0, 6, 4, 13, 5, 4, 16, 12, 11, 7, 2]])
										_lowerCamelCase     :		Union[str, Any] 						=						model(lowerCamelCase_)[0]
										# compare the actual values for a slice.
										_lowerCamelCase     :		int 						=						tf.constant(
										    [
										        [
										            [0.1_4_4_4_3_0_9_2, 0.5_4_1_2_5_3_2_7, 0.3_2_4_7_7_3_9],
										            [0.3_0_3_4_0_4_8_4, 0.0_0_5_2_6_6_7_6, 0.3_1_0_7_7_7_2_2],
										            [0.3_2_2_7_8_0_4_3, -0.2_4_9_8_7_0_9_6, 0.3_4_1_4_6_2_8],
										        ]
										    ])
										self.assertTrue(numpy.allclose(output[:, :3, :3].numpy()    ,  expected_slice.numpy()    ,  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, normalize, rescale, resize, to_channel_dimension_format
from ...image_utils import (
    IMAGENET_STANDARD_MEAN,
    IMAGENET_STANDARD_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


lowerCAmelCase			:							Tuple     =logging.get_logger(__name__)




class 	__snake_case	( __lowerCAmelCase		):





      '''simple docstring'''






      _snake_case    		=       ['pixel_values']



      def __init__(					self     :				Optional[Any]    ,  _UpperCamelCase     :				bool = True    ,  _UpperCamelCase     :				Dict[str, int] = None    ,  _UpperCamelCase     :				PILImageResampling = PIL.Image.BICUBIC    ,  _UpperCamelCase     :				bool = True    ,  _UpperCamelCase     :				Dict[str, int] = None    ,  _UpperCamelCase     :				Union[int, float] = 1 / 255    ,  _UpperCamelCase     :				bool = True    ,  _UpperCamelCase     :				bool = True    ,  _UpperCamelCase     :				Optional[Union[float, List[float]]] = None    ,  _UpperCamelCase     :				Optional[Union[float, List[float]]] = None    ,  **_UpperCamelCase     :				str    ,  )				->None:


          """simple docstring"""


          super().__init__(**_UpperCamelCase)
          _lowerCamelCase     :		Tuple 						=						size if size is not None else {"""height""": 256, """width""": 256}
          _lowerCamelCase     :		Optional[Any] 						=						get_size_dict(_UpperCamelCase)
          _lowerCamelCase     :		Any 						=						crop_size if crop_size is not None else {"""height""": 224, """width""": 224}
          _lowerCamelCase     :		Any 						=						get_size_dict(_UpperCamelCase    ,  param_name="""crop_size""")

          _lowerCamelCase     :		int 						=						do_resize
          _lowerCamelCase     :		int 						=						size
          _lowerCamelCase     :		Optional[int] 						=						resample
          _lowerCamelCase     :		int 						=						do_center_crop
          _lowerCamelCase     :		Optional[Any] 						=						crop_size
          _lowerCamelCase     :		Union[str, Any] 						=						do_rescale
          _lowerCamelCase     :		List[str] 						=						rescale_factor
          _lowerCamelCase     :		List[Any] 						=						do_normalize
          _lowerCamelCase     :		Dict 						=						image_mean if image_mean is not None else IMAGENET_STANDARD_MEAN
          _lowerCamelCase     :		int 						=						image_std if image_std is not None else IMAGENET_STANDARD_STD



      def 	_SCREAMING_SNAKE_CASE    (					self     :				Any    ,  _UpperCamelCase     :				np.ndarray    ,  _UpperCamelCase     :				Dict[str, int]    ,  _UpperCamelCase     :				PILImageResampling = PIL.Image.BICUBIC    ,  _UpperCamelCase     :				Optional[Union[str, ChannelDimension]] = None    ,  **_UpperCamelCase     :				Union[str, Any]    ,  )				->np.ndarray:


          """simple docstring"""


          _lowerCamelCase     :		Dict 						=						get_size_dict(_UpperCamelCase)
          if "height" not in size or "width" not in size:
              raise ValueError(F"""The size dictionary must have keys 'height' and 'width'. Got {size.keys()}""")
          return resize(
              _UpperCamelCase    ,  size=(size["""height"""], size["""width"""])    ,  resample=_UpperCamelCase    ,  data_format=_UpperCamelCase    ,  **_UpperCamelCase)



      def 	_SCREAMING_SNAKE_CASE    (					self     :				List[str]    ,  _UpperCamelCase     :				np.ndarray    ,  _UpperCamelCase     :				Dict[str, int]    ,  _UpperCamelCase     :				Optional[Union[str, ChannelDimension]] = None    ,  **_UpperCamelCase     :				List[str]    ,  )				->np.ndarray:


          """simple docstring"""


          _lowerCamelCase     :		Union[str, Any] 						=						get_size_dict(_UpperCamelCase)
          if "height" not in size or "width" not in size:
              raise ValueError(F"""The size dictionary must have keys 'height' and 'width'. Got {size.keys()}""")
          return center_crop(_UpperCamelCase    ,  size=(size["""height"""], size["""width"""])    ,  data_format=_UpperCamelCase    ,  **_UpperCamelCase)



      def 	_SCREAMING_SNAKE_CASE    (					self     :				Union[str, Any]    ,  _UpperCamelCase     :				np.ndarray    ,  _UpperCamelCase     :				Union[int, float]    ,  _UpperCamelCase     :				Optional[Union[str, ChannelDimension]] = None    ,  **_UpperCamelCase     :				Union[str, Any]    ,  )				->str:


          """simple docstring"""


          return rescale(_UpperCamelCase    ,  scale=_UpperCamelCase    ,  data_format=_UpperCamelCase    ,  **_UpperCamelCase)



      def 	_SCREAMING_SNAKE_CASE    (					self     :				List[Any]    ,  _UpperCamelCase     :				np.ndarray    ,  _UpperCamelCase     :				Union[float, List[float]]    ,  _UpperCamelCase     :				Union[float, List[float]]    ,  _UpperCamelCase     :				Optional[Union[str, ChannelDimension]] = None    ,  **_UpperCamelCase     :				Union[str, Any]    ,  )				->np.ndarray:


          """simple docstring"""


          return normalize(_UpperCamelCase    ,  mean=_UpperCamelCase    ,  std=_UpperCamelCase    ,  data_format=_UpperCamelCase    ,  **_UpperCamelCase)




      def 	_SCREAMING_SNAKE_CASE    (					self     :				Optional[Any]    ,  _UpperCamelCase     :				ImageInput    ,  _UpperCamelCase     :				bool = None    ,  _UpperCamelCase     :				Dict[str, int] = None    ,  _UpperCamelCase     :				Tuple=None    ,  _UpperCamelCase     :				bool = None    ,  _UpperCamelCase     :				Dict[str, int] = None    ,  _UpperCamelCase     :				bool = None    ,  _UpperCamelCase     :				float = None    ,  _UpperCamelCase     :				bool = None    ,  _UpperCamelCase     :				Optional[Union[float, List[float]]] = None    ,  _UpperCamelCase     :				Optional[Union[float, List[float]]] = None    ,  _UpperCamelCase     :				Optional[Union[str, TensorType]] = None    ,  _UpperCamelCase     :				ChannelDimension = ChannelDimension.FIRST    ,  **_UpperCamelCase     :				List[Any]    ,  )				->PIL.Image.Image:


          """simple docstring"""


          _lowerCamelCase     :		Any 						=						do_resize if do_resize is not None else self.do_resize
          _lowerCamelCase     :		List[str] 						=						resample if resample is not None else self.resample
          _lowerCamelCase     :		Dict 						=						do_center_crop if do_center_crop is not None else self.do_center_crop
          _lowerCamelCase     :		Optional[Any] 						=						do_rescale if do_rescale is not None else self.do_rescale
          _lowerCamelCase     :		Dict 						=						rescale_factor if rescale_factor is not None else self.rescale_factor
          _lowerCamelCase     :		Dict 						=						do_normalize if do_normalize is not None else self.do_normalize
          _lowerCamelCase     :		int 						=						image_mean if image_mean is not None else self.image_mean
          _lowerCamelCase     :		Dict 						=						image_std if image_std is not None else self.image_std

          _lowerCamelCase     :		Optional[Any] 						=						size if size is not None else self.size
          _lowerCamelCase     :		Optional[int] 						=						get_size_dict(_UpperCamelCase)
          _lowerCamelCase     :		List[str] 						=						crop_size if crop_size is not None else self.crop_size
          _lowerCamelCase     :		Dict 						=						get_size_dict(_UpperCamelCase    ,  param_name="""crop_size""")

          _lowerCamelCase     :		int 						=						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_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.""")

          # All transformations expect numpy arrays.
          _lowerCamelCase     :		Union[str, Any] 						=						[to_numpy_array(_UpperCamelCase) for image in images]

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

          if do_center_crop:
              _lowerCamelCase     :		str 						=						[self.center_crop(image=_UpperCamelCase    ,  size=_UpperCamelCase) for image in images]

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

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

          _lowerCamelCase     :		List[str] 						=						[to_channel_dimension_format(_UpperCamelCase    ,  _UpperCamelCase) for image in images]

          _lowerCamelCase     :		int 						=						{"""pixel_values""": images}
          return BatchFeature(data=_UpperCamelCase    ,  tensor_type=_UpperCamelCase)




