






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

def   snake_case (UpperCAmelCase__=None     ,   UpperCAmelCase__=None  )	->    Tuple:
		return field(default_factory=lambda: default     ,   metadata=SCREAMING_SNAKE_CASE__  )




@dataclass
class     _lowerCAmelCase:





							"""simple docstring"""







							a    :		Optional[int]									=42
							a    :		List[str]									=42
							a    :		Optional[int]									=42
							a    :		Optional[Any]									=42







@dataclass
class     _lowerCAmelCase:





							"""simple docstring"""







							a    :		List[str]									=42
							a    :		Union[str, Any]									=field(default='''toto'''							,     metadata={'''help''': '''help message'''} )







@dataclass
class     _lowerCAmelCase:





							"""simple docstring"""







							a    :		Tuple									=False
							a    :		Union[str, Any]									=True
							a    :		str									=None







class     _lowerCAmelCase(	__SCREAMING_SNAKE_CASE ):





							"""simple docstring"""







							a    :		List[Any]									='''titi'''
							a    :		Optional[Any]									='''toto'''







class     _lowerCAmelCase(	__SCREAMING_SNAKE_CASE ):





							"""simple docstring"""







							a    :		List[str]									='''titi'''
							a    :		Union[str, Any]									='''toto'''
							a    :		Any									=42







@dataclass
class     _lowerCAmelCase:





							"""simple docstring"""







							a    :		List[str]									='''toto'''





							def       _a   ( self							):
									UpperCamelCase_: Any   				=    BasicEnum(self.foo							)







@dataclass
class     _lowerCAmelCase:





							"""simple docstring"""







							a    :		int									='''toto'''





							def       _a   ( self							):
									UpperCamelCase_: int   				=    MixedTypeEnum(self.foo							)







@dataclass
class     _lowerCAmelCase:





							"""simple docstring"""







							a    :		List[str]									=None
							a    :		Optional[Any]									=field(default=__SCREAMING_SNAKE_CASE							,     metadata={'''help''': '''help message'''} )
							a    :		Optional[Any]									=None
							a    :		Optional[int]									=list_field(default=[] )
							a    :		Optional[int]									=list_field(default=[] )







@dataclass
class     _lowerCAmelCase:





							"""simple docstring"""







							a    :		Union[str, Any]									=list_field(default=[] )
							a    :		Any									=list_field(default=[1, 2, 3] )
							a    :		Optional[Any]									=list_field(default=['''Hallo''', '''Bonjour''', '''Hello'''] )
							a    :		List[str]									=list_field(default=[0.1, 0.2, 0.3] )







@dataclass
class     _lowerCAmelCase:





							"""simple docstring"""







							a    :		Optional[int]									=field()
							a    :		str									=field()
							a    :		List[Any]									=field()





							def       _a   ( self							):
									UpperCamelCase_: List[Any]   				=    BasicEnum(self.required_enum							)







@dataclass
class     _lowerCAmelCase:





							"""simple docstring"""







							a    :		List[Any]									=42
							a    :		Optional[int]									=field()
							a    :		Any									=None
							a    :		Dict									=field(default='''toto'''							,     metadata={'''help''': '''help message'''} )
							a    :		Tuple									=list_field(default=['''Hallo''', '''Bonjour''', '''Hello'''] )


if is_python_no_less_than_3_10:




			@dataclass
			class     _lowerCAmelCase:





										"""simple docstring"""







										a    :		Any									=False
										a    :		List[Any]									=True
										a    :		Union[str, Any]									=None







			@dataclass
			class     _lowerCAmelCase:





										"""simple docstring"""







										a    :		Optional[int]									=None
										a    :		Union[str, Any]									=field(default=__SCREAMING_SNAKE_CASE							,     metadata={'''help''': '''help message'''} )
										a    :		Optional[int]									=None
										a    :		int									=list_field(default=[] )
										a    :		List[Any]									=list_field(default=[] )




class     _lowerCAmelCase(	unittest.TestCase ):





							"""simple docstring"""







							def       _a   ( self  ,      _lowerCamelCase  ,      _lowerCamelCase							):
									self.assertEqual(len(a._actions							)  ,      len(b._actions							)							)
									for x, y in zip(a._actions  ,      b._actions							):
											UpperCamelCase_: List[Any]   				=    {k: v for k, v in vars(UpperCamelCase__							).items() if k != '''container'''}
											UpperCamelCase_: List[Any]   				=    {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							):
									UpperCamelCase_: Dict   				=    HfArgumentParser(UpperCamelCase__							)

									UpperCamelCase_: int   				=    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__							)

									UpperCamelCase_: Any   				=    ['''--foo''', '''1''', '''--baz''', '''quux''', '''--bar''', '''0.5''']
									(UpperCamelCase_): Tuple   				=    parser.parse_args_into_dataclasses(UpperCamelCase__  ,      look_for_args_file=UpperCamelCase__							)
									self.assertFalse(example.flag							)





							def       _a   ( self							):
									UpperCamelCase_: Optional[Any]   				=    HfArgumentParser(UpperCamelCase__							)

									UpperCamelCase_: Optional[int]   				=    argparse.ArgumentParser()
									expected.add_argument('--foo'  ,      default=4_2  ,      type=UpperCamelCase__							)
									expected.add_argument('--baz'  ,      default='toto'  ,      type=UpperCamelCase__  ,      help='help message'							)
									self.argparsersEqual(UpperCamelCase__  ,      UpperCamelCase__							)





							def       _a   ( self							):
									UpperCamelCase_: Any   				=    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__							)

									UpperCamelCase_: str   				=    [WithDefaultBoolExample]
									if is_python_no_less_than_3_10:
											dataclass_types.append(UpperCamelCase__							)

									for dataclass_type in dataclass_types:
											UpperCamelCase_: Tuple   				=    HfArgumentParser(UpperCamelCase__							)
											self.argparsersEqual(UpperCamelCase__  ,      UpperCamelCase__							)

											UpperCamelCase_: Tuple   				=    parser.parse_args([]							)
											self.assertEqual(UpperCamelCase__  ,      Namespace(foo=UpperCamelCase__  ,      baz=UpperCamelCase__  ,      opt=UpperCamelCase__							)							)

											UpperCamelCase_: Any   				=    parser.parse_args(['--foo', '--no_baz']							)
											self.assertEqual(UpperCamelCase__  ,      Namespace(foo=UpperCamelCase__  ,      baz=UpperCamelCase__  ,      opt=UpperCamelCase__							)							)

											UpperCamelCase_: Optional[Any]   				=    parser.parse_args(['--foo', '--baz']							)
											self.assertEqual(UpperCamelCase__  ,      Namespace(foo=UpperCamelCase__  ,      baz=UpperCamelCase__  ,      opt=UpperCamelCase__							)							)

											UpperCamelCase_: int   				=    parser.parse_args(['--foo', 'True', '--baz', 'True', '--opt', 'True']							)
											self.assertEqual(UpperCamelCase__  ,      Namespace(foo=UpperCamelCase__  ,      baz=UpperCamelCase__  ,      opt=UpperCamelCase__							)							)

											UpperCamelCase_: int   				=    parser.parse_args(['--foo', 'False', '--baz', 'False', '--opt', 'False']							)
											self.assertEqual(UpperCamelCase__  ,      Namespace(foo=UpperCamelCase__  ,      baz=UpperCamelCase__  ,      opt=UpperCamelCase__							)							)





							def       _a   ( self							):
									UpperCamelCase_: Union[str, Any]   				=    HfArgumentParser(UpperCamelCase__							)

									UpperCamelCase_: Optional[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(UpperCamelCase__  ,      UpperCamelCase__							)

									UpperCamelCase_: List[Any]   				=    parser.parse_args([]							)
									self.assertEqual(args.foo  ,      'toto'							)
									UpperCamelCase_: Tuple   				=    parser.parse_args_into_dataclasses([]							)[0]
									self.assertEqual(enum_ex.foo  ,      MixedTypeEnum.toto							)

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

									UpperCamelCase_: Dict   				=    parser.parse_args(['--foo', '42']							)
									self.assertEqual(args.foo  ,      4_2							)
									UpperCamelCase_: Union[str, Any]   				=    parser.parse_args_into_dataclasses(['--foo', '42']							)[0]
									self.assertEqual(enum_ex.foo  ,      MixedTypeEnum.fourtytwo							)





							def       _a   ( self							):




									@dataclass
									class     _lowerCAmelCase:





																"""simple docstring"""







																a    :		Dict									='''toto'''







									UpperCamelCase_: int   				=    HfArgumentParser(UpperCamelCase__							)

									UpperCamelCase_: Optional[int]   				=    argparse.ArgumentParser()
									expected.add_argument(
									    '--foo'  ,      default='toto'  ,      choices=('titi', 'toto', 4_2)  ,      type=make_choice_type_function(['titi', 'toto', 4_2]							)  ,      )
									self.argparsersEqual(UpperCamelCase__  ,      UpperCamelCase__							)

									UpperCamelCase_: Tuple   				=    parser.parse_args([]							)
									self.assertEqual(args.foo  ,      'toto'							)

									UpperCamelCase_: List[Any]   				=    parser.parse_args(['--foo', 'titi']							)
									self.assertEqual(args.foo  ,      'titi'							)

									UpperCamelCase_: Tuple   				=    parser.parse_args(['--foo', '42']							)
									self.assertEqual(args.foo  ,      4_2							)





							def       _a   ( self							):
									UpperCamelCase_: Union[str, Any]   				=    HfArgumentParser(UpperCamelCase__							)

									UpperCamelCase_: 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__							)

									UpperCamelCase_: str   				=    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]							)  ,      )

									UpperCamelCase_: 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(UpperCamelCase__  ,      Namespace(foo_int=[1]  ,      bar_int=[2, 3]  ,      foo_str=['a', 'b', 'c']  ,      foo_float=[0.1, 0.7]							)							)





							def       _a   ( self							):
									UpperCamelCase_: 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__							)

									UpperCamelCase_: Any   				=    [OptionalExample]
									if is_python_no_less_than_3_10:
											dataclass_types.append(UpperCamelCase__							)

									for dataclass_type in dataclass_types:
											UpperCamelCase_: List[str]   				=    HfArgumentParser(UpperCamelCase__							)

											self.argparsersEqual(UpperCamelCase__  ,      UpperCamelCase__							)

											UpperCamelCase_: Union[str, Any]   				=    parser.parse_args([]							)
											self.assertEqual(UpperCamelCase__  ,      Namespace(foo=UpperCamelCase__  ,      bar=UpperCamelCase__  ,      baz=UpperCamelCase__  ,      ces=[]  ,      des=[]							)							)

											UpperCamelCase_: Any   				=    parser.parse_args('--foo 12 --bar 3.14 --baz 42 --ces a b c --des 1 2 3'.split()							)
											self.assertEqual(UpperCamelCase__  ,      Namespace(foo=1_2  ,      bar=3.1_4  ,      baz='42'  ,      ces=['a', 'b', 'c']  ,      des=[1, 2, 3]							)							)





							def       _a   ( self							):
									UpperCamelCase_: int   				=    HfArgumentParser(UpperCamelCase__							)

									UpperCamelCase_: Dict   				=    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							):
									UpperCamelCase_: Tuple   				=    HfArgumentParser(UpperCamelCase__							)

									UpperCamelCase_: Dict   				=    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							):
									UpperCamelCase_: Dict   				=    HfArgumentParser(UpperCamelCase__							)

									UpperCamelCase_: Any   				=    {
									    '''foo''': 1_2,
									    '''bar''': 3.1_4,
									    '''baz''': '''42''',
									    '''flag''': True,
									}

									UpperCamelCase_: Optional[int]   				=    parser.parse_dict(UpperCamelCase__							)[0]
									UpperCamelCase_: List[str]   				=    BasicExample(**UpperCamelCase__							)
									self.assertEqual(UpperCamelCase__  ,      UpperCamelCase__							)





							def       _a   ( self							):
									UpperCamelCase_: Dict   				=    HfArgumentParser(UpperCamelCase__							)

									UpperCamelCase_: Optional[Any]   				=    {
									    '''foo''': 1_2,
									    '''bar''': 3.1_4,
									    '''baz''': '''42''',
									    '''flag''': True,
									    '''extra''': 4_2,
									}

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





							def       _a   ( self							):
									UpperCamelCase_: str   				=    HfArgumentParser(UpperCamelCase__							)

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

									UpperCamelCase_: Optional[int]   				=    BasicExample(**UpperCamelCase__							)
									self.assertEqual(UpperCamelCase__  ,      UpperCamelCase__							)





							def       _a   ( self							):
									UpperCamelCase_: Tuple   				=    HfArgumentParser(UpperCamelCase__							)

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





							def       _a   ( self							):
									UpperCamelCase_: Union[str, Any]   				=    HfArgumentParser(UpperCamelCase__							)
									self.assertIsNotNone(UpperCamelCase__							)







def   snake_case (UpperCAmelCase__  )	->    int:
  assert isinstance(UpperCAmelCase__     ,   UpperCAmelCase__  ), F'''The input value of [n={number}] is not an integer'''

  if number == 1:
    return 2
  elif number < 1:
    UpperCamelCase_: List[Any]   				=    F'''The input value of [n={number}] has to be > 0'''
    raise ValueError(UpperCAmelCase__  )
  else:
    UpperCamelCase_: str   				=    sylvester(number - 1  )
    UpperCamelCase_: str   				=    num - 1
    UpperCamelCase_: Any   				=    num
    return lower * upper + 1


if __name__ == "__main__":
   print(F'''The 8th number in Sylvester\'s sequence: {sylvester(8)}''')