




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 						A:



 '''simple docstring'''


 def __init__(       self      :						Optional[int]		,							A_      :						List[str]		,							A_      :						Optional[int]=3		,							A_      :						List[str]=7		,							A_      :						Dict=True		,							A_      :						Tuple=True		,							A_      :						List[Any]=False		,							A_      :						Tuple=True		,							A_      :						Union[str, Any]=99		,							A_      :						List[str]=32		,							A_      :						List[str]=5		,							A_      :						Tuple=4		,							A_      :						Union[str, Any]=37		,							A_      :						Optional[int]="gelu"		,							A_      :						str=0.1		,							A_      :						List[str]=0.1		,							A_      :						Tuple=512		,							A_      :						Any=16		,							A_      :						int=2		,							A_      :						List[Any]=0.02		,							A_      :						int=3		,							A_      :						int=4		,							A_      :						List[str]=None		,							)     ->			Optional[Any]:

       """simple docstring"""






       lowerCamelCase_	  =					parent
       lowerCamelCase_	  =					batch_size
       lowerCamelCase_	  =					seq_length
       lowerCamelCase_	  =					is_training
       lowerCamelCase_	  =					use_input_mask
       lowerCamelCase_	  =					use_token_type_ids
       lowerCamelCase_	  =					use_labels
       lowerCamelCase_	  =					vocab_size
       lowerCamelCase_	  =					hidden_size
       lowerCamelCase_	  =					num_hidden_layers
       lowerCamelCase_	  =					num_attention_heads
       lowerCamelCase_	  =					intermediate_size
       lowerCamelCase_	  =					hidden_act
       lowerCamelCase_	  =					hidden_dropout_prob
       lowerCamelCase_	  =					attention_probs_dropout_prob
       lowerCamelCase_	  =					max_position_embeddings
       lowerCamelCase_	  =					type_vocab_size
       lowerCamelCase_	  =					type_sequence_label_size
       lowerCamelCase_	  =					initializer_range
       lowerCamelCase_	  =					num_labels
       lowerCamelCase_	  =					num_choices
       lowerCamelCase_	  =					scope

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

       """simple docstring"""






       lowerCamelCase_	  =					ids_tensor([self.batch_size, self.seq_length]		,							self.vocab_size						)

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

       lowerCamelCase_	  =					None

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

       lowerCamelCase_	  =					self.get_config()

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

 def        a__				(       self      :						List[str]						)     ->			Union[str, Any]:

       """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=A_		,							initializer_range=self.initializer_range		,							pad_token_id=1		,							new_decoder_architecture=A_		,							)

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

       """simple docstring"""






       lowerCamelCase_	  =					FalconModel(config=A_						)
       model.to(A_						)
       model.eval()
       lowerCamelCase_	  =					model(A_		,							attention_mask=A_						)
       lowerCamelCase_	  =					model(A_						)
       self.parent.assertEqual(result.last_hidden_state.shape		,							(self.batch_size, self.seq_length, self.hidden_size)						)

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

       """simple docstring"""






       lowerCamelCase_	  =					True
       lowerCamelCase_	  =					FalconModel(A_						)
       model.to(A_						)
       model.eval()
       lowerCamelCase_	  =					model(
           A_		,							attention_mask=A_		,							encoder_hidden_states=A_		,							encoder_attention_mask=A_		,							)
       lowerCamelCase_	  =					model(
           A_		,							attention_mask=A_		,							encoder_hidden_states=A_		,							)
       lowerCamelCase_	  =					model(A_		,							attention_mask=A_						)
       self.parent.assertEqual(result.last_hidden_state.shape		,							(self.batch_size, self.seq_length, self.hidden_size)						)

 def        a__				(       self      :						Optional[int]		,							A_      :						Dict		,							A_      :						Any		,							A_      :						Union[str, Any]		,							A_      :						Optional[Any]		,							A_      :						str		,							A_      :						Optional[Any]		,							A_      :						Dict		,							A_      :						List[str]		,							A_      :						Union[str, Any]		,							)     ->			int:

       """simple docstring"""






       lowerCamelCase_	  =					FalconForCausalLM(config=A_						)
       model.to(A_						)
       model.eval()
       lowerCamelCase_	  =					model(A_		,							attention_mask=A_		,							labels=A_						)
       self.parent.assertEqual(result.logits.shape		,							(self.batch_size, self.seq_length, self.vocab_size)						)

 def        a__				(       self      :						Tuple		,							A_      :						str		,							A_      :						Any		,							A_      :						List[Any]		,							A_      :						List[str]		,							A_      :						Dict		,							A_      :						str		,							A_      :						Union[str, Any]		,							A_      :						int		,							A_      :						List[Any]		,							)     ->			Tuple:

       """simple docstring"""






       lowerCamelCase_	  =					True
       lowerCamelCase_	  =					True
       lowerCamelCase_	  =					FalconForCausalLM(config=A_						)
       model.to(A_						)
       model.eval()

       # first forward pass
       lowerCamelCase_	  =					model(
           A_		,							attention_mask=A_		,							encoder_hidden_states=A_		,							encoder_attention_mask=A_		,							use_cache=A_		,							)
       lowerCamelCase_	  =					outputs.past_key_values

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

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

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

       # select random slice
       lowerCamelCase_	  =					ids_tensor((1,)		,							output_from_past.shape[-1]						).item()
       lowerCamelCase_	  =					output_from_no_past[:, -3:, random_slice_idx].detach()
       lowerCamelCase_	  =					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(A_		,							A_		,							atol=1E-3						)						)





 def        a__				(       self      :						Optional[Any]						)     ->			Tuple:

       """simple docstring"""






       lowerCamelCase_	  =					self.prepare_config_and_inputs()
       (
           (
           lowerCamelCase_       
       )  ,       (
           lowerCamelCase_       
       )  ,       (
           lowerCamelCase_       
       )  ,       (
           lowerCamelCase_       
       )  ,       (
           lowerCamelCase_       
       )  ,       (
           lowerCamelCase_       
       )  ,       (
           lowerCamelCase_       
       )  ,              
       )	  =					config_and_inputs
       lowerCamelCase_	  =					{'input_ids': input_ids, 'attention_mask': input_mask}
       return config, inputs_dict







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



 '''simple docstring'''


 UpperCamelCase		     =		(
     (
         FalconModel,
         FalconForCausalLM,
         FalconForSequenceClassification,
         FalconForTokenClassification,
         FalconForQuestionAnswering,
     )
     if is_torch_available()
     else ()
 )
 UpperCamelCase		     =		(FalconForCausalLM,) if is_torch_available() else ()
 UpperCamelCase		     =		(
     {
         '''feature-extraction''': FalconModel,
         '''text-classification''': FalconForSequenceClassification,
         '''text-generation''': FalconForCausalLM,
         '''question-answering''': FalconForQuestionAnswering,
         '''token-classification''': FalconForTokenClassification,
         '''zero-shot''': FalconForSequenceClassification,
     }
     if is_torch_available()
     else {}
 )
 UpperCamelCase		     =		False
 UpperCamelCase		     =		False

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

       """simple docstring"""






       lowerCamelCase_	  =					FalconModelTester(self						)
       lowerCamelCase_	  =					ConfigTester(self		,							config_class=A_		,							hidden_size=37						)

 def        a__				(       self      :						Any						)     ->			int:

       """simple docstring"""






       self.config_tester.run_common_tests()

 def        a__				(       self      :						Optional[Any]						)     ->			Any:

       """simple docstring"""






       lowerCamelCase_	  =					self.model_tester.prepare_config_and_inputs()
       self.model_tester.create_and_check_model(*A_						)

 def        a__				(       self      :						List[str]						)     ->			List[Any]:

       """simple docstring"""






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

 def        a__				(       self      :						Dict						)     ->			List[str]:

       """simple docstring"""






       lowerCamelCase_  ,       lowerCamelCase_	  =					self.model_tester.prepare_config_and_inputs_for_common()
       lowerCamelCase_	  =					3
       lowerCamelCase_	  =					input_dict['input_ids']
       lowerCamelCase_	  =					input_ids.ne(1						).to(A_						)
       lowerCamelCase_	  =					ids_tensor([self.model_tester.batch_size]		,							self.model_tester.type_sequence_label_size						)
       lowerCamelCase_	  =					FalconForSequenceClassification(A_						)
       model.to(A_						)
       model.eval()
       lowerCamelCase_	  =					model(A_		,							attention_mask=A_		,							labels=A_						)
       self.assertEqual(result.logits.shape		,							(self.model_tester.batch_size, self.model_tester.num_labels)						)

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

       """simple docstring"""






       lowerCamelCase_  ,       lowerCamelCase_	  =					self.model_tester.prepare_config_and_inputs_for_common()
       lowerCamelCase_	  =					3
       lowerCamelCase_	  =					'single_label_classification'
       lowerCamelCase_	  =					input_dict['input_ids']
       lowerCamelCase_	  =					input_ids.ne(1						).to(A_						)
       lowerCamelCase_	  =					ids_tensor([self.model_tester.batch_size]		,							self.model_tester.type_sequence_label_size						)
       lowerCamelCase_	  =					FalconForSequenceClassification(A_						)
       model.to(A_						)
       model.eval()
       lowerCamelCase_	  =					model(A_		,							attention_mask=A_		,							labels=A_						)
       self.assertEqual(result.logits.shape		,							(self.model_tester.batch_size, self.model_tester.num_labels)						)

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

       """simple docstring"""






       lowerCamelCase_  ,       lowerCamelCase_	  =					self.model_tester.prepare_config_and_inputs_for_common()
       lowerCamelCase_	  =					input_dict['input_ids']
       lowerCamelCase_	  =					FalconForCausalLM(A_						)
       model.to(A_						)
       model.eval()
       lowerCamelCase_	  =					model(A_		,							use_cache=A_						)
       lowerCamelCase_	  =					input_ids.shape[0]
       lowerCamelCase_	  =					model._convert_to_rw_cache(result.past_key_values						)
       lowerCamelCase_	  =					model._convert_cache_to_standard_format(A_		,							A_						)
       for layer in range(len(A_						)						):
             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        a__				(       self      :						Dict						)     ->			str:

       """simple docstring"""






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





 def        a__				(       self      :						str						)     ->			Dict:

       """simple docstring"""






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

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

             lowerCamelCase_	  =					model_class(A_						).to(A_						)
             if "use_cache" not in inputs:
                   lowerCamelCase_	  =					True
             lowerCamelCase_	  =					model(**A_						)

             # 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

             lowerCamelCase_	  =					(
                 getattr(A_		,							'decoder_layers'		,							A_						)
                 or getattr(A_		,							'num_decoder_layers'		,							A_						)
                 or config.num_hidden_layers
             )
             lowerCamelCase_	  =					getattr(A_		,							'num_kv_heads'		,							config.num_attention_heads						)
             lowerCamelCase_	  =					getattr(A_		,							'd_model'		,							config.hidden_size						)
             lowerCamelCase_	  =					embed_dim // num_attention_heads

             lowerCamelCase_	  =					outputs['past_key_values']
             self.assertEqual(len(A_						)		,							A_						)

             lowerCamelCase_  ,       lowerCamelCase_	  =					inputs['input_ids'].shape
             for i in range(A_						):
                   if config.new_decoder_architecture:
                         lowerCamelCase_	  =					config.num_attention_heads
                   elif config.multi_query:
                         lowerCamelCase_	  =					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 						A(		unittest.TestCase     ):



 '''simple docstring'''


 @slow
 def        a__				(       self      :						Any						)     ->			Union[str, Any]:

       """simple docstring"""






       lowerCamelCase_	  =					AutoTokenizer.from_pretrained('Rocketknight1/falcon-rw-1b'						)
       lowerCamelCase_	  =					FalconForCausalLM.from_pretrained('Rocketknight1/falcon-rw-1b'						)
       model.eval()
       model.to(A_						)
       lowerCamelCase_	  =					tokenizer('My favorite food is'		,							return_tensors='pt'						).to(A_						)

       lowerCamelCase_	  =					(
           'My favorite food is pizza. I love it so much that I have a pizza party every year for my birthday.'
       )

       lowerCamelCase_	  =					model.generate(**A_		,							do_sample=A_		,							max_new_tokens=19						)
       lowerCamelCase_	  =					tokenizer.batch_decode(A_						)[0]

       self.assertEqual(A_		,							A_						)

 @slow
 def        a__				(       self      :						List[str]						)     ->			Optional[int]:

       """simple docstring"""






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

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





 @slow
 def        a__				(       self      :						str						)     ->			Optional[int]:

       """simple docstring"""






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

                   # Test results are the same with and without cache
                   lowerCamelCase_	  =					model.generate(**A_		,							do_sample=A_		,							max_new_tokens=20		,							use_cache=A_						)
                   lowerCamelCase_	  =					model.generate(**A_		,							do_sample=A_		,							max_new_tokens=20		,							use_cache=A_						)
                   self.assertTrue((outputs_cache - outputs_no_cache).sum().item() == 0						)









from typing import Dict, Iterable, 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_DEFAULT_MEAN,
    IMAGENET_DEFAULT_STD,
    ChannelDimension,
    ImageInput,
    PILImageResampling,
    make_list_of_images,
    to_numpy_array,
    valid_images,
)
from ...utils import TensorType, logging


lowerCamelCase       :	List[Any]									=     logging.get_logger(__name__)







class 						A(		UpperCamelCase     ):



 '''simple docstring'''


 UpperCamelCase		     =		['''pixel_values''']

 def __init__(       self      :						List[Any]		,							A_      :						bool = True		,							A_      :						Dict[str, int] = None		,							A_      :						PILImageResampling = PILImageResampling.BICUBIC		,							A_      :						bool = True		,							A_      :						Dict[str, int] = None		,							A_      :						bool = True		,							A_      :						Union[int, float] = 1 / 255		,							A_      :						bool = True		,							A_      :						Optional[Union[float, Iterable[float]]] = IMAGENET_DEFAULT_MEAN		,							A_      :						Optional[Union[float, Iterable[float]]] = IMAGENET_DEFAULT_STD		,							**A_      :						Tuple		,							)     ->			None:

       """simple docstring"""






       super().__init__(**A_						)
       lowerCamelCase_	  =					size if size is not None else {'shortest_edge': 224}
       lowerCamelCase_	  =					get_size_dict(A_		,							default_to_square=A_						)
       lowerCamelCase_	  =					crop_size if crop_size is not None else {'height': 224, 'width': 224}
       lowerCamelCase_	  =					get_size_dict(A_		,							param_name='crop_size'						)

       lowerCamelCase_	  =					do_resize
       lowerCamelCase_	  =					size
       lowerCamelCase_	  =					resample
       lowerCamelCase_	  =					do_center_crop
       lowerCamelCase_	  =					crop_size
       lowerCamelCase_	  =					do_rescale
       lowerCamelCase_	  =					rescale_factor
       lowerCamelCase_	  =					do_normalize
       lowerCamelCase_	  =					image_mean if image_mean is not None else IMAGENET_DEFAULT_MEAN
       lowerCamelCase_	  =					image_std if image_std is not None else IMAGENET_DEFAULT_STD

 def        a__				(       self      :						Optional[Any]		,							A_      :						np.ndarray		,							A_      :						Dict[str, int]		,							A_      :						PILImageResampling = PILImageResampling.BICUBIC		,							A_      :						Optional[Union[str, ChannelDimension]] = None		,							**A_      :						Tuple		,							)     ->			np.ndarray:

       """simple docstring"""






       lowerCamelCase_	  =					get_size_dict(A_		,							default_to_square=A_						)
       # size_dict is a dict with either keys "height" and "width" or "shortest_edge"
       if "shortest_edge" in size:
             lowerCamelCase_	  =					int((256 / 224) * size['shortest_edge']						)
             lowerCamelCase_	  =					get_resize_output_image_size(A_		,							size=A_		,							default_to_square=A_						)
             lowerCamelCase_	  =					{'height': output_size[0], 'width': output_size[1]}
       if "height" not in size_dict or "width" not in size_dict:
             raise ValueError(
                 f"""Size dict must have keys 'height' and 'width' or 'shortest_edge'. Got {size_dict.keys()}"""						)
       return resize(
           A_		,							size=(size_dict['height'], size_dict['width'])		,							resample=A_		,							data_format=A_		,							**A_						)

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

       """simple docstring"""






       lowerCamelCase_	  =					get_size_dict(A_						)
       if "height" not in size or "width" not in size:
             raise ValueError(f"""Size dict must have keys 'height' and 'width'. Got {size.keys()}"""						)
       return center_crop(A_		,							size=(size['height'], size['width'])		,							data_format=A_		,							**A_						)

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

       """simple docstring"""






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

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

       """simple docstring"""






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





 def        a__				(       self      :						Optional[int]		,							A_      :						ImageInput		,							A_      :						Optional[bool] = None		,							A_      :						Optional[Dict[str, int]] = None		,							A_      :						PILImageResampling = None		,							A_      :						Optional[bool] = None		,							A_      :						Optional[Dict[str, int]] = None		,							A_      :						Optional[bool] = None		,							A_      :						Optional[float] = None		,							A_      :						Optional[bool] = None		,							A_      :						Optional[Union[float, Iterable[float]]] = None		,							A_      :						Optional[Union[float, Iterable[float]]] = None		,							A_      :						Optional[TensorType] = None		,							A_      :						ChannelDimension = ChannelDimension.FIRST		,							**A_      :						List[Any]		,							)     ->			BatchFeature:

       """simple docstring"""






       lowerCamelCase_	  =					do_resize if do_resize is not None else self.do_resize
       lowerCamelCase_	  =					resample if resample is not None else self.resample
       lowerCamelCase_	  =					do_center_crop if do_center_crop is not None else self.do_center_crop
       lowerCamelCase_	  =					do_rescale if do_rescale is not None else self.do_rescale
       lowerCamelCase_	  =					rescale_factor if rescale_factor is not None else self.rescale_factor
       lowerCamelCase_	  =					do_normalize if do_normalize is not None else self.do_normalize
       lowerCamelCase_	  =					image_mean if image_mean is not None else self.image_mean
       lowerCamelCase_	  =					image_std if image_std is not None else self.image_std

       lowerCamelCase_	  =					size if size is not None else self.size
       lowerCamelCase_	  =					get_size_dict(A_		,							default_to_square=A_						)
       lowerCamelCase_	  =					crop_size if crop_size is not None else self.crop_size
       lowerCamelCase_	  =					get_size_dict(A_		,							param_name='crop_size'						)

       lowerCamelCase_	  =					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:
             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.
       lowerCamelCase_	  =					[to_numpy_array(A_						) for image in images]

       if do_resize:
             lowerCamelCase_	  =					[self.resize(A_		,							A_		,							A_						) for image in images]

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

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

       if do_normalize:
             lowerCamelCase_	  =					[self.normalize(A_		,							A_		,							A_						) for image in images]

       lowerCamelCase_	  =					[to_channel_dimension_format(A_		,							A_						) for image in images]

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



