


'''simple docstring'''


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


def 		_lowercase (SCREAMING_SNAKE_CASE=None       ,					SCREAMING_SNAKE_CASE=None							):




     '''simple docstring'''





     return field(default_factory=lambda: default       ,					metadata=SCREAMING_SNAKE_CASE							)







@dataclass
class 							__magic_name__	:

     """simple docstring"""






     lowerCamelCase__       						=				42
     lowerCamelCase__       						=				42
     lowerCamelCase__       						=				42
     lowerCamelCase__       						=				42







@dataclass
class 							__magic_name__	:

     """simple docstring"""






     lowerCamelCase__       						=				42
     lowerCamelCase__       						=				field(default='toto'    ,		metadata={'help': 'help message'} )







@dataclass
class 							__magic_name__	:

     """simple docstring"""






     lowerCamelCase__       						=				False
     lowerCamelCase__       						=				True
     lowerCamelCase__       						=				None







class 							__magic_name__	(       lowerCAmelCase ):

     """simple docstring"""






     lowerCamelCase__       						=				'titi'
     lowerCamelCase__       						=				'toto'







class 							__magic_name__	(       lowerCAmelCase ):

     """simple docstring"""






     lowerCamelCase__       						=				'titi'
     lowerCamelCase__       						=				'toto'
     lowerCamelCase__       						=				42







@dataclass
class 							__magic_name__	:

     """simple docstring"""






     lowerCamelCase__       						=				"toto"


     def lowerCAmelCase__  (   self		):


          '''simple docstring'''





          __A	:       str      =							BasicEnum(self.foo		)







@dataclass
class 							__magic_name__	:

     """simple docstring"""






     lowerCamelCase__       						=				"toto"


     def lowerCAmelCase__  (   self		):


          '''simple docstring'''





          __A	:       int      =							MixedTypeEnum(self.foo		)







@dataclass
class 							__magic_name__	:

     """simple docstring"""






     lowerCamelCase__       						=				None
     lowerCamelCase__       						=				field(default=lowerCAmelCase    ,		metadata={'help': 'help message'} )
     lowerCamelCase__       						=				None
     lowerCamelCase__       						=				list_field(default=[] )
     lowerCamelCase__       						=				list_field(default=[] )







@dataclass
class 							__magic_name__	:

     """simple docstring"""






     lowerCamelCase__       						=				list_field(default=[] )
     lowerCamelCase__       						=				list_field(default=[1, 2, 3] )
     lowerCamelCase__       						=				list_field(default=['Hallo', 'Bonjour', 'Hello'] )
     lowerCamelCase__       						=				list_field(default=[0.1, 0.2, 0.3] )







@dataclass
class 							__magic_name__	:

     """simple docstring"""






     lowerCamelCase__       						=				field()
     lowerCamelCase__       						=				field()
     lowerCamelCase__       						=				field()


     def lowerCAmelCase__  (   self		):


          '''simple docstring'''





          __A	:       int      =							BasicEnum(self.required_enum		)







@dataclass
class 							__magic_name__	:

     """simple docstring"""






     lowerCamelCase__       						=				42
     lowerCamelCase__       						=				field()
     lowerCamelCase__       						=				None
     lowerCamelCase__       						=				field(default='toto'    ,		metadata={'help': 'help message'} )
     lowerCamelCase__       						=				list_field(default=['Hallo', 'Bonjour', 'Hello'] )


if is_python_no_less_than_3_10:







      @dataclass
      class 							__magic_name__	:

           """simple docstring"""






           lowerCamelCase__       						=				False
           lowerCamelCase__       						=				True
           lowerCamelCase__       						=				None







      @dataclass
      class 							__magic_name__	:

           """simple docstring"""






           lowerCamelCase__       						=				None
           lowerCamelCase__       						=				field(default=lowerCAmelCase    ,		metadata={'help': 'help message'} )
           lowerCamelCase__       						=				None
           lowerCamelCase__       						=				list_field(default=[] )
           lowerCamelCase__       						=				list_field(default=[] )







class 							__magic_name__	(       unittest.TestCase ):

     """simple docstring"""






     def lowerCAmelCase__  (   self			,     lowerCamelCase			,     lowerCamelCase		):


          '''simple docstring'''





          self.assertEqual(len(a._actions		)			,     len(b._actions		)		)
          for x, y in zip(a._actions			,     b._actions		):
               __A	:       Union[str, Any]      =							{k: v for k, v in vars(lowerCamelCase		).items() if k != "container"}
               __A	:       Any      =							{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 lowerCAmelCase__  (   self		):


          '''simple docstring'''





          __A	:       str      =							HfArgumentParser(lowerCamelCase		)

          __A	:       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		)

          __A	:       Union[str, Any]      =							["--foo", "1", "--baz", "quux", "--bar", "0.5"]
          ((__A)  ,)	:       Any      =							parser.parse_args_into_dataclasses(lowerCamelCase			,     look_for_args_file=lowerCamelCase		)
          self.assertFalse(example.flag		)


     def lowerCAmelCase__  (   self		):


          '''simple docstring'''





          __A	:       str      =							HfArgumentParser(lowerCamelCase		)

          __A	:       int      =							argparse.ArgumentParser()
          expected.add_argument("--foo"			,     default=42			,     type=lowerCamelCase		)
          expected.add_argument("--baz"			,     default="toto"			,     type=lowerCamelCase			,     help="help message"		)
          self.argparsersEqual(lowerCamelCase			,     lowerCamelCase		)


     def lowerCAmelCase__  (   self		):


          '''simple docstring'''





          __A	:       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		)

          __A	:       Any      =							[WithDefaultBoolExample]
          if is_python_no_less_than_3_10:
               dataclass_types.append(lowerCamelCase		)

          for dataclass_type in dataclass_types:
               __A	:       Optional[Any]      =							HfArgumentParser(lowerCamelCase		)
               self.argparsersEqual(lowerCamelCase			,     lowerCamelCase		)

               __A	:       List[Any]      =							parser.parse_args([]		)
               self.assertEqual(lowerCamelCase			,     Namespace(foo=lowerCamelCase			,     baz=lowerCamelCase			,     opt=lowerCamelCase		)		)

               __A	:       Optional[int]      =							parser.parse_args(["--foo", "--no_baz"]		)
               self.assertEqual(lowerCamelCase			,     Namespace(foo=lowerCamelCase			,     baz=lowerCamelCase			,     opt=lowerCamelCase		)		)

               __A	:       int      =							parser.parse_args(["--foo", "--baz"]		)
               self.assertEqual(lowerCamelCase			,     Namespace(foo=lowerCamelCase			,     baz=lowerCamelCase			,     opt=lowerCamelCase		)		)

               __A	:       str      =							parser.parse_args(["--foo", "True", "--baz", "True", "--opt", "True"]		)
               self.assertEqual(lowerCamelCase			,     Namespace(foo=lowerCamelCase			,     baz=lowerCamelCase			,     opt=lowerCamelCase		)		)

               __A	:       Optional[Any]      =							parser.parse_args(["--foo", "False", "--baz", "False", "--opt", "False"]		)
               self.assertEqual(lowerCamelCase			,     Namespace(foo=lowerCamelCase			,     baz=lowerCamelCase			,     opt=lowerCamelCase		)		)


     def lowerCAmelCase__  (   self		):


          '''simple docstring'''





          __A	:       Optional[int]      =							HfArgumentParser(lowerCamelCase		)

          __A	:       List[Any]      =							argparse.ArgumentParser()
          expected.add_argument(
              "--foo"			,     default="toto"			,     choices=["titi", "toto", 42]			,     type=make_choice_type_function(["titi", "toto", 42]		)			,     )
          self.argparsersEqual(lowerCamelCase			,     lowerCamelCase		)

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

          __A	:       Optional[Any]      =							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[Any]      =							parser.parse_args(["--foo", "42"]		)
          self.assertEqual(args.foo			,     42		)
          __A	:       int      =							parser.parse_args_into_dataclasses(["--foo", "42"]		)[0]
          self.assertEqual(enum_ex.foo			,     MixedTypeEnum.fourtytwo		)


     def lowerCAmelCase__  (   self		):


          '''simple docstring'''





          @dataclass
          class 							__magic_name__	:

               """simple docstring"""






               lowerCamelCase__       						=				"toto"


          __A	:       Dict      =							HfArgumentParser(lowerCamelCase		)

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

          __A	:       List[Any]      =							parser.parse_args([]		)
          self.assertEqual(args.foo			,     "toto"		)

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

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


     def lowerCAmelCase__  (   self		):


          '''simple docstring'''





          __A	:       List[str]      =							HfArgumentParser(lowerCamelCase		)

          __A	:       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		)

          __A	:       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]		)			,     )

          __A	:       List[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 lowerCAmelCase__  (   self		):


          '''simple docstring'''





          __A	:       Dict      =							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		)

          __A	:       List[str]      =							[OptionalExample]
          if is_python_no_less_than_3_10:
               dataclass_types.append(lowerCamelCase		)

          for dataclass_type in dataclass_types:
               __A	:       Dict      =							HfArgumentParser(lowerCamelCase		)

               self.argparsersEqual(lowerCamelCase			,     lowerCamelCase		)

               __A	:       Optional[int]      =							parser.parse_args([]		)
               self.assertEqual(lowerCamelCase			,     Namespace(foo=lowerCamelCase			,     bar=lowerCamelCase			,     baz=lowerCamelCase			,     ces=[]			,     des=[]		)		)

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


     def lowerCAmelCase__  (   self		):


          '''simple docstring'''





          __A	:       str      =							HfArgumentParser(lowerCamelCase		)

          __A	:       Dict      =							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 lowerCAmelCase__  (   self		):


          '''simple docstring'''





          __A	:       List[Any]      =							HfArgumentParser(lowerCamelCase		)

          __A	:       Union[str, 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 lowerCAmelCase__  (   self		):


          '''simple docstring'''





          __A	:       Tuple      =							HfArgumentParser(lowerCamelCase		)

          __A	:       Optional[Any]      =							{
              "foo": 12,
              "bar": 3.14,
              "baz": "42",
              "flag": True,
          }

          __A	:       Any      =							parser.parse_dict(lowerCamelCase		)[0]
          __A	:       Any      =							BasicExample(**lowerCamelCase		)
          self.assertEqual(lowerCamelCase			,     lowerCamelCase		)


     def lowerCAmelCase__  (   self		):


          '''simple docstring'''





          __A	:       Dict      =							HfArgumentParser(lowerCamelCase		)

          __A	:       List[Any]      =							{
              "foo": 12,
              "bar": 3.14,
              "baz": "42",
              "flag": True,
              "extra": 42,
          }

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


     def lowerCAmelCase__  (   self		):


          '''simple docstring'''





          __A	:       int      =							HfArgumentParser(lowerCamelCase		)

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

          __A	:       Union[str, Any]      =							BasicExample(**lowerCamelCase		)
          self.assertEqual(lowerCamelCase			,     lowerCamelCase		)


     def lowerCAmelCase__  (   self		):


          '''simple docstring'''





          __A	:       Optional[Any]      =							HfArgumentParser(lowerCamelCase		)

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


     def lowerCAmelCase__  (   self		):


          '''simple docstring'''





          __A	:       Union[str, Any]      =							HfArgumentParser(lowerCamelCase		)
          self.assertIsNotNone(lowerCamelCase		)





'''simple docstring'''


def 		_lowercase (SCREAMING_SNAKE_CASE       ,					SCREAMING_SNAKE_CASE = " "							):




     '''simple docstring'''





     __A	:       List[str]      =							[]

     __A	:       Tuple      =							0
     for index, char in enumerate(SCREAMING_SNAKE_CASE							):
          if char == separator:
               split_words.append(string[last_index:index]							)
               __A	:       Union[str, Any]      =							index + 1
          elif index + 1 == len(SCREAMING_SNAKE_CASE							):
               split_words.append(string[last_index : index + 1]							)
     return split_words


if __name__ == "__main__":
      from doctest import testmod

      testmod()

