






"""simple docstring"""



import unittest

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


if is_torch_available():
 import torch

 from transformers import (
     MODEL_FOR_PRETRAINING_MAPPING,
     ElectraForCausalLM,
     ElectraForMaskedLM,
     ElectraForMultipleChoice,
     ElectraForPreTraining,
     ElectraForQuestionAnswering,
     ElectraForSequenceClassification,
     ElectraForTokenClassification,
     ElectraModel,
 )
 from transformers.models.electra.modeling_electra import ELECTRA_PRETRAINED_MODEL_ARCHIVE_LIST




class        lowerCAmelCase__       :
   def __init__(						self	:     Dict				,       snake_case__	:     Tuple				,       snake_case__	:     int=1_3				,       snake_case__	:     Optional[Any]=7				,       snake_case__	:     Optional[Any]=True				,       snake_case__	:     Optional[Any]=True				,       snake_case__	:     Optional[int]=True				,       snake_case__	:     str=True				,       snake_case__	:     List[Any]=9_9				,       snake_case__	:     Dict=3_2				,       snake_case__	:     List[str]=5				,       snake_case__	:     Optional[int]=4				,       snake_case__	:     Optional[Any]=3_7				,       snake_case__	:     Dict="gelu"				,       snake_case__	:     Tuple=0.1				,       snake_case__	:     List[str]=0.1				,       snake_case__	:     int=5_1_2				,       snake_case__	:     int=1_6				,       snake_case__	:     Optional[Any]=2				,       snake_case__	:     int=0.02				,       snake_case__	:     Optional[Any]=3				,       snake_case__	:     List[str]=4				,       snake_case__	:     int=None				,       ):


        '''simple docstring'''
        UpperCAmelCase__		:  Dict				=				parent
        UpperCAmelCase__		:  Optional[Any]				=				batch_size
        UpperCAmelCase__		:  List[Any]				=				seq_length
        UpperCAmelCase__		:  Optional[Any]				=				is_training
        UpperCAmelCase__		:  Union[str, Any]				=				use_input_mask
        UpperCAmelCase__		:  List[str]				=				use_token_type_ids
        UpperCAmelCase__		:  List[Any]				=				use_labels
        UpperCAmelCase__		:  Optional[int]				=				vocab_size
        UpperCAmelCase__		:  List[Any]				=				hidden_size
        UpperCAmelCase__		:  Tuple				=				num_hidden_layers
        UpperCAmelCase__		:  Optional[int]				=				num_attention_heads
        UpperCAmelCase__		:  str				=				intermediate_size
        UpperCAmelCase__		:  Tuple				=				hidden_act
        UpperCAmelCase__		:  Any				=				hidden_dropout_prob
        UpperCAmelCase__		:  Tuple				=				attention_probs_dropout_prob
        UpperCAmelCase__		:  str				=				max_position_embeddings
        UpperCAmelCase__		:  Dict				=				type_vocab_size
        UpperCAmelCase__		:  List[str]				=				type_sequence_label_size
        UpperCAmelCase__		:  Tuple				=				initializer_range
        UpperCAmelCase__		:  Any				=				num_labels
        UpperCAmelCase__		:  Union[str, Any]				=				num_choices
        UpperCAmelCase__		:  Any				=				scope
   def 	__a				(						self	:     List[Any]				):


        '''simple docstring'''
        UpperCAmelCase__		:  Any				=				ids_tensor([self.batch_size, self.seq_length]				,       self.vocab_size				)

        UpperCAmelCase__		:  Optional[Any]				=				None
        if self.use_input_mask:
             UpperCAmelCase__		:  List[str]				=				random_attention_mask([self.batch_size, self.seq_length]				)

        UpperCAmelCase__		:  str				=				None
        if self.use_token_type_ids:
             UpperCAmelCase__		:  Optional[Any]				=				ids_tensor([self.batch_size, self.seq_length]				,       self.type_vocab_size				)

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

        UpperCAmelCase__		:  List[Any]				=				self.get_config()

        return (
            config,
            input_ids,
            token_type_ids,
            input_mask,
            sequence_labels,
            token_labels,
            choice_labels,
            fake_token_labels,
        )
   def 	__a				(						self	:     int				):


        '''simple docstring'''
        return ElectraConfig(
            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=snake_case__				,       initializer_range=self.initializer_range				,       )
   def 	__a				(						self	:     List[str]				):


        '''simple docstring'''
        (
            (
            UpperCAmelCase__
        )				,							(
            UpperCAmelCase__
        )				,							(
            UpperCAmelCase__
        )				,							(
            UpperCAmelCase__
        )				,							(
            UpperCAmelCase__
        )				,							(
            UpperCAmelCase__
        )				,							(
            UpperCAmelCase__
        )				,							(
            UpperCAmelCase__
        )				,							
        )		:  Tuple				=				self.prepare_config_and_inputs()

        UpperCAmelCase__		:  Any				=				True
        UpperCAmelCase__		:  Tuple				=				floats_tensor([self.batch_size, self.seq_length, self.hidden_size]				)
        UpperCAmelCase__		:  int				=				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 	__a				(						self	:     List[Any]				,       snake_case__	:     Any				,       snake_case__	:     int				,       snake_case__	:     List[Any]				,       snake_case__	:     str				,       snake_case__	:     Tuple				,       snake_case__	:     Union[str, Any]				,       snake_case__	:     int				,       snake_case__	:     Any				,       ):


        '''simple docstring'''
        UpperCAmelCase__		:  Dict				=				ElectraModel(config=snake_case__				)
        model.to(snake_case__				)
        model.eval()
        UpperCAmelCase__		:  Dict				=				model(snake_case__				,       attention_mask=snake_case__				,       token_type_ids=snake_case__				)
        UpperCAmelCase__		:  str				=				model(snake_case__				,       token_type_ids=snake_case__				)
        UpperCAmelCase__		:  Any				=				model(snake_case__				)
        self.parent.assertEqual(result.last_hidden_state.shape				,       (self.batch_size, self.seq_length, self.hidden_size)				)
   def 	__a				(						self	:     Union[str, Any]				,       snake_case__	:     Any				,       snake_case__	:     str				,       snake_case__	:     List[str]				,       snake_case__	:     Union[str, Any]				,       snake_case__	:     List[str]				,       snake_case__	:     int				,       snake_case__	:     Tuple				,       snake_case__	:     int				,       snake_case__	:     Union[str, Any]				,       ):


        '''simple docstring'''
        UpperCAmelCase__		:  Optional[int]				=				True
        UpperCAmelCase__		:  List[str]				=				ElectraModel(snake_case__				)
        model.to(snake_case__				)
        model.eval()
        UpperCAmelCase__		:  List[str]				=				model(
            snake_case__				,       attention_mask=snake_case__				,       token_type_ids=snake_case__				,       encoder_hidden_states=snake_case__				,       encoder_attention_mask=snake_case__				,       )
        UpperCAmelCase__		:  Dict				=				model(
            snake_case__				,       attention_mask=snake_case__				,       token_type_ids=snake_case__				,       encoder_hidden_states=snake_case__				,       )
        UpperCAmelCase__		:  str				=				model(snake_case__				,       attention_mask=snake_case__				,       token_type_ids=snake_case__				)
        self.parent.assertEqual(result.last_hidden_state.shape				,       (self.batch_size, self.seq_length, self.hidden_size)				)
   def 	__a				(						self	:     List[Any]				,       snake_case__	:     Optional[int]				,       snake_case__	:     Tuple				,       snake_case__	:     str				,       snake_case__	:     List[Any]				,       snake_case__	:     Union[str, Any]				,       snake_case__	:     Optional[int]				,       snake_case__	:     List[str]				,       snake_case__	:     Optional[int]				,       ):


        '''simple docstring'''
        UpperCAmelCase__		:  List[str]				=				ElectraForMaskedLM(config=snake_case__				)
        model.to(snake_case__				)
        model.eval()
        UpperCAmelCase__		:  Tuple				=				model(snake_case__				,       attention_mask=snake_case__				,       token_type_ids=snake_case__				,       labels=snake_case__				)
        self.parent.assertEqual(result.logits.shape				,       (self.batch_size, self.seq_length, self.vocab_size)				)
   def 	__a				(						self	:     Union[str, Any]				,       snake_case__	:     List[Any]				,       snake_case__	:     Union[str, Any]				,       snake_case__	:     List[Any]				,       snake_case__	:     int				,       snake_case__	:     int				,       snake_case__	:     str				,       snake_case__	:     Any				,       snake_case__	:     List[str]				,       snake_case__	:     str				,       ):


        '''simple docstring'''
        UpperCAmelCase__		:  Union[str, Any]				=				ElectraForCausalLM(config=snake_case__				)
        model.to(snake_case__				)
        model.eval()
        UpperCAmelCase__		:  List[str]				=				model(snake_case__				,       attention_mask=snake_case__				,       token_type_ids=snake_case__				,       labels=snake_case__				)
        self.parent.assertEqual(result.logits.shape				,       (self.batch_size, self.seq_length, self.vocab_size)				)
   def 	__a				(						self	:     str				,       snake_case__	:     List[Any]				,       snake_case__	:     str				,       snake_case__	:     Dict				,       snake_case__	:     Tuple				,       snake_case__	:     Dict				,       snake_case__	:     Tuple				,       snake_case__	:     List[Any]				,       snake_case__	:     List[Any]				,       ):


        '''simple docstring'''
        UpperCAmelCase__		:  Optional[int]				=				self.num_labels
        UpperCAmelCase__		:  Dict				=				ElectraForTokenClassification(config=snake_case__				)
        model.to(snake_case__				)
        model.eval()
        UpperCAmelCase__		:  List[str]				=				model(snake_case__				,       attention_mask=snake_case__				,       token_type_ids=snake_case__				,       labels=snake_case__				)
        self.parent.assertEqual(result.logits.shape				,       (self.batch_size, self.seq_length, self.num_labels)				)
   def 	__a				(						self	:     int				,       snake_case__	:     Tuple				,       snake_case__	:     Optional[int]				,       snake_case__	:     int				,       snake_case__	:     int				,       snake_case__	:     List[Any]				,       snake_case__	:     int				,       snake_case__	:     Optional[Any]				,       snake_case__	:     List[Any]				,       ):


        '''simple docstring'''
        UpperCAmelCase__		:  List[str]				=				self.num_labels
        UpperCAmelCase__		:  Tuple				=				ElectraForPreTraining(config=snake_case__				)
        model.to(snake_case__				)
        model.eval()
        UpperCAmelCase__		:  List[str]				=				model(snake_case__				,       attention_mask=snake_case__				,       token_type_ids=snake_case__				,       labels=snake_case__				)
        self.parent.assertEqual(result.logits.shape				,       (self.batch_size, self.seq_length)				)
   def 	__a				(						self	:     str				,       snake_case__	:     str				,       snake_case__	:     str				,       snake_case__	:     Optional[Any]				,       snake_case__	:     List[Any]				,       snake_case__	:     Any				,       snake_case__	:     List[Any]				,       snake_case__	:     Optional[Any]				,       snake_case__	:     List[str]				,       ):


        '''simple docstring'''
        UpperCAmelCase__		:  Any				=				self.num_labels
        UpperCAmelCase__		:  Union[str, Any]				=				ElectraForSequenceClassification(snake_case__				)
        model.to(snake_case__				)
        model.eval()
        UpperCAmelCase__		:  List[str]				=				model(snake_case__				,       attention_mask=snake_case__				,       token_type_ids=snake_case__				,       labels=snake_case__				)
        self.parent.assertEqual(result.logits.shape				,       (self.batch_size, self.num_labels)				)
   def 	__a				(						self	:     Any				,       snake_case__	:     Tuple				,       snake_case__	:     List[str]				,       snake_case__	:     Any				,       snake_case__	:     Dict				,       snake_case__	:     Any				,       snake_case__	:     Optional[Any]				,       snake_case__	:     List[Any]				,       snake_case__	:     List[str]				,       ):


        '''simple docstring'''
        UpperCAmelCase__		:  List[str]				=				ElectraForQuestionAnswering(config=snake_case__				)
        model.to(snake_case__				)
        model.eval()
        UpperCAmelCase__		:  Optional[Any]				=				model(
            snake_case__				,       attention_mask=snake_case__				,       token_type_ids=snake_case__				,       start_positions=snake_case__				,       end_positions=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 	__a				(						self	:     Optional[int]				,       snake_case__	:     Union[str, Any]				,       snake_case__	:     Optional[Any]				,       snake_case__	:     Tuple				,       snake_case__	:     Any				,       snake_case__	:     List[str]				,       snake_case__	:     Optional[int]				,       snake_case__	:     Dict				,       snake_case__	:     int				,       ):


        '''simple docstring'''
        UpperCAmelCase__		:  int				=				self.num_choices
        UpperCAmelCase__		:  Optional[Any]				=				ElectraForMultipleChoice(config=snake_case__				)
        model.to(snake_case__				)
        model.eval()
        UpperCAmelCase__		:  str				=				input_ids.unsqueeze(1				).expand(-1				,       self.num_choices				,       -1				).contiguous()
        UpperCAmelCase__		:  Union[str, Any]				=				token_type_ids.unsqueeze(1				).expand(-1				,       self.num_choices				,       -1				).contiguous()
        UpperCAmelCase__		:  List[str]				=				input_mask.unsqueeze(1				).expand(-1				,       self.num_choices				,       -1				).contiguous()
        UpperCAmelCase__		:  Dict				=				model(
            snake_case__				,       attention_mask=snake_case__				,       token_type_ids=snake_case__				,       labels=snake_case__				,       )
        self.parent.assertEqual(result.logits.shape				,       (self.batch_size, self.num_choices)				)




   def 	__a				(						self	:     str				):


        '''simple docstring'''
        UpperCAmelCase__		:  Any				=				self.prepare_config_and_inputs()
        (
            (
            UpperCAmelCase__
        )				,							(
            UpperCAmelCase__
        )				,							(
            UpperCAmelCase__
        )				,							(
            UpperCAmelCase__
        )				,							(
            UpperCAmelCase__
        )				,							(
            UpperCAmelCase__
        )				,							(
            UpperCAmelCase__
        )				,							(
            UpperCAmelCase__
        )				,							
        )		:  Optional[int]				=				config_and_inputs
        UpperCAmelCase__		:  Dict				=				{"input_ids": input_ids, "token_type_ids": token_type_ids, "attention_mask": input_mask}
        return config, inputs_dict




@require_torch
class        lowerCAmelCase__       (  __magic_name__				,		__magic_name__				,		unittest.TestCase					):
   SCREAMING_SNAKE_CASE_					      =(
       (
           ElectraModel,
           ElectraForPreTraining,
           ElectraForMaskedLM,
           ElectraForCausalLM,
           ElectraForMultipleChoice,
           ElectraForTokenClassification,
           ElectraForSequenceClassification,
           ElectraForQuestionAnswering,
       )
       if is_torch_available()
       else ()
   )
   SCREAMING_SNAKE_CASE_					      =(
       {
           '''feature-extraction''': ElectraModel,
           '''fill-mask''': ElectraForMaskedLM,
           '''question-answering''': ElectraForQuestionAnswering,
           '''text-classification''': ElectraForSequenceClassification,
           '''text-generation''': ElectraForCausalLM,
           '''token-classification''': ElectraForTokenClassification,
           '''zero-shot''': ElectraForSequenceClassification,
       }
       if is_torch_available()
       else {}
   )
   SCREAMING_SNAKE_CASE_					      =True
   def 	__a				(						self	:     List[Any]				,       snake_case__	:     Any				,       snake_case__	:     Any				,       snake_case__	:     Any=False				):


        '''simple docstring'''
        UpperCAmelCase__		:  Union[str, Any]				=				super()._prepare_for_class(snake_case__				,       snake_case__				,       return_labels=snake_case__				)

        if return_labels:
             if model_class in get_values(snake_case__				):
                  UpperCAmelCase__		:  Union[str, Any]				=				torch.zeros(
                      (self.model_tester.batch_size, self.model_tester.seq_length)				,       dtype=torch.long				,       device=snake_case__				)
        return inputs_dict
   def 	__a				(						self	:     str				):


        '''simple docstring'''
        UpperCAmelCase__		:  Tuple				=				ElectraModelTester(self				)
        UpperCAmelCase__		:  Optional[int]				=				ConfigTester(self				,       config_class=snake_case__				,       hidden_size=3_7				)
   def 	__a				(						self	:     Optional[int]				):


        '''simple docstring'''
        self.config_tester.run_common_tests()
   def 	__a				(						self	:     List[Any]				):


        '''simple docstring'''
        UpperCAmelCase__		:  List[Any]				=				self.model_tester.prepare_config_and_inputs()
        self.model_tester.create_and_check_electra_model(*snake_case__				)
   def 	__a				(						self	:     Tuple				):


        '''simple docstring'''
        UpperCAmelCase__		:  Union[str, Any]				=				self.model_tester.prepare_config_and_inputs_for_decoder()
        self.model_tester.create_and_check_electra_model_as_decoder(*snake_case__				)
   def 	__a				(						self	:     Tuple				):


        '''simple docstring'''
        UpperCAmelCase__		:  Optional[Any]				=				self.model_tester.prepare_config_and_inputs()
        for type in ["absolute", "relative_key", "relative_key_query"]:
             UpperCAmelCase__		:  Any				=				type
             self.model_tester.create_and_check_electra_model(*snake_case__				)
   def 	__a				(						self	:     Optional[Any]				):


        '''simple docstring'''
        UpperCAmelCase__		:  Dict				=				self.model_tester.prepare_config_and_inputs()
        self.model_tester.create_and_check_electra_for_masked_lm(*snake_case__				)
   def 	__a				(						self	:     int				):


        '''simple docstring'''
        UpperCAmelCase__		:  List[Any]				=				self.model_tester.prepare_config_and_inputs()
        self.model_tester.create_and_check_electra_for_token_classification(*snake_case__				)
   def 	__a				(						self	:     Optional[Any]				):


        '''simple docstring'''
        UpperCAmelCase__		:  str				=				self.model_tester.prepare_config_and_inputs()
        self.model_tester.create_and_check_electra_for_pretraining(*snake_case__				)
   def 	__a				(						self	:     int				):


        '''simple docstring'''
        UpperCAmelCase__		:  Tuple				=				self.model_tester.prepare_config_and_inputs()
        self.model_tester.create_and_check_electra_for_sequence_classification(*snake_case__				)
   def 	__a				(						self	:     List[Any]				):


        '''simple docstring'''
        UpperCAmelCase__		:  Union[str, Any]				=				self.model_tester.prepare_config_and_inputs()
        self.model_tester.create_and_check_electra_for_question_answering(*snake_case__				)
   def 	__a				(						self	:     int				):


        '''simple docstring'''
        UpperCAmelCase__		:  Optional[int]				=				self.model_tester.prepare_config_and_inputs()
        self.model_tester.create_and_check_electra_for_multiple_choice(*snake_case__				)
   @slow
   def 	__a				(						self	:     Union[str, Any]				):


        '''simple docstring'''
        for model_name in ELECTRA_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
             UpperCAmelCase__		:  List[str]				=				ElectraModel.from_pretrained(snake_case__				)
             self.assertIsNotNone(snake_case__				)




   def 	__a				(						self	:     Dict				):


        '''simple docstring'''
        UpperCAmelCase__		:  List[str]				=				self.model_tester.prepare_config_and_inputs_for_decoder()
        self.model_tester.create_and_check_electra_for_causal_lm(*snake_case__				)




@require_torch
class        lowerCAmelCase__       (  unittest.TestCase					):
   @slow
   def 	__a				(						self	:     int				):


        '''simple docstring'''
        UpperCAmelCase__		:  int				=				ElectraModel.from_pretrained("google/electra-small-discriminator"				)
        UpperCAmelCase__		:  Union[str, Any]				=				torch.tensor([[0, 3_4_5, 2_3_2, 3_2_8, 7_4_0, 1_4_0, 1_6_9_5, 6_9, 6_0_7_8, 1_5_8_8, 2]]				)
        UpperCAmelCase__		:  Optional[int]				=				torch.tensor([[0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]				)
        UpperCAmelCase__		:  Optional[Any]				=				model(snake_case__				,       attention_mask=snake_case__				)[0]
        UpperCAmelCase__		:  List[Any]				=				torch.Size((1, 1_1, 2_5_6)				)
        self.assertEqual(output.shape				,       snake_case__				)
        UpperCAmelCase__		:  List[Any]				=				torch.tensor(
            [[[0.4471, 0.6821, -0.3265], [0.4627, 0.5255, -0.3668], [0.4532, 0.3313, -0.4344]]]				)

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










"""simple docstring"""



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 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, logging


_lowerCAmelCase     :     Any            =	logging.get_logger(__name__)




class        lowerCAmelCase__       (  __magic_name__					):
   SCREAMING_SNAKE_CASE_					      =['''pixel_values''']
   def __init__(						self	:     str				,       snake_case__	:     bool = True				,       snake_case__	:     Optional[Dict[str, int]] = None				,       snake_case__	:     PILImageResampling = PILImageResampling.BILINEAR				,       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__	:     Dict				,       ):


        '''simple docstring'''
        super().__init__(**snake_case__				)
        UpperCAmelCase__		:  Dict				=				size if size is not None else {"height": 2_2_4, "width": 2_2_4}
        UpperCAmelCase__		:  Optional[Any]				=				get_size_dict(snake_case__				)
        UpperCAmelCase__		:  Optional[Any]				=				do_resize
        UpperCAmelCase__		:  Any				=				do_rescale
        UpperCAmelCase__		:  Optional[int]				=				do_normalize
        UpperCAmelCase__		:  Dict				=				size
        UpperCAmelCase__		:  Optional[Any]				=				resample
        UpperCAmelCase__		:  List[str]				=				rescale_factor
        UpperCAmelCase__		:  str				=				image_mean if image_mean is not None else IMAGENET_STANDARD_MEAN
        UpperCAmelCase__		:  Dict				=				image_std if image_std is not None else IMAGENET_STANDARD_STD
   def 	__a				(						self	:     Optional[Any]				,       snake_case__	:     np.ndarray				,       snake_case__	:     Dict[str, int]				,       snake_case__	:     PILImageResampling = PILImageResampling.BILINEAR				,       snake_case__	:     Optional[Union[str, ChannelDimension]] = None				,       **snake_case__	:     Dict				,       ):


        '''simple docstring'''
        UpperCAmelCase__		:  Optional[int]				=				get_size_dict(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()}'				)
        return resize(
            snake_case__				,       size=(size["height"], size["width"])				,       resample=snake_case__				,       data_format=snake_case__				,       **snake_case__				)
   def 	__a				(						self	:     Any				,       snake_case__	:     np.ndarray				,       snake_case__	:     float				,       snake_case__	:     Optional[Union[str, ChannelDimension]] = None				,       **snake_case__	:     Any				):


        '''simple docstring'''
        return rescale(snake_case__				,       scale=snake_case__				,       data_format=snake_case__				,       **snake_case__				)
   def 	__a				(						self	:     str				,       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__	:     List[Any]				,       ):


        '''simple docstring'''
        return normalize(snake_case__				,       mean=snake_case__				,       std=snake_case__				,       data_format=snake_case__				,       **snake_case__				)




   def 	__a				(						self	:     Union[str, Any]				,       snake_case__	:     ImageInput				,       snake_case__	:     Optional[bool] = None				,       snake_case__	:     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__	:     Union[str, ChannelDimension] = ChannelDimension.FIRST				,       **snake_case__	:     List[Any]				,       ):


        '''simple docstring'''
        UpperCAmelCase__		:  Union[str, Any]				=				do_resize if do_resize is not None else self.do_resize
        UpperCAmelCase__		:  Optional[Any]				=				do_rescale if do_rescale is not None else self.do_rescale
        UpperCAmelCase__		:  str				=				do_normalize if do_normalize is not None else self.do_normalize
        UpperCAmelCase__		:  Dict				=				resample if resample is not None else self.resample
        UpperCAmelCase__		:  List[str]				=				rescale_factor if rescale_factor is not None else self.rescale_factor
        UpperCAmelCase__		:  Optional[int]				=				image_mean if image_mean is not None else self.image_mean
        UpperCAmelCase__		:  Optional[int]				=				image_std if image_std is not None else self.image_std

        UpperCAmelCase__		:  Any				=				size if size is not None else self.size
        UpperCAmelCase__		:  Optional[Any]				=				get_size_dict(snake_case__				)

        UpperCAmelCase__		:  List[Any]				=				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:
             raise ValueError("Size 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."				)

        # All transformations expect numpy arrays.
        UpperCAmelCase__		:  Optional[int]				=				[to_numpy_array(snake_case__				) for image in images]

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

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

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

        UpperCAmelCase__		:  Any				=				[to_channel_dimension_format(snake_case__				,       snake_case__				) for image in images]

        UpperCAmelCase__		:  str				=				{"pixel_values": images}
        return BatchFeature(data=snake_case__				,       tensor_type=snake_case__				)


