

import unittest

from transformers import MraConfig, is_torch_available
from transformers.testing_utils import require_torch, slow, torch_device

from ...test_configuration_common import ConfigTester
from ...test_modeling_common import ModelTesterMixin, floats_tensor, ids_tensor, random_attention_mask


if is_torch_available():
  import torch

  from transformers import (
      MraForMaskedLM,
      MraForMultipleChoice,
      MraForQuestionAnswering,
      MraForSequenceClassification,
      MraForTokenClassification,
      MraModel,
  )
  from transformers.models.mra.modeling_mra import MRA_PRETRAINED_MODEL_ARCHIVE_LIST





class A__    :



 """simple docstring"""







 def __init__(		self :	Any     ,						A_ :	str     ,						A_ :	Dict=2     ,						A_ :	Union[str, Any]=8     ,						A_ :	int=True     ,						A_ :	List[Any]=True     ,						A_ :	List[str]=True     ,						A_ :	Optional[Any]=True     ,						A_ :	Optional[int]=9_9     ,						A_ :	str=1_6     ,						A_ :	Dict=5     ,						A_ :	Tuple=2     ,						A_ :	Any=3_6     ,						A_ :	str="gelu"     ,						A_ :	Tuple=0.0     ,						A_ :	int=0.0     ,						A_ :	Any=5_1_2     ,						A_ :	Union[str, Any]=1_6     ,						A_ :	Tuple=2     ,						A_ :	List[str]=0.02     ,						A_ :	Dict=3     ,						A_ :	Optional[int]=4     ,						A_ :	Union[str, Any]=None     ,						):






      '''simple docstring'''




      _lowerCAmelCase   :					Union[str, Any]        =    parent
      _lowerCAmelCase   :					Optional[Any]        =    batch_size
      _lowerCAmelCase   :					Any        =    seq_length
      _lowerCAmelCase   :					Tuple        =    is_training
      _lowerCAmelCase   :					Union[str, Any]        =    use_input_mask
      _lowerCAmelCase   :					str        =    use_token_type_ids
      _lowerCAmelCase   :					Optional[Any]        =    use_labels
      _lowerCAmelCase   :					Any        =    vocab_size
      _lowerCAmelCase   :					Dict        =    hidden_size
      _lowerCAmelCase   :					Union[str, Any]        =    num_hidden_layers
      _lowerCAmelCase   :					Optional[Any]        =    num_attention_heads
      _lowerCAmelCase   :					List[str]        =    intermediate_size
      _lowerCAmelCase   :					List[Any]        =    hidden_act
      _lowerCAmelCase   :					Optional[Any]        =    hidden_dropout_prob
      _lowerCAmelCase   :					Optional[Any]        =    attention_probs_dropout_prob
      _lowerCAmelCase   :					Optional[Any]        =    max_position_embeddings
      _lowerCAmelCase   :					int        =    type_vocab_size
      _lowerCAmelCase   :					Union[str, Any]        =    type_sequence_label_size
      _lowerCAmelCase   :					List[Any]        =    initializer_range
      _lowerCAmelCase   :					List[str]        =    num_labels
      _lowerCAmelCase   :					List[Any]        =    num_choices
      _lowerCAmelCase   :					List[str]        =    scope

 def    __magic_name__       (		self :	Dict       ):






      '''simple docstring'''




      _lowerCAmelCase   :					List[Any]        =    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   :					Any        =    None
      if self.use_token_type_ids:
           _lowerCAmelCase   :					List[Any]        =    ids_tensor([self.batch_size, self.seq_length]     ,						self.type_vocab_size       )

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

      _lowerCAmelCase   :					int        =    self.get_config()

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

 def    __magic_name__       (		self :	Optional[Any]       ):






      '''simple docstring'''




      return MraConfig(
          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     ,						is_decoder=A_     ,						initializer_range=self.initializer_range     ,						)

 def    __magic_name__       (		self :	str       ):






      '''simple docstring'''




      _lowerCAmelCase   :					List[str]        =    self.get_config()
      _lowerCAmelCase   :					str        =    3_0_0
      return config

 def    __magic_name__       (		self :	int       ):






      '''simple docstring'''




      (
          _lowerCAmelCase			
      )   :					int        =    self.prepare_config_and_inputs()

      _lowerCAmelCase   :					List[str]        =    True
      _lowerCAmelCase   :					Union[str, Any]        =    floats_tensor([self.batch_size, self.seq_length, self.hidden_size]       )
      _lowerCAmelCase   :					str        =    ids_tensor([self.batch_size, self.seq_length]     ,						vocab_size=2       )

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

 def    __magic_name__       (		self :	Dict     ,						A_ :	str     ,						A_ :	Union[str, Any]     ,						A_ :	Union[str, Any]     ,						A_ :	Tuple     ,						A_ :	List[str]     ,						A_ :	Any     ,						A_ :	Optional[Any]       ):






      '''simple docstring'''




      _lowerCAmelCase   :					int        =    MraModel(config=A_       )
      model.to(A_       )
      model.eval()
      _lowerCAmelCase   :					List[str]        =    model(A_     ,						attention_mask=A_     ,						token_type_ids=A_       )
      _lowerCAmelCase   :					List[Any]        =    model(A_     ,						token_type_ids=A_       )
      _lowerCAmelCase   :					Any        =    model(A_       )
      self.parent.assertEqual(result.last_hidden_state.shape     ,						(self.batch_size, self.seq_length, self.hidden_size)       )

 def    __magic_name__       (		self :	int     ,						A_ :	Tuple     ,						A_ :	Any     ,						A_ :	Optional[Any]     ,						A_ :	List[Any]     ,						A_ :	Union[str, Any]     ,						A_ :	Dict     ,						A_ :	Optional[Any]     ,						A_ :	str     ,						A_ :	Optional[Any]     ,						):






      '''simple docstring'''




      _lowerCAmelCase   :					Optional[Any]        =    True
      _lowerCAmelCase   :					Optional[Any]        =    MraModel(A_       )
      model.to(A_       )
      model.eval()
      _lowerCAmelCase   :					Optional[int]        =    model(
          A_     ,						attention_mask=A_     ,						token_type_ids=A_     ,						encoder_hidden_states=A_     ,						encoder_attention_mask=A_     ,						)
      _lowerCAmelCase   :					Tuple        =    model(
          A_     ,						attention_mask=A_     ,						token_type_ids=A_     ,						encoder_hidden_states=A_     ,						)
      _lowerCAmelCase   :					Any        =    model(A_     ,						attention_mask=A_     ,						token_type_ids=A_       )
      self.parent.assertEqual(result.last_hidden_state.shape     ,						(self.batch_size, self.seq_length, self.hidden_size)       )

 def    __magic_name__       (		self :	Union[str, Any]     ,						A_ :	Optional[int]     ,						A_ :	str     ,						A_ :	Tuple     ,						A_ :	str     ,						A_ :	List[str]     ,						A_ :	Any     ,						A_ :	int       ):






      '''simple docstring'''




      _lowerCAmelCase   :					Union[str, Any]        =    MraForMaskedLM(config=A_       )
      model.to(A_       )
      model.eval()
      _lowerCAmelCase   :					Tuple        =    model(A_     ,						attention_mask=A_     ,						token_type_ids=A_     ,						labels=A_       )
      self.parent.assertEqual(result.logits.shape     ,						(self.batch_size, self.seq_length, self.vocab_size)       )

 def    __magic_name__       (		self :	str     ,						A_ :	Optional[int]     ,						A_ :	Union[str, Any]     ,						A_ :	List[str]     ,						A_ :	Any     ,						A_ :	Optional[Any]     ,						A_ :	List[Any]     ,						A_ :	Any       ):






      '''simple docstring'''




      _lowerCAmelCase   :					Union[str, Any]        =    MraForQuestionAnswering(config=A_       )
      model.to(A_       )
      model.eval()
      _lowerCAmelCase   :					List[str]        =    model(
          A_     ,						attention_mask=A_     ,						token_type_ids=A_     ,						start_positions=A_     ,						end_positions=A_     ,						)
      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    __magic_name__       (		self :	List[str]     ,						A_ :	Optional[Any]     ,						A_ :	Tuple     ,						A_ :	Tuple     ,						A_ :	str     ,						A_ :	Any     ,						A_ :	Union[str, Any]     ,						A_ :	Any       ):






      '''simple docstring'''




      _lowerCAmelCase   :					Optional[Any]        =    self.num_labels
      _lowerCAmelCase   :					str        =    MraForSequenceClassification(A_       )
      model.to(A_       )
      model.eval()
      _lowerCAmelCase   :					Any        =    model(A_     ,						attention_mask=A_     ,						token_type_ids=A_     ,						labels=A_       )
      self.parent.assertEqual(result.logits.shape     ,						(self.batch_size, self.num_labels)       )

 def    __magic_name__       (		self :	Optional[int]     ,						A_ :	List[str]     ,						A_ :	Optional[int]     ,						A_ :	List[Any]     ,						A_ :	Any     ,						A_ :	Any     ,						A_ :	str     ,						A_ :	Any       ):






      '''simple docstring'''




      _lowerCAmelCase   :					str        =    self.num_labels
      _lowerCAmelCase   :					Union[str, Any]        =    MraForTokenClassification(config=A_       )
      model.to(A_       )
      model.eval()
      _lowerCAmelCase   :					Any        =    model(A_     ,						attention_mask=A_     ,						token_type_ids=A_     ,						labels=A_       )
      self.parent.assertEqual(result.logits.shape     ,						(self.batch_size, self.seq_length, self.num_labels)       )

 def    __magic_name__       (		self :	str     ,						A_ :	Any     ,						A_ :	List[str]     ,						A_ :	Optional[Any]     ,						A_ :	Dict     ,						A_ :	Tuple     ,						A_ :	int     ,						A_ :	Tuple       ):






      '''simple docstring'''




      _lowerCAmelCase   :					Optional[Any]        =    self.num_choices
      _lowerCAmelCase   :					Optional[int]        =    MraForMultipleChoice(config=A_       )
      model.to(A_       )
      model.eval()
      _lowerCAmelCase   :					Optional[int]        =    input_ids.unsqueeze(1       ).expand(-1     ,						self.num_choices     ,						-1       ).contiguous()
      _lowerCAmelCase   :					Any        =    token_type_ids.unsqueeze(1       ).expand(-1     ,						self.num_choices     ,						-1       ).contiguous()
      _lowerCAmelCase   :					Dict        =    input_mask.unsqueeze(1       ).expand(-1     ,						self.num_choices     ,						-1       ).contiguous()
      _lowerCAmelCase   :					Optional[int]        =    model(
          A_     ,						attention_mask=A_     ,						token_type_ids=A_     ,						labels=A_     ,						)
      self.parent.assertEqual(result.logits.shape     ,						(self.batch_size, self.num_choices)       )


 def    __magic_name__       (		self :	List[str]       ):






      '''simple docstring'''




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





@require_torch
class A__    ( A  ,		unittest.TestCase ):



 """simple docstring"""







 _lowercase     :					int      =						(
     (
         MraModel,
         MraForMaskedLM,
         MraForMultipleChoice,
         MraForQuestionAnswering,
         MraForSequenceClassification,
         MraForTokenClassification,
     )
     if is_torch_available()
     else ()
 )
 _lowercase     :					Optional[Any]      =						False
 _lowercase     :					Optional[int]      =						False
 _lowercase     :					Tuple      =						False
 _lowercase     :					Optional[int]      =						False

 _lowercase     :					Any      =						()

 def    __magic_name__       (		self :	Any       ):






      '''simple docstring'''




      _lowerCAmelCase   :					Union[str, Any]        =    MraModelTester(self       )
      _lowerCAmelCase   :					Union[str, Any]        =    ConfigTester(self     ,						config_class=A_     ,						hidden_size=3_7       )

 def    __magic_name__       (		self :	Any       ):






      '''simple docstring'''




      self.config_tester.run_common_tests()

 def    __magic_name__       (		self :	List[Any]       ):






      '''simple docstring'''




      _lowerCAmelCase   :					Optional[int]        =    self.model_tester.prepare_config_and_inputs()
      self.model_tester.create_and_check_model(*A_       )

 def    __magic_name__       (		self :	Union[str, Any]       ):






      '''simple docstring'''




      _lowerCAmelCase   :					Optional[int]        =    self.model_tester.prepare_config_and_inputs()
      for type in ["absolute", "relative_key", "relative_key_query"]:
           _lowerCAmelCase   :					str        =    type
           self.model_tester.create_and_check_model(*A_       )

 def    __magic_name__       (		self :	Tuple       ):






      '''simple docstring'''




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

 def    __magic_name__       (		self :	Tuple       ):






      '''simple docstring'''




      _lowerCAmelCase   :					str        =    self.model_tester.prepare_config_and_inputs()
      self.model_tester.create_and_check_for_multiple_choice(*A_       )

 def    __magic_name__       (		self :	str       ):






      '''simple docstring'''




      _lowerCAmelCase   :					List[Any]        =    self.model_tester.prepare_config_and_inputs()
      self.model_tester.create_and_check_for_question_answering(*A_       )

 def    __magic_name__       (		self :	Union[str, Any]       ):






      '''simple docstring'''




      _lowerCAmelCase   :					str        =    self.model_tester.prepare_config_and_inputs()
      self.model_tester.create_and_check_for_sequence_classification(*A_       )

 def    __magic_name__       (		self :	str       ):






      '''simple docstring'''




      _lowerCAmelCase   :					Optional[int]        =    self.model_tester.prepare_config_and_inputs()
      self.model_tester.create_and_check_for_token_classification(*A_       )

 @slow
 def    __magic_name__       (		self :	List[Any]       ):






      '''simple docstring'''




      for model_name in MRA_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
           _lowerCAmelCase   :					Dict        =    MraModel.from_pretrained(A_       )
           self.assertIsNotNone(A_       )


 @unittest.skip(reason="MRA does not output attentions"       )
 def    __magic_name__       (		self :	Any       ):






      '''simple docstring'''




      return





@require_torch
class A__    ( unittest.TestCase ):



 """simple docstring"""







 @slow
 def    __magic_name__       (		self :	str       ):






      '''simple docstring'''




      _lowerCAmelCase   :					Any        =    MraModel.from_pretrained("uw-madison/mra-base-512-4"       )
      _lowerCAmelCase   :					List[str]        =    torch.arange(2_5_6       ).unsqueeze(0       )

      with torch.no_grad():
           _lowerCAmelCase   :					Optional[Any]        =    model(A_       )[0]

      _lowerCAmelCase   :					int        =    torch.Size((1, 2_5_6, 7_6_8)       )
      self.assertEqual(output.shape     ,						A_       )

      _lowerCAmelCase   :					Dict        =    torch.tensor(
          [[[-0.0140, 0.0830, -0.0381], [0.1546, 0.1402, 0.0220], [0.1162, 0.0851, 0.0165]]]       )

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

 @slow
 def    __magic_name__       (		self :	Tuple       ):






      '''simple docstring'''




      _lowerCAmelCase   :					int        =    MraForMaskedLM.from_pretrained("uw-madison/mra-base-512-4"       )
      _lowerCAmelCase   :					int        =    torch.arange(2_5_6       ).unsqueeze(0       )

      with torch.no_grad():
           _lowerCAmelCase   :					Tuple        =    model(A_       )[0]

      _lowerCAmelCase   :					Optional[int]        =    5_0_2_6_5

      _lowerCAmelCase   :					Union[str, Any]        =    torch.Size((1, 2_5_6, vocab_size)       )
      self.assertEqual(output.shape     ,						A_       )

      _lowerCAmelCase   :					Any        =    torch.tensor(
          [[[9.2595, -3.6038, 11.8819], [9.3869, -3.2693, 11.0956], [11.8524, -3.4938, 13.1210]]]       )

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


 @slow
 def    __magic_name__       (		self :	List[str]       ):






      '''simple docstring'''




      _lowerCAmelCase   :					Any        =    MraForMaskedLM.from_pretrained("uw-madison/mra-base-4096-8-d3"       )
      _lowerCAmelCase   :					List[Any]        =    torch.arange(4_0_9_6       ).unsqueeze(0       )

      with torch.no_grad():
           _lowerCAmelCase   :					List[str]        =    model(A_       )[0]

      _lowerCAmelCase   :					Tuple        =    5_0_2_6_5

      _lowerCAmelCase   :					Union[str, Any]        =    torch.Size((1, 4_0_9_6, vocab_size)       )
      self.assertEqual(output.shape     ,						A_       )

      _lowerCAmelCase   :					int        =    torch.tensor(
          [[[5.4789, -2.3564, 7.5064], [7.9067, -1.3369, 9.9668], [9.0712, -1.8106, 7.0380]]]       )

      self.assertTrue(torch.allclose(output[:, :3, :3]     ,						A_     ,						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


__UpperCAmelCase    				=     logging.get_logger(__name__)





class A__    ( A ):



 """simple docstring"""







 _lowercase     :					Union[str, Any]      =						['''pixel_values''']

 def __init__(		self :	List[str]     ,						A_ :	bool = True     ,						A_ :	Dict[str, int] = None     ,						A_ :	PILImageResampling = PIL.Image.BICUBIC     ,						A_ :	bool = True     ,						A_ :	Dict[str, int] = None     ,						A_ :	Union[int, float] = 1 / 2_5_5     ,						A_ :	bool = True     ,						A_ :	bool = True     ,						A_ :	Optional[Union[float, List[float]]] = None     ,						A_ :	Optional[Union[float, List[float]]] = None     ,						**A_ :	List[str]     ,						):






      '''simple docstring'''




      super().__init__(**A_       )
      _lowerCAmelCase   :					str        =    size if size is not None else {"height": 2_5_6, "width": 2_5_6}
      _lowerCAmelCase   :					Any        =    get_size_dict(A_       )
      _lowerCAmelCase   :					Tuple        =    crop_size if crop_size is not None else {"height": 2_2_4, "width": 2_2_4}
      _lowerCAmelCase   :					Any        =    get_size_dict(A_     ,						param_name="crop_size"       )

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

 def    __magic_name__       (		self :	Optional[int]     ,						A_ :	np.ndarray     ,						A_ :	Dict[str, int]     ,						A_ :	PILImageResampling = PIL.Image.BICUBIC     ,						A_ :	Optional[Union[str, ChannelDimension]] = None     ,						**A_ :	str     ,						):






      '''simple docstring'''




      _lowerCAmelCase   :					Optional[Any]        =    get_size_dict(A_       )
      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(
          A_     ,						size=(size["height"], size["width"])     ,						resample=A_     ,						data_format=A_     ,						**A_       )

 def    __magic_name__       (		self :	Any     ,						A_ :	np.ndarray     ,						A_ :	Dict[str, int]     ,						A_ :	Optional[Union[str, ChannelDimension]] = None     ,						**A_ :	str     ,						):






      '''simple docstring'''




      _lowerCAmelCase   :					Any        =    get_size_dict(A_       )
      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(A_     ,						size=(size["height"], size["width"])     ,						data_format=A_     ,						**A_       )

 def    __magic_name__       (		self :	List[Any]     ,						A_ :	np.ndarray     ,						A_ :	Union[int, float]     ,						A_ :	Optional[Union[str, ChannelDimension]] = None     ,						**A_ :	List[Any]     ,						):






      '''simple docstring'''




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

 def    __magic_name__       (		self :	Optional[Any]     ,						A_ :	np.ndarray     ,						A_ :	Union[float, List[float]]     ,						A_ :	Union[float, List[float]]     ,						A_ :	Optional[Union[str, ChannelDimension]] = None     ,						**A_ :	Optional[int]     ,						):






      '''simple docstring'''




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


 def    __magic_name__       (		self :	Union[str, Any]     ,						A_ :	ImageInput     ,						A_ :	bool = None     ,						A_ :	Dict[str, int] = None     ,						A_ :	Union[str, Any]=None     ,						A_ :	bool = None     ,						A_ :	Dict[str, int] = None     ,						A_ :	bool = None     ,						A_ :	float = None     ,						A_ :	bool = None     ,						A_ :	Optional[Union[float, List[float]]] = None     ,						A_ :	Optional[Union[float, List[float]]] = None     ,						A_ :	Optional[Union[str, TensorType]] = None     ,						A_ :	ChannelDimension = ChannelDimension.FIRST     ,						**A_ :	Dict     ,						):






      '''simple docstring'''




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

      _lowerCAmelCase   :					Optional[int]        =    size if size is not None else self.size
      _lowerCAmelCase   :					List[str]        =    get_size_dict(A_       )
      _lowerCAmelCase   :					int        =    crop_size if crop_size is not None else self.crop_size
      _lowerCAmelCase   :					List[str]        =    get_size_dict(A_     ,						param_name="crop_size"       )

      _lowerCAmelCase   :					Tuple        =    make_list_of_images(A_       )

      if not valid_images(A_       ):
           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(A_       ) for image in images]

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

      if do_center_crop:
           _lowerCAmelCase   :					Any        =    [self.center_crop(image=A_     ,						size=A_       ) for image in images]

      if do_rescale:
           _lowerCAmelCase   :					str        =    [self.rescale(image=A_     ,						scale=A_       ) for image in images]

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

      _lowerCAmelCase   :					Tuple        =    [to_channel_dimension_format(A_     ,						A_       ) for image in images]

      _lowerCAmelCase   :					int        =    {"pixel_values": images}
      return BatchFeature(data=A_     ,						tensor_type=A_       )






