



import argparse
import json
import os
import sys
import tempfile
import unittest
from argparse import Namespace
from dataclasses import dataclass, field
from enum import Enum
from pathlib import Path
from typing import List, Literal, Optional

import yaml

from transformers import HfArgumentParser, TrainingArguments
from transformers.hf_argparser import make_choice_type_function, string_to_bool


# Since Python 3.10, we can use the builtin `|` operator for Union types
# See PEP 604: https://peps.python.org/pep-0604
lowerCamelCase		       =      sys.version_info >= (3, 10)






def     SCREAMING_SNAKE_CASE(      __UpperCamelCase=None	,				__UpperCamelCase=None )	->						Union[str, Any]:
				return field(default_factory=lambda: default	,				metadata=__UpperCamelCase )


@dataclass
class 				_a						:





							'''simple docstring'''

							A				:int
							A				:float
							A				:str
							A				:bool





@dataclass
class 				_a						:





							'''simple docstring'''

							A				:int =       42
							A				:str =       field(default="toto"       ,  metadata={"help": "help message"}			)





@dataclass
class 				_a						:





							'''simple docstring'''

							A				:bool =       False
							A				:bool =       True
							A				:Optional[bool] =       None





class 				_a						(       SCREAMING_SNAKE_CASE			):





							'''simple docstring'''

							A				:Tuple =       "titi"
							A				:Any =       "toto"





class 				_a						(       SCREAMING_SNAKE_CASE			):





							'''simple docstring'''

							A				:Optional[Any] =       "titi"
							A				:Tuple =       "toto"
							A				:Optional[int] =       42





@dataclass
class 				_a						:





							'''simple docstring'''

							A				:BasicEnum =       "toto"



							def 		_A	(							self				):







											"""simple docstring"""



											a__	:							Dict      						= BasicEnum(self.foo				)





@dataclass
class 				_a						:





							'''simple docstring'''

							A				:MixedTypeEnum =       "toto"



							def 		_A	(							self				):







											"""simple docstring"""



											a__	:							List[str]      						= MixedTypeEnum(self.foo				)





@dataclass
class 				_a						:





							'''simple docstring'''

							A				:Optional[int] =       None
							A				:Optional[float] =       field(default=SCREAMING_SNAKE_CASE       ,  metadata={"help": "help message"}			)
							A				:Optional[str] =       None
							A				:Optional[List[str]] =       list_field(default=[]			)
							A				:Optional[List[int]] =       list_field(default=[]			)





@dataclass
class 				_a						:





							'''simple docstring'''

							A				:List[int] =       list_field(default=[]			)
							A				:List[int] =       list_field(default=[1, 2, 3]			)
							A				:List[str] =       list_field(default=["Hallo", "Bonjour", "Hello"]			)
							A				:List[float] =       list_field(default=[0.1, 0.2, 0.3]			)





@dataclass
class 				_a						:





							'''simple docstring'''

							A				:List[int] =       field()
							A				:str =       field()
							A				:BasicEnum =       field()



							def 		_A	(							self				):







											"""simple docstring"""



											a__	:							Tuple      						= BasicEnum(self.required_enum				)





@dataclass
class 				_a						:





							'''simple docstring'''

							A				:int
							A				:"BasicEnum" =       field()
							A				:"Optional[bool]" =       None
							A				:"str" =       field(default="toto"       ,  metadata={"help": "help message"}			)
							A				:"List[str]" =       list_field(default=["Hallo", "Bonjour", "Hello"]			)


if is_python_no_less_than_3_10:


						@dataclass
						class 				_a						:





													'''simple docstring'''

													A				:bool =       False
													A				:bool =       True
													A				:bool | None =       None





						@dataclass
						class 				_a						:





													'''simple docstring'''

													A				:int | None =       None
													A				:float | None =       field(default=SCREAMING_SNAKE_CASE       ,  metadata={"help": "help message"}			)
													A				:str | None =       None
													A				:list[str] | None =       list_field(default=[]			)
													A				:list[int] | None =       list_field(default=[]			)






class 				_a						(       unittest.TestCase			):





							'''simple docstring'''

							def 		_A	(							self ,					__UpperCAmelCase ,					__UpperCAmelCase				):







											"""simple docstring"""



											self.assertEqual(len(a._actions				) ,					len(b._actions				)				)
											for x, y in zip(a._actions ,					b._actions				):
															a__	:							List[str]      						= {k: v for k, v in vars(__UpperCAmelCase				).items() if k != "container"}
															a__	:							Dict      						= {k: v for k, v in vars(__UpperCAmelCase				).items() if k != "container"}

															# Choices with mixed type have custom function as "type"
															# So we need to compare results directly for equality
															if xx.get("choices" ,					__UpperCAmelCase				) and yy.get("choices" ,					__UpperCAmelCase				):
																			for expected_choice in yy["choices"] + xx["choices"]:
																							self.assertEqual(xx["type"](__UpperCAmelCase				) ,					yy["type"](__UpperCAmelCase				)				)
																			del xx["type"], yy["type"]

															self.assertEqual(__UpperCAmelCase ,					__UpperCAmelCase				)



							def 		_A	(							self				):







											"""simple docstring"""



											a__	:							str      						= HfArgumentParser(__UpperCAmelCase				)

											a__	:							str      						= argparse.ArgumentParser()
											expected.add_argument("--foo" ,					type=__UpperCAmelCase ,					required=__UpperCAmelCase				)
											expected.add_argument("--bar" ,					type=__UpperCAmelCase ,					required=__UpperCAmelCase				)
											expected.add_argument("--baz" ,					type=__UpperCAmelCase ,					required=__UpperCAmelCase				)
											expected.add_argument("--flag" ,					type=__UpperCAmelCase ,					default=__UpperCAmelCase ,					const=__UpperCAmelCase ,					nargs="?"				)
											self.argparsersEqual(__UpperCAmelCase ,					__UpperCAmelCase				)

											a__	:							Optional[int]      						= ["--foo", "1", "--baz", "quux", "--bar", "0.5"]
											((a__)						,   )	:							str      						= parser.parse_args_into_dataclasses(__UpperCAmelCase ,					look_for_args_file=__UpperCAmelCase				)
											self.assertFalse(example.flag				)



							def 		_A	(							self				):







											"""simple docstring"""



											a__	:							Union[str, Any]      						= HfArgumentParser(__UpperCAmelCase				)

											a__	:							Dict      						= argparse.ArgumentParser()
											expected.add_argument("--foo" ,					default=42 ,					type=__UpperCAmelCase				)
											expected.add_argument("--baz" ,					default="toto" ,					type=__UpperCAmelCase ,					help="help message"				)
											self.argparsersEqual(__UpperCAmelCase ,					__UpperCAmelCase				)



							def 		_A	(							self				):







											"""simple docstring"""



											a__	:							str      						= argparse.ArgumentParser()
											expected.add_argument("--foo" ,					type=__UpperCAmelCase ,					default=__UpperCAmelCase ,					const=__UpperCAmelCase ,					nargs="?"				)
											expected.add_argument("--baz" ,					type=__UpperCAmelCase ,					default=__UpperCAmelCase ,					const=__UpperCAmelCase ,					nargs="?"				)
											# A boolean no_* argument always has to come after its "default: True" regular counter-part
											# and its default must be set to False
											expected.add_argument("--no_baz" ,					action="store_false" ,					default=__UpperCAmelCase ,					dest="baz"				)
											expected.add_argument("--opt" ,					type=__UpperCAmelCase ,					default=__UpperCAmelCase				)

											a__	:							Union[str, Any]      						= [WithDefaultBoolExample]
											if is_python_no_less_than_3_10:
															dataclass_types.append(__UpperCAmelCase				)

											for dataclass_type in dataclass_types:
															a__	:							Union[str, Any]      						= HfArgumentParser(__UpperCAmelCase				)
															self.argparsersEqual(__UpperCAmelCase ,					__UpperCAmelCase				)

															a__	:							Any      						= parser.parse_args([]				)
															self.assertEqual(__UpperCAmelCase ,					Namespace(foo=__UpperCAmelCase ,					baz=__UpperCAmelCase ,					opt=__UpperCAmelCase				)				)

															a__	:							Any      						= parser.parse_args(["--foo", "--no_baz"]				)
															self.assertEqual(__UpperCAmelCase ,					Namespace(foo=__UpperCAmelCase ,					baz=__UpperCAmelCase ,					opt=__UpperCAmelCase				)				)

															a__	:							List[Any]      						= parser.parse_args(["--foo", "--baz"]				)
															self.assertEqual(__UpperCAmelCase ,					Namespace(foo=__UpperCAmelCase ,					baz=__UpperCAmelCase ,					opt=__UpperCAmelCase				)				)

															a__	:							int      						= parser.parse_args(["--foo", "True", "--baz", "True", "--opt", "True"]				)
															self.assertEqual(__UpperCAmelCase ,					Namespace(foo=__UpperCAmelCase ,					baz=__UpperCAmelCase ,					opt=__UpperCAmelCase				)				)

															a__	:							List[Any]      						= parser.parse_args(["--foo", "False", "--baz", "False", "--opt", "False"]				)
															self.assertEqual(__UpperCAmelCase ,					Namespace(foo=__UpperCAmelCase ,					baz=__UpperCAmelCase ,					opt=__UpperCAmelCase				)				)



							def 		_A	(							self				):







											"""simple docstring"""



											a__	:							Optional[int]      						= HfArgumentParser(__UpperCAmelCase				)

											a__	:							Dict      						= argparse.ArgumentParser()
											expected.add_argument(
											    "--foo" ,					default="toto" ,					choices=["titi", "toto", 42] ,					type=make_choice_type_function(["titi", "toto", 42]				) ,					)
											self.argparsersEqual(__UpperCAmelCase ,					__UpperCAmelCase				)

											a__	:							Optional[int]      						= parser.parse_args([]				)
											self.assertEqual(args.foo ,					"toto"				)
											a__	:							Tuple      						= parser.parse_args_into_dataclasses([]				)[0]
											self.assertEqual(enum_ex.foo ,					MixedTypeEnum.toto				)

											a__	:							Dict      						= parser.parse_args(["--foo", "titi"]				)
											self.assertEqual(args.foo ,					"titi"				)
											a__	:							Optional[int]      						= parser.parse_args_into_dataclasses(["--foo", "titi"]				)[0]
											self.assertEqual(enum_ex.foo ,					MixedTypeEnum.titi				)

											a__	:							List[str]      						= parser.parse_args(["--foo", "42"]				)
											self.assertEqual(args.foo ,					42				)
											a__	:							Tuple      						= parser.parse_args_into_dataclasses(["--foo", "42"]				)[0]
											self.assertEqual(enum_ex.foo ,					MixedTypeEnum.fourtytwo				)



							def 		_A	(							self				):







											"""simple docstring"""



											@dataclass
											class 				_a						:





																		'''simple docstring'''

																		A				:Literal["titi", "toto", 42] =       "toto"





											a__	:							str      						= HfArgumentParser(__UpperCAmelCase				)

											a__	:							Optional[int]      						= argparse.ArgumentParser()
											expected.add_argument(
											    "--foo" ,					default="toto" ,					choices=("titi", "toto", 42) ,					type=make_choice_type_function(["titi", "toto", 42]				) ,					)
											self.argparsersEqual(__UpperCAmelCase ,					__UpperCAmelCase				)

											a__	:							Union[str, Any]      						= parser.parse_args([]				)
											self.assertEqual(args.foo ,					"toto"				)

											a__	:							Dict      						= parser.parse_args(["--foo", "titi"]				)
											self.assertEqual(args.foo ,					"titi"				)

											a__	:							Optional[Any]      						= parser.parse_args(["--foo", "42"]				)
											self.assertEqual(args.foo ,					42				)



							def 		_A	(							self				):







											"""simple docstring"""



											a__	:							Any      						= HfArgumentParser(__UpperCAmelCase				)

											a__	:							Optional[Any]      						= argparse.ArgumentParser()
											expected.add_argument("--foo_int" ,					nargs="+" ,					default=[] ,					type=__UpperCAmelCase				)
											expected.add_argument("--bar_int" ,					nargs="+" ,					default=[1, 2, 3] ,					type=__UpperCAmelCase				)
											expected.add_argument("--foo_str" ,					nargs="+" ,					default=["Hallo", "Bonjour", "Hello"] ,					type=__UpperCAmelCase				)
											expected.add_argument("--foo_float" ,					nargs="+" ,					default=[0.1, 0.2, 0.3] ,					type=__UpperCAmelCase				)

											self.argparsersEqual(__UpperCAmelCase ,					__UpperCAmelCase				)

											a__	:							Optional[int]      						= parser.parse_args([]				)
											self.assertEqual(
											    __UpperCAmelCase ,					Namespace(foo_int=[] ,					bar_int=[1, 2, 3] ,					foo_str=["Hallo", "Bonjour", "Hello"] ,					foo_float=[0.1, 0.2, 0.3]				) ,					)

											a__	:							Optional[int]      						= parser.parse_args("--foo_int 1 --bar_int 2 3 --foo_str a b c --foo_float 0.1 0.7".split()				)
											self.assertEqual(__UpperCAmelCase ,					Namespace(foo_int=[1] ,					bar_int=[2, 3] ,					foo_str=["a", "b", "c"] ,					foo_float=[0.1, 0.7]				)				)



							def 		_A	(							self				):







											"""simple docstring"""



											a__	:							Dict      						= argparse.ArgumentParser()
											expected.add_argument("--foo" ,					default=__UpperCAmelCase ,					type=__UpperCAmelCase				)
											expected.add_argument("--bar" ,					default=__UpperCAmelCase ,					type=__UpperCAmelCase ,					help="help message"				)
											expected.add_argument("--baz" ,					default=__UpperCAmelCase ,					type=__UpperCAmelCase				)
											expected.add_argument("--ces" ,					nargs="+" ,					default=[] ,					type=__UpperCAmelCase				)
											expected.add_argument("--des" ,					nargs="+" ,					default=[] ,					type=__UpperCAmelCase				)

											a__	:							str      						= [OptionalExample]
											if is_python_no_less_than_3_10:
															dataclass_types.append(__UpperCAmelCase				)

											for dataclass_type in dataclass_types:
															a__	:							int      						= HfArgumentParser(__UpperCAmelCase				)

															self.argparsersEqual(__UpperCAmelCase ,					__UpperCAmelCase				)

															a__	:							int      						= parser.parse_args([]				)
															self.assertEqual(__UpperCAmelCase ,					Namespace(foo=__UpperCAmelCase ,					bar=__UpperCAmelCase ,					baz=__UpperCAmelCase ,					ces=[] ,					des=[]				)				)

															a__	:							Dict      						= parser.parse_args("--foo 12 --bar 3.14 --baz 42 --ces a b c --des 1 2 3".split()				)
															self.assertEqual(__UpperCAmelCase ,					Namespace(foo=12 ,					bar=3.1_4 ,					baz="42" ,					ces=["a", "b", "c"] ,					des=[1, 2, 3]				)				)



							def 		_A	(							self				):







											"""simple docstring"""



											a__	:							Tuple      						= HfArgumentParser(__UpperCAmelCase				)

											a__	:							Union[str, Any]      						= argparse.ArgumentParser()
											expected.add_argument("--required_list" ,					nargs="+" ,					type=__UpperCAmelCase ,					required=__UpperCAmelCase				)
											expected.add_argument("--required_str" ,					type=__UpperCAmelCase ,					required=__UpperCAmelCase				)
											expected.add_argument(
											    "--required_enum" ,					type=make_choice_type_function(["titi", "toto"]				) ,					choices=["titi", "toto"] ,					required=__UpperCAmelCase ,					)
											self.argparsersEqual(__UpperCAmelCase ,					__UpperCAmelCase				)



							def 		_A	(							self				):







											"""simple docstring"""



											a__	:							int      						= HfArgumentParser(__UpperCAmelCase				)

											a__	:							Optional[Any]      						= argparse.ArgumentParser()
											expected.add_argument("--foo" ,					type=__UpperCAmelCase ,					required=__UpperCAmelCase				)
											expected.add_argument(
											    "--required_enum" ,					type=make_choice_type_function(["titi", "toto"]				) ,					choices=["titi", "toto"] ,					required=__UpperCAmelCase ,					)
											expected.add_argument("--opt" ,					type=__UpperCAmelCase ,					default=__UpperCAmelCase				)
											expected.add_argument("--baz" ,					default="toto" ,					type=__UpperCAmelCase ,					help="help message"				)
											expected.add_argument("--foo_str" ,					nargs="+" ,					default=["Hallo", "Bonjour", "Hello"] ,					type=__UpperCAmelCase				)
											self.argparsersEqual(__UpperCAmelCase ,					__UpperCAmelCase				)



							def 		_A	(							self				):







											"""simple docstring"""



											a__	:							List[str]      						= HfArgumentParser(__UpperCAmelCase				)

											a__	:							Tuple      						= {
											    "foo": 12,
											    "bar": 3.1_4,
											    "baz": "42",
											    "flag": True,
											}

											a__	:							Tuple      						= parser.parse_dict(__UpperCAmelCase				)[0]
											a__	:							Union[str, Any]      						= BasicExample(**__UpperCAmelCase				)
											self.assertEqual(__UpperCAmelCase ,					__UpperCAmelCase				)



							def 		_A	(							self				):







											"""simple docstring"""



											a__	:							List[str]      						= HfArgumentParser(__UpperCAmelCase				)

											a__	:							str      						= {
											    "foo": 12,
											    "bar": 3.1_4,
											    "baz": "42",
											    "flag": True,
											    "extra": 42,
											}

											self.assertRaises(__UpperCAmelCase ,					parser.parse_dict ,					__UpperCAmelCase ,					allow_extra_keys=__UpperCAmelCase				)



							def 		_A	(							self				):







											"""simple docstring"""



											a__	:							Any      						= HfArgumentParser(__UpperCAmelCase				)

											a__	:							Optional[Any]      						= {
											    "foo": 12,
											    "bar": 3.1_4,
											    "baz": "42",
											    "flag": True,
											}
											with tempfile.TemporaryDirectory() as tmp_dir:
															a__	:							Union[str, Any]      						= os.path.join(__UpperCAmelCase ,					"temp_json"				)
															os.mkdir(__UpperCAmelCase				)
															with open(temp_local_path + ".json" ,					"w+"				) as f:
																			json.dump(__UpperCAmelCase ,					__UpperCAmelCase				)
															a__	:							Dict      						= parser.parse_yaml_file(Path(temp_local_path + ".json"				)				)[0]

											a__	:							List[str]      						= BasicExample(**__UpperCAmelCase				)
											self.assertEqual(__UpperCAmelCase ,					__UpperCAmelCase				)



							def 		_A	(							self				):







											"""simple docstring"""



											a__	:							Union[str, Any]      						= HfArgumentParser(__UpperCAmelCase				)

											a__	:							Optional[Any]      						= {
											    "foo": 12,
											    "bar": 3.1_4,
											    "baz": "42",
											    "flag": True,
											}
											with tempfile.TemporaryDirectory() as tmp_dir:
															a__	:							Union[str, Any]      						= os.path.join(__UpperCAmelCase ,					"temp_yaml"				)
															os.mkdir(__UpperCAmelCase				)
															with open(temp_local_path + ".yaml" ,					"w+"				) as f:
																			yaml.dump(__UpperCAmelCase ,					__UpperCAmelCase				)
															a__	:							Union[str, Any]      						= parser.parse_yaml_file(Path(temp_local_path + ".yaml"				)				)[0]
											a__	:							Dict      						= BasicExample(**__UpperCAmelCase				)
											self.assertEqual(__UpperCAmelCase ,					__UpperCAmelCase				)




							def 		_A	(							self				):







											"""simple docstring"""



											a__	:							Optional[Any]      						= HfArgumentParser(__UpperCAmelCase				)
											self.assertIsNotNone(__UpperCAmelCase				)







from typing import Dict, List, Optional, Union

import numpy as np

from transformers.utils import is_vision_available
from transformers.utils.generic import TensorType

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,
    is_valid_image,
    to_numpy_array,
    valid_images,
)
from ...utils import logging


if is_vision_available():
						import PIL

lowerCamelCase		       =      logging.get_logger(__name__)






def     SCREAMING_SNAKE_CASE(      __UpperCamelCase )	->						List[List[ImageInput]]:
				if isinstance(__UpperCamelCase	,				(list, tuple) ) and isinstance(videos[0]	,				(list, tuple) ) and is_valid_image(videos[0][0] ):
								return videos

				elif isinstance(__UpperCamelCase	,				(list, tuple) ) and is_valid_image(videos[0] ):
								return [videos]

				elif is_valid_image(__UpperCamelCase ):
								return [[videos]]

				raise ValueError(F'Could not make batched video from {videos}' )






class 				_a						(       SCREAMING_SNAKE_CASE			):





							'''simple docstring'''

							A				:List[str] =       ["pixel_values"]



							def __init__(							self ,					__UpperCAmelCase = True ,					__UpperCAmelCase = None ,					__UpperCAmelCase = PILImageResampling.BILINEAR ,					__UpperCAmelCase = True ,					__UpperCAmelCase = None ,					__UpperCAmelCase = True ,					__UpperCAmelCase = 1 / 255 ,					__UpperCAmelCase = True ,					__UpperCAmelCase = True ,					__UpperCAmelCase = None ,					__UpperCAmelCase = None ,					**__UpperCAmelCase ,					):







											"""simple docstring"""



											super().__init__(**__UpperCAmelCase				)
											a__	:							int      						= size if size is not None else {"shortest_edge": 256}
											a__	:							str      						= get_size_dict(__UpperCAmelCase ,					default_to_square=__UpperCAmelCase				)
											a__	:							Union[str, Any]      						= crop_size if crop_size is not None else {"height": 224, "width": 224}
											a__	:							int      						= get_size_dict(__UpperCAmelCase ,					param_name="crop_size"				)

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



							def 		_A	(							self ,					__UpperCAmelCase ,					__UpperCAmelCase ,					__UpperCAmelCase = PILImageResampling.BILINEAR ,					__UpperCAmelCase = None ,					**__UpperCAmelCase ,					):







											"""simple docstring"""



											a__	:							Union[str, Any]      						= get_size_dict(__UpperCAmelCase ,					default_to_square=__UpperCAmelCase				)
											if "shortest_edge" in size:
															a__	:							Optional[Any]      						= get_resize_output_image_size(__UpperCAmelCase ,					size["shortest_edge"] ,					default_to_square=__UpperCAmelCase				)
											elif "height" in size and "width" in size:
															a__	:							Union[str, Any]      						= (size["height"], size["width"])
											else:
															raise ValueError(f'Size must have \'height\' and \'width\' or \'shortest_edge\' as keys. Got {size.keys()}'				)
											return resize(__UpperCAmelCase ,					size=__UpperCAmelCase ,					resample=__UpperCAmelCase ,					data_format=__UpperCAmelCase ,					**__UpperCAmelCase				)



							def 		_A	(							self ,					__UpperCAmelCase ,					__UpperCAmelCase ,					__UpperCAmelCase = None ,					**__UpperCAmelCase ,					):







											"""simple docstring"""



											a__	:							Optional[Any]      						= get_size_dict(__UpperCAmelCase				)
											if "height" not in size or "width" not in size:
															raise ValueError(f'Size must have \'height\' and \'width\' as keys. Got {size.keys()}'				)
											return center_crop(__UpperCAmelCase ,					size=(size["height"], size["width"]) ,					data_format=__UpperCAmelCase ,					**__UpperCAmelCase				)



							def 		_A	(							self ,					__UpperCAmelCase ,					__UpperCAmelCase ,					__UpperCAmelCase = True ,					__UpperCAmelCase = None ,					**__UpperCAmelCase ,					):







											"""simple docstring"""



											a__	:							Optional[Any]      						= image.astype(np.floataa				)
											if offset:
															a__	:							Dict      						= image - (scale / 2)
											return rescale(__UpperCAmelCase ,					scale=__UpperCAmelCase ,					data_format=__UpperCAmelCase ,					**__UpperCAmelCase				)



							def 		_A	(							self ,					__UpperCAmelCase ,					__UpperCAmelCase ,					__UpperCAmelCase ,					__UpperCAmelCase = None ,					**__UpperCAmelCase ,					):







											"""simple docstring"""



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



							def 		_A	(							self ,					__UpperCAmelCase ,					__UpperCAmelCase = None ,					__UpperCAmelCase = None ,					__UpperCAmelCase = None ,					__UpperCAmelCase = None ,					__UpperCAmelCase = None ,					__UpperCAmelCase = None ,					__UpperCAmelCase = None ,					__UpperCAmelCase = None ,					__UpperCAmelCase = None ,					__UpperCAmelCase = None ,					__UpperCAmelCase = None ,					__UpperCAmelCase = ChannelDimension.FIRST ,					):







											"""simple docstring"""



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

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

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

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

											if offset and not do_rescale:
															raise ValueError("For offset, do_rescale must also be set to True."				)

											# All transformations expect numpy arrays.
											a__	:							int      						= to_numpy_array(__UpperCAmelCase				)

											if do_resize:
															a__	:							List[Any]      						= self.resize(image=__UpperCAmelCase ,					size=__UpperCAmelCase ,					resample=__UpperCAmelCase				)

											if do_center_crop:
															a__	:							str      						= self.center_crop(__UpperCAmelCase ,					size=__UpperCAmelCase				)

											if do_rescale:
															a__	:							Optional[Any]      						= self.rescale(image=__UpperCAmelCase ,					scale=__UpperCAmelCase ,					offset=__UpperCAmelCase				)

											if do_normalize:
															a__	:							Union[str, Any]      						= self.normalize(image=__UpperCAmelCase ,					mean=__UpperCAmelCase ,					std=__UpperCAmelCase				)

											a__	:							Optional[int]      						= to_channel_dimension_format(__UpperCAmelCase ,					__UpperCAmelCase				)
											return image




							def 		_A	(							self ,					__UpperCAmelCase ,					__UpperCAmelCase = None ,					__UpperCAmelCase = None ,					__UpperCAmelCase = None ,					__UpperCAmelCase = None ,					__UpperCAmelCase = None ,					__UpperCAmelCase = None ,					__UpperCAmelCase = None ,					__UpperCAmelCase = None ,					__UpperCAmelCase = None ,					__UpperCAmelCase = None ,					__UpperCAmelCase = None ,					__UpperCAmelCase = None ,					__UpperCAmelCase = ChannelDimension.FIRST ,					**__UpperCAmelCase ,					):







											"""simple docstring"""



											a__	:							List[Any]      						= do_resize if do_resize is not None else self.do_resize
											a__	:							Dict      						= resample if resample is not None else self.resample
											a__	:							Tuple      						= do_center_crop if do_center_crop is not None else self.do_center_crop
											a__	:							Optional[Any]      						= do_rescale if do_rescale is not None else self.do_rescale
											a__	:							Optional[int]      						= rescale_factor if rescale_factor is not None else self.rescale_factor
											a__	:							List[Any]      						= offset if offset is not None else self.offset
											a__	:							Optional[Any]      						= do_normalize if do_normalize is not None else self.do_normalize
											a__	:							int      						= image_mean if image_mean is not None else self.image_mean
											a__	:							List[Any]      						= image_std if image_std is not None else self.image_std

											a__	:							int      						= size if size is not None else self.size
											a__	:							Tuple      						= get_size_dict(__UpperCAmelCase ,					default_to_square=__UpperCAmelCase				)
											a__	:							List[Any]      						= crop_size if crop_size is not None else self.crop_size
											a__	:							Union[str, Any]      						= get_size_dict(__UpperCAmelCase ,					param_name="crop_size"				)

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

											a__	:							Union[str, Any]      						= make_batched(__UpperCAmelCase				)

											a__	:							Optional[Any]      						= [
											    [
											        self._preprocess_image(
											            image=__UpperCAmelCase ,					do_resize=__UpperCAmelCase ,					size=__UpperCAmelCase ,					resample=__UpperCAmelCase ,					do_center_crop=__UpperCAmelCase ,					crop_size=__UpperCAmelCase ,					do_rescale=__UpperCAmelCase ,					rescale_factor=__UpperCAmelCase ,					offset=__UpperCAmelCase ,					do_normalize=__UpperCAmelCase ,					image_mean=__UpperCAmelCase ,					image_std=__UpperCAmelCase ,					data_format=__UpperCAmelCase ,					)
											        for img in video
											    ]
											    for video in videos
											]

											a__	:							Any      						= {"pixel_values": videos}
											return BatchFeature(data=__UpperCAmelCase ,					tensor_type=__UpperCAmelCase				)


