

'''simple docstring'''

from __future__ import annotations

import random
import unittest

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

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


if is_tf_available():
    import tensorflow as tf

    from transformers import (
        TF_TRANSFO_XL_PRETRAINED_MODEL_ARCHIVE_LIST,
        TFTransfoXLForSequenceClassification,
        TFTransfoXLLMHeadModel,
        TFTransfoXLModel,
    )





class 							_snake_case					:
   def __init__( self			:      Tuple     ,SCREAMING_SNAKE_CASE__			:      Dict     ,):
     SCREAMING_SNAKE_CASE:Any						      =					parent
     SCREAMING_SNAKE_CASE:Optional[Any]						      =					13
     SCREAMING_SNAKE_CASE:Optional[int]						      =					7
     SCREAMING_SNAKE_CASE:Optional[Any]						      =					30
     SCREAMING_SNAKE_CASE:Tuple						      =					self.seq_length + self.mem_len
     SCREAMING_SNAKE_CASE:Dict						      =					15
     SCREAMING_SNAKE_CASE:Union[str, Any]						      =					True
     SCREAMING_SNAKE_CASE:List[Any]						      =					True
     SCREAMING_SNAKE_CASE:int						      =					99
     SCREAMING_SNAKE_CASE:Tuple						      =					[10, 50, 80]
     SCREAMING_SNAKE_CASE:Dict						      =					32
     SCREAMING_SNAKE_CASE:int						      =					32
     SCREAMING_SNAKE_CASE:Any						      =					4
     SCREAMING_SNAKE_CASE:Any						      =					8
     SCREAMING_SNAKE_CASE:List[str]						      =					128
     SCREAMING_SNAKE_CASE:Tuple						      =					2
     SCREAMING_SNAKE_CASE:List[Any]						      =					2
     SCREAMING_SNAKE_CASE:Dict						      =					None
     SCREAMING_SNAKE_CASE:Dict						      =					1
     SCREAMING_SNAKE_CASE:str						      =					0
     SCREAMING_SNAKE_CASE:Any						      =					3
     SCREAMING_SNAKE_CASE:Optional[int]						      =					self.vocab_size - 1
     SCREAMING_SNAKE_CASE:Optional[int]						      =					0.01
   def     __UpperCamelCase						( self			:      Any							):
     SCREAMING_SNAKE_CASE:Optional[int]						      =					ids_tensor([self.batch_size, self.seq_length]     ,self.vocab_size							)
     SCREAMING_SNAKE_CASE:Optional[Any]						      =					ids_tensor([self.batch_size, self.seq_length]     ,self.vocab_size							)

     SCREAMING_SNAKE_CASE:Union[str, Any]						      =					None
     if self.use_labels:
       SCREAMING_SNAKE_CASE:Optional[Any]						      =					ids_tensor([self.batch_size, self.seq_length]     ,self.vocab_size							)

     SCREAMING_SNAKE_CASE:Union[str, Any]						      =					TransfoXLConfig(
         vocab_size=self.vocab_size     ,mem_len=self.mem_len     ,clamp_len=self.clamp_len     ,cutoffs=self.cutoffs     ,d_model=self.hidden_size     ,d_embed=self.d_embed     ,n_head=self.num_attention_heads     ,d_head=self.d_head     ,d_inner=self.d_inner     ,div_val=self.div_val     ,n_layer=self.num_hidden_layers     ,eos_token_id=self.eos_token_id     ,pad_token_id=self.vocab_size - 1     ,init_range=self.init_range     ,num_labels=self.num_labels     ,)

     return (config, input_ids_a, input_ids_a, lm_labels)
   def     __UpperCamelCase						( self			:      Any							):
     random.seed(self.seed							)
     tf.random.set_seed(self.seed							)
   def     __UpperCamelCase						( self			:      List[str]     ,SCREAMING_SNAKE_CASE__			:      Optional[Any]     ,SCREAMING_SNAKE_CASE__			:      str     ,SCREAMING_SNAKE_CASE__			:      int     ,SCREAMING_SNAKE_CASE__			:      str							):
     SCREAMING_SNAKE_CASE:List[str]						      =					TFTransfoXLModel(UpperCamelCase__							)

     SCREAMING_SNAKE_CASE      ,    SCREAMING_SNAKE_CASE:Any						      =					model(UpperCamelCase__							).to_tuple()

     SCREAMING_SNAKE_CASE:Dict						      =					{"input_ids": input_ids_a, "mems": mems_a}

     SCREAMING_SNAKE_CASE      ,    SCREAMING_SNAKE_CASE:List[str]						      =					model(UpperCamelCase__							).to_tuple()

     self.parent.assertEqual(hidden_states_a.shape     ,(self.batch_size, self.seq_length, self.hidden_size)							)
     self.parent.assertEqual(hidden_states_a.shape     ,(self.batch_size, self.seq_length, self.hidden_size)							)
     self.parent.assertListEqual(
         [mem.shape for mem in mems_a]     ,[(self.mem_len, self.batch_size, self.hidden_size)] * self.num_hidden_layers     ,)
     self.parent.assertListEqual(
         [mem.shape for mem in mems_a]     ,[(self.mem_len, self.batch_size, self.hidden_size)] * self.num_hidden_layers     ,)
   def     __UpperCamelCase						( self			:      Tuple     ,SCREAMING_SNAKE_CASE__			:      Dict     ,SCREAMING_SNAKE_CASE__			:      str     ,SCREAMING_SNAKE_CASE__			:      Any     ,SCREAMING_SNAKE_CASE__			:      Optional[Any]							):
     SCREAMING_SNAKE_CASE:Optional[Any]						      =					TFTransfoXLLMHeadModel(UpperCamelCase__							)

     SCREAMING_SNAKE_CASE      ,    SCREAMING_SNAKE_CASE:Dict						      =					model(UpperCamelCase__							).to_tuple()

     SCREAMING_SNAKE_CASE:Dict						      =					{"input_ids": input_ids_a, "labels": lm_labels}
     SCREAMING_SNAKE_CASE      ,    SCREAMING_SNAKE_CASE:List[Any]						      =					model(UpperCamelCase__							).to_tuple()

     SCREAMING_SNAKE_CASE      ,    SCREAMING_SNAKE_CASE:List[str]						      =					model([input_ids_a, mems_a]							).to_tuple()

     SCREAMING_SNAKE_CASE:Dict						      =					{"input_ids": input_ids_a, "mems": mems_a, "labels": lm_labels}

     SCREAMING_SNAKE_CASE      ,    SCREAMING_SNAKE_CASE:Optional[Any]						      =					model(UpperCamelCase__							).to_tuple()

     self.parent.assertEqual(lm_logits_a.shape     ,(self.batch_size, self.seq_length, self.vocab_size)							)
     self.parent.assertListEqual(
         [mem.shape for mem in mems_a]     ,[(self.mem_len, self.batch_size, self.hidden_size)] * self.num_hidden_layers     ,)

     self.parent.assertEqual(lm_logits_a.shape     ,(self.batch_size, self.seq_length, self.vocab_size)							)
     self.parent.assertListEqual(
         [mem.shape for mem in mems_a]     ,[(self.mem_len, self.batch_size, self.hidden_size)] * self.num_hidden_layers     ,)
   def     __UpperCamelCase						( self			:      str     ,SCREAMING_SNAKE_CASE__			:      Tuple     ,SCREAMING_SNAKE_CASE__			:      Optional[int]     ,SCREAMING_SNAKE_CASE__			:      Union[str, Any]     ,SCREAMING_SNAKE_CASE__			:      List[str]							):
     SCREAMING_SNAKE_CASE:Tuple						      =					TFTransfoXLForSequenceClassification(UpperCamelCase__							)
     SCREAMING_SNAKE_CASE:List[str]						      =					model(UpperCamelCase__							)
     self.parent.assertEqual(result.logits.shape     ,(self.batch_size, self.num_labels)							)







   def     __UpperCamelCase						( self			:      List[Any]							):
     SCREAMING_SNAKE_CASE:List[Any]						      =					self.prepare_config_and_inputs()
     ((SCREAMING_SNAKE_CASE)      ,    (SCREAMING_SNAKE_CASE)      ,    (SCREAMING_SNAKE_CASE)      ,    (SCREAMING_SNAKE_CASE)):List[str]						      =					config_and_inputs
     SCREAMING_SNAKE_CASE:Tuple						      =					{"input_ids": input_ids_a}
     return config, inputs_dict





@require_tf
class 							_snake_case					(       _A	,  _A	,  unittest.TestCase						):
   _A       :     Optional[int]       =					(
       (TFTransfoXLModel, TFTransfoXLLMHeadModel, TFTransfoXLForSequenceClassification) if is_tf_available() else ()
   )
   _A       :     Optional[Any]       =					() if is_tf_available() else ()
   _A       :     str       =					(
       {
           '''feature-extraction''': TFTransfoXLModel,
           '''text-classification''': TFTransfoXLForSequenceClassification,
           '''text-generation''': TFTransfoXLLMHeadModel,
           '''zero-shot''': TFTransfoXLForSequenceClassification,
       }
       if is_tf_available()
       else {}
   )
   # TODO: add this test when TFTransfoXLLMHead has a linear output layer implemented
   _A       :     Optional[Any]       =					False
   _A       :     Any       =					False
   _A       :     Tuple       =					False
   _A       :     Optional[int]       =					False
   def     __UpperCamelCase						( self			:      Optional[int]     ,SCREAMING_SNAKE_CASE__			:      Any     ,SCREAMING_SNAKE_CASE__			:      str     ,SCREAMING_SNAKE_CASE__			:      Tuple     ,SCREAMING_SNAKE_CASE__			:      str     ,SCREAMING_SNAKE_CASE__			:      Union[str, Any]							):






     if pipeline_test_casse_name == "TextGenerationPipelineTests":
       # Get `ValueError: AttributeError: 'NoneType' object has no attribute 'new_ones'` or `AssertionError`.
       # `TransfoXLConfig` was never used in pipeline tests: cannot create a simple
       # tokenizer.
       return True

     return False
   def     __UpperCamelCase						( self			:      List[Any]							):
     SCREAMING_SNAKE_CASE:List[Any]						      =					TFTransfoXLModelTester(self							)
     SCREAMING_SNAKE_CASE:Dict						      =					ConfigTester(self     ,config_class=UpperCamelCase__     ,d_embed=37							)
   def     __UpperCamelCase						( self			:      Dict							):
     self.config_tester.run_common_tests()
   def     __UpperCamelCase						( self			:      List[Any]							):
     self.model_tester.set_seed()
     SCREAMING_SNAKE_CASE:Dict						      =					self.model_tester.prepare_config_and_inputs()
     self.model_tester.create_and_check_transfo_xl_model(*UpperCamelCase__							)
   def     __UpperCamelCase						( self			:      Any							):
     self.model_tester.set_seed()
     SCREAMING_SNAKE_CASE:Optional[Any]						      =					self.model_tester.prepare_config_and_inputs()
     self.model_tester.create_and_check_transfo_xl_lm_head(*UpperCamelCase__							)
   def     __UpperCamelCase						( self			:      Any							):
     SCREAMING_SNAKE_CASE:Any						      =					self.model_tester.prepare_config_and_inputs()
     self.model_tester.create_and_check_transfo_xl_for_sequence_classification(*UpperCamelCase__							)
   def     __UpperCamelCase						( self			:      Any							):
     SCREAMING_SNAKE_CASE      ,    SCREAMING_SNAKE_CASE:Any						      =					self.model_tester.prepare_config_and_inputs_for_common()
     SCREAMING_SNAKE_CASE:List[str]						      =					[TFTransfoXLForSequenceClassification]

     for model_class in self.all_model_classes:
       SCREAMING_SNAKE_CASE:int						      =					model_class(UpperCamelCase__							)
       assert isinstance(model.get_input_embeddings()     ,tf.keras.layers.Layer							)
       if model_class in list_other_models_with_output_ebd:
         SCREAMING_SNAKE_CASE:Union[str, Any]						      =					model.get_output_embeddings()
         assert isinstance(UpperCamelCase__     ,tf.keras.layers.Layer							)
         SCREAMING_SNAKE_CASE:List[str]						      =					model.get_bias()
         assert name is None
       else:
         SCREAMING_SNAKE_CASE:str						      =					model.get_output_embeddings()
         assert x is None
         SCREAMING_SNAKE_CASE:Dict						      =					model.get_bias()
         assert name is None
   def     __UpperCamelCase						( self			:      Tuple							):
     pass
   @slow
   def     __UpperCamelCase						( self			:      Dict							):






     for model_name in TF_TRANSFO_XL_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
       SCREAMING_SNAKE_CASE:List[Any]						      =					TFTransfoXLModel.from_pretrained(UpperCamelCase__							)
       self.assertIsNotNone(UpperCamelCase__							)







   @unittest.skip(reason="This model doesn't play well with fit() due to not returning a single loss."							)
   def     __UpperCamelCase						( self			:      Union[str, Any]							):
     pass





@require_tf
class 							_snake_case					(       unittest.TestCase						):
   @unittest.skip("Skip test until #12651 is resolved."							)
   @slow
   def     __UpperCamelCase						( self			:      str							):
     SCREAMING_SNAKE_CASE:Any						      =					TFTransfoXLLMHeadModel.from_pretrained("transfo-xl-wt103"							)
     # fmt: off
     SCREAMING_SNAKE_CASE:Optional[Any]						      =					tf.convert_to_tensor([[33,1_297,2,1,1_009,4,1_109,11_739,4_762,358,5,25,245,22,1_706,17,20_098,5,3_215,21,37,1_110,3,13,1_041,4,24,603,490,2,71_477,20_098,104_447,2,20_961,1,2_604,4,1,329,3,6_224,831,16_002,2,8,603,78_967,29_546,23,803,20,25,416,5,8,232,4,277,6,1_855,4_601,3,29_546,54,8,3_609,5,57_211,49,4,1,277,18,8,1_755,15_691,3,341,25,416,693,42_573,71,17,401,94,31,17_919,2,29_546,7_873,18,1,435,23,11_011,755,5,5_167,3,7_983,98,84,2,29_546,3_267,8,3_609,4,1,4_865,1_075,2,6_087,71,6,346,8,5_854,3,29_546,824,1_400,1_868,2,19,160,2,311,8,5_496,2,20_920,17,25,15_097,3,24,24,0]]     ,dtype=tf.intaa							)  # noqa: E231
     # fmt: on
     #  In 1991 , the remains of Russian Tsar Nicholas II and his family
     #  ( except for Alexei and Maria ) are discovered .
     #  The voice of Nicholas's young son , Tsarevich Alexei Nikolaevich , narrates the
     #  remainder of the story . 1883 Western Siberia ,
     #  a young Grigori Rasputin is asked by his father and a group of men to perform magic .
     #  Rasputin has a vision and denounces one of the men as a horse thief . Although his
     #  father initially slaps him for making such an accusation , Rasputin watches as the
     #  man is chased outside and beaten . Twenty years later , Rasputin sees a vision of
     #  the Virgin Mary , prompting him to become a priest . Rasputin quickly becomes famous ,
     #  with people , even a bishop , begging for his blessing . <eod> </s> <eos>

     # fmt: off
     SCREAMING_SNAKE_CASE:List[str]						      =					[33,1_297,2,1,1_009,4,1_109,11_739,4_762,358,5,25,245,22,1_706,17,20_098,5,3_215,21,37,1_110,3,13,1_041,4,24,603,490,2,71_477,20_098,104_447,2,20_961,1,2_604,4,1,329,3,6_224,831,16_002,2,8,603,78_967,29_546,23,803,20,25,416,5,8,232,4,277,6,1_855,4_601,3,29_546,54,8,3_609,5,57_211,49,4,1,277,18,8,1_755,15_691,3,341,25,416,693,42_573,71,17,401,94,31,17_919,2,29_546,7_873,18,1,435,23,11_011,755,5,5_167,3,7_983,98,84,2,29_546,3_267,8,3_609,4,1,4_865,1_075,2,6_087,71,6,346,8,5_854,3,29_546,824,1_400,1_868,2,19,160,2,311,8,5_496,2,20_920,17,25,15_097,3,24,24,0,33,1,1_857,2,1,1_009,4,1_109,11_739,4_762,358,5,25,245,28,1_110,3,13,1_041,4,24,603,490,2,71_477,20_098,104_447,2,20_961,1,2_604,4,1,329,3,0]  # noqa: E231
     # fmt: on
     #  In 1991, the remains of Russian Tsar Nicholas II and his family (
     #  except for Alexei and Maria ) are discovered. The voice of young son,
     #  Tsarevich Alexei Nikolaevich, narrates the remainder of the story.
     #  1883 Western Siberia, a young Grigori Rasputin is asked by his father
     #  and a group of men to perform magic. Rasputin has a vision and
     #  denounces one of the men as a horse thief. Although his father initially
     #  slaps him for making such an accusation, Rasputin watches as the man
     #  is chased outside and beaten. Twenty years later, Rasputin sees a vision
     #  of the Virgin Mary, prompting him to become a priest.
     #  Rasputin quickly becomes famous, with people, even a bishop, begging for
     #  his blessing. <unk> <unk> <eos> In the 1990s, the remains of Russian Tsar
     # Nicholas II and his family were discovered. The voice of <unk> young son,
     # Tsarevich Alexei Nikolaevich, narrates the remainder of the story.<eos>

     SCREAMING_SNAKE_CASE:Tuple						      =					model.generate(UpperCamelCase__     ,max_length=200     ,do_sample=UpperCamelCase__							)
     self.assertListEqual(output_ids[0].numpy().tolist()     ,UpperCamelCase__							)









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


if is_vision_available():
    import PIL


A_       						=							logging.get_logger(__name__)





class 							_snake_case (       _a						):
   _A       :     Union[str, Any]       =					['''pixel_values''']
   def __init__( self			:      Optional[Any]     ,SCREAMING_SNAKE_CASE__			:      bool = True     ,SCREAMING_SNAKE_CASE__			:      Dict[str, int] = None     ,SCREAMING_SNAKE_CASE__			:      float = None     ,SCREAMING_SNAKE_CASE__			:      PILImageResampling = PILImageResampling.BILINEAR     ,SCREAMING_SNAKE_CASE__			:      bool = True     ,SCREAMING_SNAKE_CASE__			:      Union[int, float] = 1 / 255     ,SCREAMING_SNAKE_CASE__			:      bool = True     ,SCREAMING_SNAKE_CASE__			:      Optional[Union[float, List[float]]] = None     ,SCREAMING_SNAKE_CASE__			:      Optional[Union[float, List[float]]] = None     ,**SCREAMING_SNAKE_CASE__			:      List[str]     ,):
     super().__init__(**SCREAMING_SNAKE_CASE__							)
     SCREAMING_SNAKE_CASE:int						      =					size if size is not None else {"shortest_edge": 384}
     SCREAMING_SNAKE_CASE:List[str]						      =					get_size_dict(SCREAMING_SNAKE_CASE__     ,default_to_square=SCREAMING_SNAKE_CASE__							)

     SCREAMING_SNAKE_CASE:str						      =					do_resize
     SCREAMING_SNAKE_CASE:List[Any]						      =					size
     # Default value set here for backwards compatibility where the value in config is None
     SCREAMING_SNAKE_CASE:Dict						      =					crop_pct if crop_pct is not None else 224 / 256
     SCREAMING_SNAKE_CASE:Any						      =					resample
     SCREAMING_SNAKE_CASE:Dict						      =					do_rescale
     SCREAMING_SNAKE_CASE:Optional[int]						      =					rescale_factor
     SCREAMING_SNAKE_CASE:Union[str, Any]						      =					do_normalize
     SCREAMING_SNAKE_CASE:Optional[int]						      =					image_mean if image_mean is not None else IMAGENET_STANDARD_MEAN
     SCREAMING_SNAKE_CASE:Tuple						      =					image_std if image_std is not None else IMAGENET_STANDARD_STD
   def     __UpperCamelCase						( self			:      List[Any]     ,SCREAMING_SNAKE_CASE__			:      np.ndarray     ,SCREAMING_SNAKE_CASE__			:      Dict[str, int]     ,SCREAMING_SNAKE_CASE__			:      float     ,SCREAMING_SNAKE_CASE__			:      PILImageResampling = PILImageResampling.BICUBIC     ,SCREAMING_SNAKE_CASE__			:      Optional[Union[str, ChannelDimension]] = None     ,**SCREAMING_SNAKE_CASE__			:      int     ,):
     SCREAMING_SNAKE_CASE:List[Any]						      =					get_size_dict(SCREAMING_SNAKE_CASE__     ,default_to_square=SCREAMING_SNAKE_CASE__							)
     if "shortest_edge" not in size:
       raise ValueError(F'''Size dictionary must contain \'shortest_edge\' key. Got {size.keys()}'''							)
     SCREAMING_SNAKE_CASE:Any						      =					size["shortest_edge"]

     if shortest_edge < 384:
       # maintain same ratio, resizing shortest edge to shortest_edge/crop_pct
       SCREAMING_SNAKE_CASE:Any						      =					int(shortest_edge / crop_pct							)
       SCREAMING_SNAKE_CASE:Any						      =					get_resize_output_image_size(SCREAMING_SNAKE_CASE__     ,size=SCREAMING_SNAKE_CASE__     ,default_to_square=SCREAMING_SNAKE_CASE__							)
       SCREAMING_SNAKE_CASE:Union[str, Any]						      =					resize(image=SCREAMING_SNAKE_CASE__     ,size=SCREAMING_SNAKE_CASE__     ,resample=SCREAMING_SNAKE_CASE__     ,data_format=SCREAMING_SNAKE_CASE__     ,**SCREAMING_SNAKE_CASE__							)
       # then crop to (shortest_edge, shortest_edge)
       return center_crop(image=SCREAMING_SNAKE_CASE__     ,size=(shortest_edge, shortest_edge)     ,data_format=SCREAMING_SNAKE_CASE__     ,**SCREAMING_SNAKE_CASE__							)
     else:
       # warping (no cropping) when evaluated at 384 or larger
       return resize(
           SCREAMING_SNAKE_CASE__     ,size=(shortest_edge, shortest_edge)     ,resample=SCREAMING_SNAKE_CASE__     ,data_format=SCREAMING_SNAKE_CASE__     ,**SCREAMING_SNAKE_CASE__							)
   def     __UpperCamelCase						( self			:      Tuple     ,SCREAMING_SNAKE_CASE__			:      np.ndarray     ,SCREAMING_SNAKE_CASE__			:      Union[int, float]     ,SCREAMING_SNAKE_CASE__			:      Optional[Union[str, ChannelDimension]] = None     ,**SCREAMING_SNAKE_CASE__			:      Union[str, Any]     ,):
     return rescale(SCREAMING_SNAKE_CASE__     ,scale=SCREAMING_SNAKE_CASE__     ,data_format=SCREAMING_SNAKE_CASE__     ,**SCREAMING_SNAKE_CASE__							)
   def     __UpperCamelCase						( self			:      Tuple     ,SCREAMING_SNAKE_CASE__			:      np.ndarray     ,SCREAMING_SNAKE_CASE__			:      Union[float, List[float]]     ,SCREAMING_SNAKE_CASE__			:      Union[float, List[float]]     ,SCREAMING_SNAKE_CASE__			:      Optional[Union[str, ChannelDimension]] = None     ,**SCREAMING_SNAKE_CASE__			:      Union[str, Any]     ,):
     return normalize(SCREAMING_SNAKE_CASE__     ,mean=SCREAMING_SNAKE_CASE__     ,std=SCREAMING_SNAKE_CASE__     ,data_format=SCREAMING_SNAKE_CASE__     ,**SCREAMING_SNAKE_CASE__							)







   def     __UpperCamelCase						( self			:      Union[str, Any]     ,SCREAMING_SNAKE_CASE__			:      ImageInput     ,SCREAMING_SNAKE_CASE__			:      bool = None     ,SCREAMING_SNAKE_CASE__			:      Dict[str, int] = None     ,SCREAMING_SNAKE_CASE__			:      float = None     ,SCREAMING_SNAKE_CASE__			:      PILImageResampling = None     ,SCREAMING_SNAKE_CASE__			:      bool = None     ,SCREAMING_SNAKE_CASE__			:      float = None     ,SCREAMING_SNAKE_CASE__			:      bool = None     ,SCREAMING_SNAKE_CASE__			:      Optional[Union[float, List[float]]] = None     ,SCREAMING_SNAKE_CASE__			:      Optional[Union[float, List[float]]] = None     ,SCREAMING_SNAKE_CASE__			:      Optional[Union[str, TensorType]] = None     ,SCREAMING_SNAKE_CASE__			:      ChannelDimension = ChannelDimension.FIRST     ,**SCREAMING_SNAKE_CASE__			:      List[Any]     ,):
     SCREAMING_SNAKE_CASE:Optional[int]						      =					do_resize if do_resize is not None else self.do_resize
     SCREAMING_SNAKE_CASE:List[str]						      =					crop_pct if crop_pct is not None else self.crop_pct
     SCREAMING_SNAKE_CASE:Union[str, Any]						      =					resample if resample is not None else self.resample
     SCREAMING_SNAKE_CASE:List[str]						      =					do_rescale if do_rescale is not None else self.do_rescale
     SCREAMING_SNAKE_CASE:str						      =					rescale_factor if rescale_factor is not None else self.rescale_factor
     SCREAMING_SNAKE_CASE:str						      =					do_normalize if do_normalize is not None else self.do_normalize
     SCREAMING_SNAKE_CASE:Any						      =					image_mean if image_mean is not None else self.image_mean
     SCREAMING_SNAKE_CASE:Optional[Any]						      =					image_std if image_std is not None else self.image_std

     SCREAMING_SNAKE_CASE:Optional[int]						      =					size if size is not None else self.size
     SCREAMING_SNAKE_CASE:Tuple						      =					get_size_dict(SCREAMING_SNAKE_CASE__     ,default_to_square=SCREAMING_SNAKE_CASE__							)

     SCREAMING_SNAKE_CASE:List[Any]						      =					make_list_of_images(SCREAMING_SNAKE_CASE__							)

     if not valid_images(SCREAMING_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 or resample is None:
       raise ValueError("Size and resample must be specified if do_resize is True."							)

     if do_resize and size["shortest_edge"] < 384 and crop_pct is None:
       raise ValueError("crop_pct must be specified if size < 384."							)

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

     if do_resize:
       SCREAMING_SNAKE_CASE:Optional[int]						      =					[self.resize(image=SCREAMING_SNAKE_CASE__     ,size=SCREAMING_SNAKE_CASE__     ,crop_pct=SCREAMING_SNAKE_CASE__     ,resample=SCREAMING_SNAKE_CASE__							) for image in images]

     if do_rescale:
       SCREAMING_SNAKE_CASE:Union[str, Any]						      =					[self.rescale(image=SCREAMING_SNAKE_CASE__     ,scale=SCREAMING_SNAKE_CASE__							) for image in images]

     if do_normalize:
       SCREAMING_SNAKE_CASE:Optional[Any]						      =					[self.normalize(image=SCREAMING_SNAKE_CASE__     ,mean=SCREAMING_SNAKE_CASE__     ,std=SCREAMING_SNAKE_CASE__							) for image in images]

     SCREAMING_SNAKE_CASE:Any						      =					[to_channel_dimension_format(SCREAMING_SNAKE_CASE__     ,SCREAMING_SNAKE_CASE__							) for image in images]

     SCREAMING_SNAKE_CASE:int						      =					{"pixel_values": images}
     return BatchFeature(data=SCREAMING_SNAKE_CASE__     ,tensor_type=SCREAMING_SNAKE_CASE__							)






