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 :Dict     =    sys.version_info >= (3, 10)







def    A				(							UpperCAmelCase=None  ,  UpperCAmelCase=None				):
					return field(default_factory=lambda: default  ,  metadata=_lowerCamelCase				)






@dataclass
class        _a:
		lowerCamelCase__     :Union[str, Any]   				=		42
		lowerCamelCase__     :Union[str, Any]   				=		42
		lowerCamelCase__     :str   				=		42
		lowerCamelCase__     :Any   				=		42






@dataclass
class        _a:
		lowerCamelCase__     :Optional[Any]   				=		42
		lowerCamelCase__     :str   				=		field(default='toto'	,   metadata={'help': 'help message'}    )






@dataclass
class        _a:
		lowerCamelCase__     :int   				=		False
		lowerCamelCase__     :Union[str, Any]   				=		True
		lowerCamelCase__     :int   				=		None






class        _a(    _A    ):
		lowerCamelCase__     :Dict   				=		'titi'
		lowerCamelCase__     :Optional[Any]   				=		'toto'






class        _a(    _A    ):
		lowerCamelCase__     :Optional[int]   				=		'titi'
		lowerCamelCase__     :int   				=		'toto'
		lowerCamelCase__     :List[Any]   				=		42






@dataclass
class        _a:
		lowerCamelCase__     :Any   				=		'toto'







		def        lowercase       (    self				)      ->      Any:


							'''simple docstring'''

							_snake_case       :					Optional[int]				       =   BasicEnum(self.foo				)






@dataclass
class        _a:
		lowerCamelCase__     :List[Any]   				=		'toto'







		def        lowercase       (    self				)      ->      List[Any]:


							'''simple docstring'''

							_snake_case       :					Union[str, Any]				       =   MixedTypeEnum(self.foo				)






@dataclass
class        _a:
		lowerCamelCase__     :Optional[int]   				=		None
		lowerCamelCase__     :Optional[Any]   				=		field(default=_A	,   metadata={'help': 'help message'}    )
		lowerCamelCase__     :List[Any]   				=		None
		lowerCamelCase__     :Optional[int]   				=		list_field(default=[]    )
		lowerCamelCase__     :Optional[Any]   				=		list_field(default=[]    )






@dataclass
class        _a:
		lowerCamelCase__     :str   				=		list_field(default=[]    )
		lowerCamelCase__     :Union[str, Any]   				=		list_field(default=[1, 2, 3]    )
		lowerCamelCase__     :Optional[Any]   				=		list_field(default=['Hallo', 'Bonjour', 'Hello']    )
		lowerCamelCase__     :Any   				=		list_field(default=[0.1, 0.2, 0.3]    )






@dataclass
class        _a:
		lowerCamelCase__     :int   				=		field()
		lowerCamelCase__     :List[str]   				=		field()
		lowerCamelCase__     :Optional[int]   				=		field()







		def        lowercase       (    self				)      ->      str:


							'''simple docstring'''

							_snake_case       :					List[str]				       =   BasicEnum(self.required_enum				)






@dataclass
class        _a:
		lowerCamelCase__     :List[str]   				=		42
		lowerCamelCase__     :Tuple   				=		field()
		lowerCamelCase__     :str   				=		None
		lowerCamelCase__     :Tuple   				=		field(default='toto'	,   metadata={'help': 'help message'}    )
		lowerCamelCase__     :str   				=		list_field(default=['Hallo', 'Bonjour', 'Hello']    )


if is_python_no_less_than_3_10:






							@dataclass
							class        _a:
									lowerCamelCase__     :str   				=		False
									lowerCamelCase__     :Optional[Any]   				=		True
									lowerCamelCase__     :List[str]   				=		None






							@dataclass
							class        _a:
									lowerCamelCase__     :Any   				=		None
									lowerCamelCase__     :int   				=		field(default=_A	,   metadata={'help': 'help message'}    )
									lowerCamelCase__     :str   				=		None
									lowerCamelCase__     :Any   				=		list_field(default=[]    )
									lowerCamelCase__     :List[str]   				=		list_field(default=[]    )






class        _a(    unittest.TestCase    ):







		def        lowercase       (    self ,						__snake_case ,						__snake_case				)      ->      Optional[Any]:


							'''simple docstring'''

							self.assertEqual(len(a._actions				) ,						len(b._actions				)				)
							for x, y in zip(a._actions ,						b._actions				):
												_snake_case       :					Union[str, Any]				       =   {k: v for k, v in vars(__lowerCamelCase				).items() if k != "container"}
												_snake_case       :					str				       =   {k: v for k, v in vars(__lowerCamelCase				).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" ,						__lowerCamelCase				) and yy.get("choices" ,						__lowerCamelCase				):
																	for expected_choice in yy["choices"] + xx["choices"]:
																						self.assertEqual(xx["type"](__lowerCamelCase				) ,						yy["type"](__lowerCamelCase				)				)
																	del xx["type"], yy["type"]

												self.assertEqual(__lowerCamelCase ,						__lowerCamelCase				)







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


							'''simple docstring'''

							_snake_case       :					List[Any]				       =   HfArgumentParser(__lowerCamelCase				)

							_snake_case       :					List[Any]				       =   argparse.ArgumentParser()
							expected.add_argument("--foo" ,						type=__lowerCamelCase ,						required=__lowerCamelCase				)
							expected.add_argument("--bar" ,						type=__lowerCamelCase ,						required=__lowerCamelCase				)
							expected.add_argument("--baz" ,						type=__lowerCamelCase ,						required=__lowerCamelCase				)
							expected.add_argument("--flag" ,						type=__lowerCamelCase ,						default=__lowerCamelCase ,						const=__lowerCamelCase ,						nargs="?"				)
							self.argparsersEqual(__lowerCamelCase ,						__lowerCamelCase				)

							_snake_case       :					Dict				       =   ["--foo", "1", "--baz", "quux", "--bar", "0.5"]
							(_snake_case )       :					Optional[Any]				       =   parser.parse_args_into_dataclasses(__lowerCamelCase ,						look_for_args_file=__lowerCamelCase				)
							self.assertFalse(example.flag				)







		def        lowercase       (    self				)      ->      Tuple:


							'''simple docstring'''

							_snake_case       :					str				       =   HfArgumentParser(__lowerCamelCase				)

							_snake_case       :					Any				       =   argparse.ArgumentParser()
							expected.add_argument("--foo" ,						default=4_2 ,						type=__lowerCamelCase				)
							expected.add_argument("--baz" ,						default="toto" ,						type=__lowerCamelCase ,						help="help message"				)
							self.argparsersEqual(__lowerCamelCase ,						__lowerCamelCase				)







		def        lowercase       (    self				)      ->      Tuple:


							'''simple docstring'''

							_snake_case       :					Any				       =   argparse.ArgumentParser()
							expected.add_argument("--foo" ,						type=__lowerCamelCase ,						default=__lowerCamelCase ,						const=__lowerCamelCase ,						nargs="?"				)
							expected.add_argument("--baz" ,						type=__lowerCamelCase ,						default=__lowerCamelCase ,						const=__lowerCamelCase ,						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=__lowerCamelCase ,						dest="baz"				)
							expected.add_argument("--opt" ,						type=__lowerCamelCase ,						default=__lowerCamelCase				)

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

							for dataclass_type in dataclass_types:
												_snake_case       :					int				       =   HfArgumentParser(__lowerCamelCase				)
												self.argparsersEqual(__lowerCamelCase ,						__lowerCamelCase				)

												_snake_case       :					Union[str, Any]				       =   parser.parse_args([]				)
												self.assertEqual(__lowerCamelCase ,						Namespace(foo=__lowerCamelCase ,						baz=__lowerCamelCase ,						opt=__lowerCamelCase				)				)

												_snake_case       :					List[str]				       =   parser.parse_args(["--foo", "--no_baz"]				)
												self.assertEqual(__lowerCamelCase ,						Namespace(foo=__lowerCamelCase ,						baz=__lowerCamelCase ,						opt=__lowerCamelCase				)				)

												_snake_case       :					Any				       =   parser.parse_args(["--foo", "--baz"]				)
												self.assertEqual(__lowerCamelCase ,						Namespace(foo=__lowerCamelCase ,						baz=__lowerCamelCase ,						opt=__lowerCamelCase				)				)

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

												_snake_case       :					Tuple				       =   parser.parse_args(["--foo", "False", "--baz", "False", "--opt", "False"]				)
												self.assertEqual(__lowerCamelCase ,						Namespace(foo=__lowerCamelCase ,						baz=__lowerCamelCase ,						opt=__lowerCamelCase				)				)







		def        lowercase       (    self				)      ->      List[Any]:


							'''simple docstring'''

							_snake_case       :					List[str]				       =   HfArgumentParser(__lowerCamelCase				)

							_snake_case       :					Any				       =   argparse.ArgumentParser()
							expected.add_argument(
							    "--foo" ,						default="toto" ,						choices=["titi", "toto", 4_2] ,						type=make_choice_type_function(["titi", "toto", 4_2]				) ,						)
							self.argparsersEqual(__lowerCamelCase ,						__lowerCamelCase				)

							_snake_case       :					Union[str, Any]				       =   parser.parse_args([]				)
							self.assertEqual(args.foo ,						"toto"				)
							_snake_case       :					Tuple				       =   parser.parse_args_into_dataclasses([]				)[0]
							self.assertEqual(enum_ex.foo ,						MixedTypeEnum.toto				)

							_snake_case       :					Optional[Any]				       =   parser.parse_args(["--foo", "titi"]				)
							self.assertEqual(args.foo ,						"titi"				)
							_snake_case       :					str				       =   parser.parse_args_into_dataclasses(["--foo", "titi"]				)[0]
							self.assertEqual(enum_ex.foo ,						MixedTypeEnum.titi				)

							_snake_case       :					Optional[int]				       =   parser.parse_args(["--foo", "42"]				)
							self.assertEqual(args.foo ,						4_2				)
							_snake_case       :					Optional[int]				       =   parser.parse_args_into_dataclasses(["--foo", "42"]				)[0]
							self.assertEqual(enum_ex.foo ,						MixedTypeEnum.fourtytwo				)







		def        lowercase       (    self				)      ->      Tuple:


							'''simple docstring'''

							@dataclass
							class        _a:
									lowerCamelCase__     :int   				=		'toto'






							_snake_case       :					List[str]				       =   HfArgumentParser(__lowerCamelCase				)

							_snake_case       :					List[Any]				       =   argparse.ArgumentParser()
							expected.add_argument(
							    "--foo" ,						default="toto" ,						choices=("titi", "toto", 4_2) ,						type=make_choice_type_function(["titi", "toto", 4_2]				) ,						)
							self.argparsersEqual(__lowerCamelCase ,						__lowerCamelCase				)

							_snake_case       :					Optional[int]				       =   parser.parse_args([]				)
							self.assertEqual(args.foo ,						"toto"				)

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

							_snake_case       :					int				       =   parser.parse_args(["--foo", "42"]				)
							self.assertEqual(args.foo ,						4_2				)







		def        lowercase       (    self				)      ->      Tuple:


							'''simple docstring'''

							_snake_case       :					List[Any]				       =   HfArgumentParser(__lowerCamelCase				)

							_snake_case       :					List[str]				       =   argparse.ArgumentParser()
							expected.add_argument("--foo_int" ,						nargs="+" ,						default=[] ,						type=__lowerCamelCase				)
							expected.add_argument("--bar_int" ,						nargs="+" ,						default=[1, 2, 3] ,						type=__lowerCamelCase				)
							expected.add_argument("--foo_str" ,						nargs="+" ,						default=["Hallo", "Bonjour", "Hello"] ,						type=__lowerCamelCase				)
							expected.add_argument("--foo_float" ,						nargs="+" ,						default=[0.1, 0.2, 0.3] ,						type=__lowerCamelCase				)

							self.argparsersEqual(__lowerCamelCase ,						__lowerCamelCase				)

							_snake_case       :					Tuple				       =   parser.parse_args([]				)
							self.assertEqual(
							    __lowerCamelCase ,						Namespace(foo_int=[] ,						bar_int=[1, 2, 3] ,						foo_str=["Hallo", "Bonjour", "Hello"] ,						foo_float=[0.1, 0.2, 0.3]				) ,						)

							_snake_case       :					Union[str, Any]				       =   parser.parse_args("--foo_int 1 --bar_int 2 3 --foo_str a b c --foo_float 0.1 0.7".split()				)
							self.assertEqual(__lowerCamelCase ,						Namespace(foo_int=[1] ,						bar_int=[2, 3] ,						foo_str=["a", "b", "c"] ,						foo_float=[0.1, 0.7]				)				)







		def        lowercase       (    self				)      ->      Optional[int]:


							'''simple docstring'''

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

							_snake_case       :					List[str]				       =   [OptionalExample]
							if is_python_no_less_than_3_10:
												dataclass_types.append(__lowerCamelCase				)

							for dataclass_type in dataclass_types:
												_snake_case       :					Optional[Any]				       =   HfArgumentParser(__lowerCamelCase				)

												self.argparsersEqual(__lowerCamelCase ,						__lowerCamelCase				)

												_snake_case       :					List[Any]				       =   parser.parse_args([]				)
												self.assertEqual(__lowerCamelCase ,						Namespace(foo=__lowerCamelCase ,						bar=__lowerCamelCase ,						baz=__lowerCamelCase ,						ces=[] ,						des=[]				)				)

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







		def        lowercase       (    self				)      ->      Optional[int]:


							'''simple docstring'''

							_snake_case       :					Dict				       =   HfArgumentParser(__lowerCamelCase				)

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







		def        lowercase       (    self				)      ->      str:


							'''simple docstring'''

							_snake_case       :					List[str]				       =   HfArgumentParser(__lowerCamelCase				)

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







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


							'''simple docstring'''

							_snake_case       :					Optional[Any]				       =   HfArgumentParser(__lowerCamelCase				)

							_snake_case       :					int				       =   {
							    "foo": 1_2,
							    "bar": 3.14,
							    "baz": "42",
							    "flag": True,
							}

							_snake_case       :					List[Any]				       =   parser.parse_dict(__lowerCamelCase				)[0]
							_snake_case       :					int				       =   BasicExample(**__lowerCamelCase				)
							self.assertEqual(__lowerCamelCase ,						__lowerCamelCase				)







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


							'''simple docstring'''

							_snake_case       :					List[Any]				       =   HfArgumentParser(__lowerCamelCase				)

							_snake_case       :					str				       =   {
							    "foo": 1_2,
							    "bar": 3.14,
							    "baz": "42",
							    "flag": True,
							    "extra": 4_2,
							}

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







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


							'''simple docstring'''

							_snake_case       :					Optional[int]				       =   HfArgumentParser(__lowerCamelCase				)

							_snake_case       :					List[str]				       =   {
							    "foo": 1_2,
							    "bar": 3.14,
							    "baz": "42",
							    "flag": True,
							}
							with tempfile.TemporaryDirectory() as tmp_dir:
												_snake_case       :					List[Any]				       =   os.path.join(__lowerCamelCase ,						"temp_json"				)
												os.mkdir(__lowerCamelCase				)
												with open(temp_local_path + ".json" ,						"w+"				) as f:
																	json.dump(__lowerCamelCase ,						__lowerCamelCase				)
												_snake_case       :					Tuple				       =   parser.parse_yaml_file(Path(temp_local_path + ".json"				)				)[0]

							_snake_case       :					List[Any]				       =   BasicExample(**__lowerCamelCase				)
							self.assertEqual(__lowerCamelCase ,						__lowerCamelCase				)







		def        lowercase       (    self				)      ->      Tuple:


							'''simple docstring'''

							_snake_case       :					Any				       =   HfArgumentParser(__lowerCamelCase				)

							_snake_case       :					Optional[Any]				       =   {
							    "foo": 1_2,
							    "bar": 3.14,
							    "baz": "42",
							    "flag": True,
							}
							with tempfile.TemporaryDirectory() as tmp_dir:
												_snake_case       :					List[Any]				       =   os.path.join(__lowerCamelCase ,						"temp_yaml"				)
												os.mkdir(__lowerCamelCase				)
												with open(temp_local_path + ".yaml" ,						"w+"				) as f:
																	yaml.dump(__lowerCamelCase ,						__lowerCamelCase				)
												_snake_case       :					Any				       =   parser.parse_yaml_file(Path(temp_local_path + ".yaml"				)				)[0]
							_snake_case       :					Tuple				       =   BasicExample(**__lowerCamelCase				)
							self.assertEqual(__lowerCamelCase ,						__lowerCamelCase				)







		def        lowercase       (    self				)      ->      int:


							'''simple docstring'''

							_snake_case       :					Any				       =   HfArgumentParser(__lowerCamelCase				)
							self.assertIsNotNone(__lowerCamelCase				)






import warnings

from ...utils import logging
from .image_processing_videomae import VideoMAEImageProcessor


__lowerCAmelCase :str     =    logging.get_logger(__name__)






class        _a(    __A    ):







		def __init__(    self ,						*__snake_case ,						**__snake_case				)      ->      None:


							'''simple docstring'''

							warnings.warn(
							    "The class VideoMAEFeatureExtractor is deprecated and will be removed in version 5 of Transformers."
							    " Please use VideoMAEImageProcessor instead." ,						__snake_case ,						)
							super().__init__(*__snake_case ,						**__snake_case				)