"""simple docstring"""







import unittest

from transformers import AutoTokenizer, FalconConfig, is_torch_available
from transformers.testing_utils import require_torch, slow, torch_device

from ...generation.test_utils import GenerationTesterMixin
from ...test_configuration_common import ConfigTester
from ...test_modeling_common import ModelTesterMixin, ids_tensor, random_attention_mask
from ...test_pipeline_mixin import PipelineTesterMixin


if is_torch_available():
						import torch

						from transformers import (
						    FalconForCausalLM,
						    FalconForQuestionAnswering,
						    FalconForSequenceClassification,
						    FalconForTokenClassification,
						    FalconModel,
						)



class  _lowerCamelCase			:







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

					"""simple docstring"""






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







				def 							__UpperCAmelCase					( self    :       Dict						):

					"""simple docstring"""






					_lowercase :    List[Any]							=							ids_tensor([self.batch_size, self.seq_length]			,					self.vocab_size						)

					_lowercase :    Dict							=							None
					if self.use_input_mask:
						_lowercase :    Optional[int]							=							random_attention_mask([self.batch_size, self.seq_length]						)

					_lowercase :    Dict							=							None

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

					_lowercase :    Optional[Any]							=							self.get_config()

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







				def 							__UpperCAmelCase					( self    :       int						):

					"""simple docstring"""






					return FalconConfig(
					    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=lowerCamelCase_			,					initializer_range=self.initializer_range			,					pad_token_id=1			,					new_decoder_architecture=lowerCamelCase_			,					)







				def 							__UpperCAmelCase					( self    :       int			,					lowerCamelCase_    :       Union[str, Any]			,					lowerCamelCase_    :       Optional[int]			,					lowerCamelCase_    :       int			,					lowerCamelCase_    :       int			,					lowerCamelCase_    :       int			,					lowerCamelCase_    :       Dict			,					lowerCamelCase_    :       Optional[Any]						):

					"""simple docstring"""






					_lowercase :    Optional[Any]							=							FalconModel(config=lowerCamelCase_						)
					model.to(lowerCamelCase_						)
					model.eval()
					_lowercase :    Optional[Any]							=							model(lowerCamelCase_			,					attention_mask=lowerCamelCase_						)
					_lowercase :    Optional[int]							=							model(lowerCamelCase_						)
					self.parent.assertEqual(result.last_hidden_state.shape			,					(self.batch_size, self.seq_length, self.hidden_size)						)







				def 							__UpperCAmelCase					( self    :       List[Any]			,					lowerCamelCase_    :       List[Any]			,					lowerCamelCase_    :       Optional[Any]			,					lowerCamelCase_    :       Union[str, Any]			,					lowerCamelCase_    :       Dict			,					lowerCamelCase_    :       List[Any]			,					lowerCamelCase_    :       Union[str, Any]			,					lowerCamelCase_    :       Dict			,					lowerCamelCase_    :       List[Any]			,					lowerCamelCase_    :       Union[str, Any]			,					):

					"""simple docstring"""






					_lowercase :    int							=							True
					_lowercase :    Dict							=							FalconModel(lowerCamelCase_						)
					model.to(lowerCamelCase_						)
					model.eval()
					_lowercase :    Tuple							=							model(
					    lowerCamelCase_			,					attention_mask=lowerCamelCase_			,					encoder_hidden_states=lowerCamelCase_			,					encoder_attention_mask=lowerCamelCase_			,					)
					_lowercase :    Optional[Any]							=							model(
					    lowerCamelCase_			,					attention_mask=lowerCamelCase_			,					encoder_hidden_states=lowerCamelCase_			,					)
					_lowercase :    Tuple							=							model(lowerCamelCase_			,					attention_mask=lowerCamelCase_						)
					self.parent.assertEqual(result.last_hidden_state.shape			,					(self.batch_size, self.seq_length, self.hidden_size)						)







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

					"""simple docstring"""






					_lowercase :    Tuple							=							FalconForCausalLM(config=lowerCamelCase_						)
					model.to(lowerCamelCase_						)
					model.eval()
					_lowercase :    Optional[Any]							=							model(lowerCamelCase_			,					attention_mask=lowerCamelCase_			,					labels=lowerCamelCase_						)
					self.parent.assertEqual(result.logits.shape			,					(self.batch_size, self.seq_length, self.vocab_size)						)







				def 							__UpperCAmelCase					( self    :       str			,					lowerCamelCase_    :       Union[str, Any]			,					lowerCamelCase_    :       Tuple			,					lowerCamelCase_    :       Any			,					lowerCamelCase_    :       Tuple			,					lowerCamelCase_    :       str			,					lowerCamelCase_    :       Optional[Any]			,					lowerCamelCase_    :       str			,					lowerCamelCase_    :       Optional[Any]			,					lowerCamelCase_    :       List[Any]			,					):

					"""simple docstring"""






					_lowercase :    Optional[int]							=							True
					_lowercase :    List[Any]							=							True
					_lowercase :    Any							=							FalconForCausalLM(config=lowerCamelCase_						)
					model.to(lowerCamelCase_						)
					model.eval()

					# first forward pass
					_lowercase :    Optional[int]							=							model(
					    lowerCamelCase_			,					attention_mask=lowerCamelCase_			,					encoder_hidden_states=lowerCamelCase_			,					encoder_attention_mask=lowerCamelCase_			,					use_cache=lowerCamelCase_			,					)
					_lowercase :    str							=							outputs.past_key_values

					# create hypothetical multiple next token and extent to next_input_ids
					_lowercase :    Tuple							=							ids_tensor((self.batch_size, 3)			,					config.vocab_size						)
					_lowercase :    str							=							ids_tensor((self.batch_size, 3)			,					vocab_size=2						)

					# append to next input_ids and
					_lowercase :    str							=							torch.cat([input_ids, next_tokens]			,					dim=-1						)
					_lowercase :    List[str]							=							torch.cat([input_mask, next_mask]			,					dim=-1						)

					_lowercase :    str							=							model(
					    lowerCamelCase_			,					attention_mask=lowerCamelCase_			,					encoder_hidden_states=lowerCamelCase_			,					encoder_attention_mask=lowerCamelCase_			,					output_hidden_states=lowerCamelCase_			,					)['hidden_states'][0]
					_lowercase :    str							=							model(
					    lowerCamelCase_			,					attention_mask=lowerCamelCase_			,					encoder_hidden_states=lowerCamelCase_			,					encoder_attention_mask=lowerCamelCase_			,					past_key_values=lowerCamelCase_			,					output_hidden_states=lowerCamelCase_			,					)['hidden_states'][0]

					# select random slice
					_lowercase :    Any							=							ids_tensor((1,)			,					output_from_past.shape[-1]						).item()
					_lowercase :    Optional[int]							=							output_from_no_past[:, -3:, random_slice_idx].detach()
					_lowercase :    Any							=							output_from_past[:, :, random_slice_idx].detach()

					self.parent.assertTrue(output_from_past_slice.shape[1] == next_tokens.shape[1]						)

					# test that outputs are equal for slice
					self.parent.assertTrue(torch.allclose(lowerCamelCase_			,					lowerCamelCase_			,					atol=1E-3						)						)







				def 							__UpperCAmelCase					( self    :       Dict						):

					"""simple docstring"""






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



@require_torch
class  _lowerCamelCase			(__lowerCamelCase						,							__lowerCamelCase						,							__lowerCamelCase						,							unittest.TestCase     ):
				_snake_case     =  (
				    (
				        FalconModel,
				        FalconForCausalLM,
				        FalconForSequenceClassification,
				        FalconForTokenClassification,
				        FalconForQuestionAnswering,
				    )
				    if is_torch_available()
				    else ()
				)
				_snake_case     =  (FalconForCausalLM,) if is_torch_available() else ()
				_snake_case     =  (
				    {
				        "feature-extraction": FalconModel,
				        "text-classification": FalconForSequenceClassification,
				        "text-generation": FalconForCausalLM,
				        "question-answering": FalconForQuestionAnswering,
				        "token-classification": FalconForTokenClassification,
				        "zero-shot": FalconForSequenceClassification,
				    }
				    if is_torch_available()
				    else {}
				)
				_snake_case     =  False
				_snake_case     =  False







				def 							__UpperCAmelCase					( self    :       List[str]						):

					"""simple docstring"""






					_lowercase :    Union[str, Any]							=							FalconModelTester(self						)
					_lowercase :    str							=							ConfigTester(self			,					config_class=lowerCamelCase_			,					hidden_size=3_7						)







				def 							__UpperCAmelCase					( self    :       Any						):

					"""simple docstring"""






					self.config_tester.run_common_tests()







				def 							__UpperCAmelCase					( self    :       int						):

					"""simple docstring"""






					_lowercase :    str							=							self.model_tester.prepare_config_and_inputs()
					self.model_tester.create_and_check_model(*lowerCamelCase_						)







				def 							__UpperCAmelCase					( self    :       List[str]						):

					"""simple docstring"""






					_lowercase				,      *_lowercase :    Dict							=							self.model_tester.prepare_config_and_inputs()
					for alibi in [True, False]:
						_lowercase :    Any							=							alibi
						self.model_tester.create_and_check_model(lowerCamelCase_			,					*lowerCamelCase_						)







				def 							__UpperCAmelCase					( self    :       Any						):

					"""simple docstring"""






					_lowercase				,      _lowercase :    List[Any]							=							self.model_tester.prepare_config_and_inputs_for_common()
					_lowercase :    Optional[int]							=							3
					_lowercase :    Tuple							=							input_dict['input_ids']
					_lowercase :    Tuple							=							input_ids.ne(1						).to(lowerCamelCase_						)
					_lowercase :    Optional[Any]							=							ids_tensor([self.model_tester.batch_size]			,					self.model_tester.type_sequence_label_size						)
					_lowercase :    Optional[int]							=							FalconForSequenceClassification(lowerCamelCase_						)
					model.to(lowerCamelCase_						)
					model.eval()
					_lowercase :    Optional[int]							=							model(lowerCamelCase_			,					attention_mask=lowerCamelCase_			,					labels=lowerCamelCase_						)
					self.assertEqual(result.logits.shape			,					(self.model_tester.batch_size, self.model_tester.num_labels)						)







				def 							__UpperCAmelCase					( self    :       List[str]						):

					"""simple docstring"""






					_lowercase				,      _lowercase :    Dict							=							self.model_tester.prepare_config_and_inputs_for_common()
					_lowercase :    Dict							=							3
					_lowercase :    Tuple							=							'single_label_classification'
					_lowercase :    int							=							input_dict['input_ids']
					_lowercase :    Any							=							input_ids.ne(1						).to(lowerCamelCase_						)
					_lowercase :    List[str]							=							ids_tensor([self.model_tester.batch_size]			,					self.model_tester.type_sequence_label_size						)
					_lowercase :    List[str]							=							FalconForSequenceClassification(lowerCamelCase_						)
					model.to(lowerCamelCase_						)
					model.eval()
					_lowercase :    Optional[int]							=							model(lowerCamelCase_			,					attention_mask=lowerCamelCase_			,					labels=lowerCamelCase_						)
					self.assertEqual(result.logits.shape			,					(self.model_tester.batch_size, self.model_tester.num_labels)						)







				def 							__UpperCAmelCase					( self    :       Optional[Any]						):

					"""simple docstring"""






					_lowercase				,      _lowercase :    int							=							self.model_tester.prepare_config_and_inputs_for_common()
					_lowercase :    Union[str, Any]							=							input_dict['input_ids']
					_lowercase :    Union[str, Any]							=							FalconForCausalLM(lowerCamelCase_						)
					model.to(lowerCamelCase_						)
					model.eval()
					_lowercase :    Union[str, Any]							=							model(lowerCamelCase_			,					use_cache=lowerCamelCase_						)
					_lowercase :    List[Any]							=							input_ids.shape[0]
					_lowercase :    Tuple							=							model._convert_to_rw_cache(result.past_key_values						)
					_lowercase :    Optional[int]							=							model._convert_cache_to_standard_format(lowerCamelCase_			,					lowerCamelCase_						)
					for layer in range(len(lowerCamelCase_						)						):
						for tensor_idx in range(2						):
							self.assertTrue(rw_cache[layer][tensor_idx].ndim == 3						)
							self.assertTrue(result.past_key_values[layer][tensor_idx].ndim == 4						)
							self.assertTrue(
							    torch.all(result.past_key_values[layer][tensor_idx] == standard_cache[layer][tensor_idx]						)						)







				def 							__UpperCAmelCase					( self    :       List[Any]						):

					"""simple docstring"""






					_lowercase				,      _lowercase :    Tuple							=							self.model_tester.prepare_config_and_inputs_for_common()
					_lowercase :    List[str]							=							3
					_lowercase :    Dict							=							'multi_label_classification'
					_lowercase :    List[Any]							=							input_dict['input_ids']
					_lowercase :    Tuple							=							input_ids.ne(1						).to(lowerCamelCase_						)
					_lowercase :    Any							=							ids_tensor(
					    [self.model_tester.batch_size, config.num_labels]			,					self.model_tester.type_sequence_label_size						).to(torch.float						)
					_lowercase :    Tuple							=							FalconForSequenceClassification(lowerCamelCase_						)
					model.to(lowerCamelCase_						)
					model.eval()
					_lowercase :    List[Any]							=							model(lowerCamelCase_			,					attention_mask=lowerCamelCase_			,					labels=lowerCamelCase_						)
					self.assertEqual(result.logits.shape			,					(self.model_tester.batch_size, self.model_tester.num_labels)						)







				def 							__UpperCAmelCase					( self    :       Dict						):

					"""simple docstring"""






					for model_class in self.all_generative_model_classes:
						_lowercase				,      _lowercase :    str							=							self.model_tester.prepare_config_and_inputs_for_common()

						# If it doesn't support cache, pass the test
						if not hasattr(lowerCamelCase_			,					'use_cache'						):
							return

						_lowercase :    List[str]							=							model_class(lowerCamelCase_						).to(lowerCamelCase_						)
						if "use_cache" not in inputs:
							_lowercase :    Tuple							=							True
						_lowercase :    Any							=							model(**lowerCamelCase_						)

						# If "past_key_values" is not returned, pass the test (e.g. RWKV uses a different cache name and format)
						if "past_key_values" not in outputs:
							return

						_lowercase :    Optional[int]							=							(
						    getattr(lowerCamelCase_			,					'decoder_layers'			,					lowerCamelCase_						)
						    or getattr(lowerCamelCase_			,					'num_decoder_layers'			,					lowerCamelCase_						)
						    or config.num_hidden_layers
						)
						_lowercase :    Optional[Any]							=							getattr(lowerCamelCase_			,					'num_kv_heads'			,					config.num_attention_heads						)
						_lowercase :    int							=							getattr(lowerCamelCase_			,					'd_model'			,					config.hidden_size						)
						_lowercase :    Optional[int]							=							embed_dim // num_attention_heads

						_lowercase :    str							=							outputs['past_key_values']
						self.assertEqual(len(lowerCamelCase_						)			,					lowerCamelCase_						)

						_lowercase				,      _lowercase :    str							=							inputs['input_ids'].shape
						for i in range(lowerCamelCase_						):
							if config.new_decoder_architecture:
								_lowercase :    Optional[Any]							=							config.num_attention_heads
							elif config.multi_query:
								_lowercase :    Dict							=							1
							self.assertEqual(len(past_kv[0]						)			,					2						)  # K V for the decoder = 2
							self.assertEqual(
							    past_kv[i][0].shape			,					(batch_size, num_attention_heads, seq_length, per_head_embed_dim)						)
							self.assertEqual(
							    past_kv[i][1].shape			,					(batch_size, num_attention_heads, seq_length, per_head_embed_dim)						)



@require_torch
class  _lowerCamelCase			(unittest.TestCase     ):







				@slow
				def 							__UpperCAmelCase					( self    :       Optional[Any]						):

					"""simple docstring"""






					_lowercase :    str							=							AutoTokenizer.from_pretrained('Rocketknight1/falcon-rw-1b'						)
					_lowercase :    Optional[int]							=							FalconForCausalLM.from_pretrained('Rocketknight1/falcon-rw-1b'						)
					model.eval()
					model.to(lowerCamelCase_						)
					_lowercase :    List[Any]							=							tokenizer('My favorite food is'			,					return_tensors='pt'						).to(lowerCamelCase_						)

					_lowercase :    List[str]							=							(
					    'My favorite food is pizza. I love it so much that I have a pizza party every year for my birthday.'
					)

					_lowercase :    List[str]							=							model.generate(**lowerCamelCase_			,					do_sample=lowerCamelCase_			,					max_new_tokens=1_9						)
					_lowercase :    Dict							=							tokenizer.batch_decode(lowerCamelCase_						)[0]

					self.assertEqual(lowerCamelCase_			,					lowerCamelCase_						)







				@slow
				def 							__UpperCAmelCase					( self    :       Optional[int]						):

					"""simple docstring"""






					for repo in ["Rocketknight1/tiny-random-falcon-7b", "Rocketknight1/tiny-random-falcon-40b"]:
						_lowercase :    Union[str, Any]							=							AutoTokenizer.from_pretrained(lowerCamelCase_						)
						_lowercase :    Union[str, Any]							=							FalconForCausalLM.from_pretrained(lowerCamelCase_						)
						model.eval()
						model.to(lowerCamelCase_						)
						_lowercase :    Tuple							=							tokenizer('My favorite food is'			,					return_tensors='pt'						).to(lowerCamelCase_						)

						# We just test that these run without errors - the models are randomly initialized
						# and so the actual text outputs will be garbage
						model.generate(**lowerCamelCase_			,					do_sample=lowerCamelCase_			,					max_new_tokens=4						)
						model.generate(**lowerCamelCase_			,					do_sample=lowerCamelCase_			,					max_new_tokens=4						)
						model.generate(**lowerCamelCase_			,					num_beams=2			,					max_new_tokens=4						)







				@slow
				def 							__UpperCAmelCase					( self    :       Union[str, Any]						):

					"""simple docstring"""






					with torch.no_grad():
						for repo in [
						    "Rocketknight1/falcon-rw-1b",
						    "Rocketknight1/tiny-random-falcon-7b",
						    "Rocketknight1/tiny-random-falcon-40b",
						]:
							_lowercase :    List[Any]							=							AutoTokenizer.from_pretrained(lowerCamelCase_						)
							_lowercase :    Dict							=							FalconForCausalLM.from_pretrained(lowerCamelCase_						)
							model.eval()
							model.to(device=lowerCamelCase_						)
							_lowercase :    int							=							tokenizer('My favorite food is'			,					return_tensors='pt'						).to(lowerCamelCase_						)

							# Test results are the same with and without cache
							_lowercase :    Union[str, Any]							=							model.generate(**lowerCamelCase_			,					do_sample=lowerCamelCase_			,					max_new_tokens=2_0			,					use_cache=lowerCamelCase_						)
							_lowercase :    str							=							model.generate(**lowerCamelCase_			,					do_sample=lowerCamelCase_			,					max_new_tokens=2_0			,					use_cache=lowerCamelCase_						)
							self.assertTrue((outputs_cache - outputs_no_cache).sum().item() == 0						)




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


SCREAMING_SNAKE_CASE									=						logging.get_logger(__name__)



class  _lowerCamelCase			(__lowerCamelCase     ):
				_snake_case     =  ["pixel_values"]







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

					"""simple docstring"""






					super().__init__(**lowerCamelCase_						)
					_lowercase :    Optional[Any]							=							size if size is not None else {'shortest_edge': 2_5_6}
					_lowercase :    Optional[int]							=							get_size_dict(lowerCamelCase_			,					default_to_square=lowerCamelCase_						)
					_lowercase :    List[str]							=							crop_size if crop_size is not None else {'height': 2_2_4, 'width': 2_2_4}
					_lowercase :    Any							=							get_size_dict(lowerCamelCase_						)
					_lowercase :    Optional[int]							=							do_resize
					_lowercase :    Optional[int]							=							size
					_lowercase :    Union[str, Any]							=							resample
					_lowercase :    Optional[Any]							=							do_center_crop
					_lowercase :    Union[str, Any]							=							crop_size
					_lowercase :    Any							=							do_rescale
					_lowercase :    Tuple							=							rescale_factor
					_lowercase :    Optional[int]							=							do_normalize
					_lowercase :    int							=							image_mean if image_mean is not None else IMAGENET_STANDARD_MEAN
					_lowercase :    Any							=							image_std if image_std is not None else IMAGENET_STANDARD_STD







				def 							__UpperCAmelCase					( self    :       List[Any]			,					lowerCamelCase_    :       np.ndarray			,					lowerCamelCase_    :       Dict[str, int]			,					lowerCamelCase_    :       PILImageResampling = PILImageResampling.BICUBIC			,					lowerCamelCase_    :       Optional[Union[str, ChannelDimension]] = None			,					**lowerCamelCase_    :       Tuple			,					):

					"""simple docstring"""






					_lowercase :    Optional[Any]							=							get_size_dict(lowerCamelCase_			,					default_to_square=lowerCamelCase_						)
					if "shortest_edge" not in size:
						raise ValueError(F'''The `size` parameter must contain the key `shortest_edge`. Got {size.keys()}'''						)
					_lowercase :    Dict							=							get_resize_output_image_size(lowerCamelCase_			,					size=size['shortest_edge']			,					default_to_square=lowerCamelCase_						)
					return resize(lowerCamelCase_			,					size=lowerCamelCase_			,					resample=lowerCamelCase_			,					data_format=lowerCamelCase_			,					**lowerCamelCase_						)







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

					"""simple docstring"""






					_lowercase :    Tuple							=							get_size_dict(lowerCamelCase_						)
					return center_crop(lowerCamelCase_			,					size=(size['height'], size['width'])			,					data_format=lowerCamelCase_			,					**lowerCamelCase_						)







				def 							__UpperCAmelCase					( self    :       Any			,					lowerCamelCase_    :       np.ndarray			,					lowerCamelCase_    :       float			,					lowerCamelCase_    :       Optional[Union[str, ChannelDimension]] = None			,					**lowerCamelCase_    :       Optional[Any]						):

					"""simple docstring"""






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







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

					"""simple docstring"""






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







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

					"""simple docstring"""






					_lowercase :    Optional[Any]							=							do_resize if do_resize is not None else self.do_resize
					_lowercase :    List[Any]							=							size if size is not None else self.size
					_lowercase :    Union[str, Any]							=							get_size_dict(lowerCamelCase_			,					default_to_square=lowerCamelCase_						)
					_lowercase :    Any							=							resample if resample is not None else self.resample
					_lowercase :    Tuple							=							do_center_crop if do_center_crop is not None else self.do_center_crop
					_lowercase :    List[Any]							=							crop_size if crop_size is not None else self.crop_size
					_lowercase :    Tuple							=							get_size_dict(lowerCamelCase_						)
					_lowercase :    List[Any]							=							do_rescale if do_rescale is not None else self.do_rescale
					_lowercase :    int							=							rescale_factor if rescale_factor is not None else self.rescale_factor
					_lowercase :    int							=							do_normalize if do_normalize is not None else self.do_normalize
					_lowercase :    str							=							image_mean if image_mean is not None else self.image_mean
					_lowercase :    List[Any]							=							image_std if image_std is not None else self.image_std

					_lowercase :    Union[str, Any]							=							make_list_of_images(lowerCamelCase_						)

					if not valid_images(lowerCamelCase_						):
						raise ValueError(
						    'Invalid image type. Must be of type PIL.Image.Image, numpy.ndarray, '
						    'torch.Tensor, tf.Tensor or jax.ndarray.'						)

					if do_resize and size is None:
						raise ValueError('Size must be specified if do_resize is True.'						)

					if do_center_crop and crop_size is None:
						raise ValueError('Crop size must be specified if do_center_crop is True.'						)

					if do_rescale and rescale_factor is None:
						raise ValueError('Rescale factor must be specified if do_rescale is True.'						)

					if do_normalize and (image_mean is None or image_std is None):
						raise ValueError('Image mean and std must be specified if do_normalize is True.'						)

					# All transformations expect numpy arrays.
					_lowercase :    Optional[Any]							=							[to_numpy_array(lowerCamelCase_						) for image in images]

					if do_resize:
						_lowercase :    Optional[Any]							=							[self.resize(image=lowerCamelCase_			,					size=lowerCamelCase_			,					resample=lowerCamelCase_						) for image in images]

					if do_center_crop:
						_lowercase :    List[Any]							=							[self.center_crop(image=lowerCamelCase_			,					size=lowerCamelCase_						) for image in images]

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

					if do_normalize:
						_lowercase :    Any							=							[self.normalize(image=lowerCamelCase_			,					mean=lowerCamelCase_			,					std=lowerCamelCase_						) for image in images]

					_lowercase :    int							=							[to_channel_dimension_format(lowerCamelCase_			,					lowerCamelCase_						) for image in images]

					_lowercase :    Tuple							=							{'pixel_values': images}
					return BatchFeature(data=lowerCamelCase_			,					tensor_type=lowerCamelCase_						)



