


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, 1_0)
def        UpperCamelCase_(				_A   :Union[str, Any]=None				,     _A   :List[Any]=None  )->		Dict:
   return field(default_factory=lambda: default				,     metadata=__snake_case  )







@dataclass
class        lowerCamelCase__	:






   """simple docstring"""






   _UpperCamelCase		:					Any    =		42
   _UpperCamelCase		:					Tuple    =		42
   _UpperCamelCase		:					Optional[Any]    =		42
   _UpperCamelCase		:					List[Any]    =		42







@dataclass
class        lowerCamelCase__	:






   """simple docstring"""






   _UpperCamelCase		:					Optional[Any]    =		42
   _UpperCamelCase		:					Dict    =		field(default='toto'					,	metadata={'help': 'help message'}      )







@dataclass
class        lowerCamelCase__	:






   """simple docstring"""






   _UpperCamelCase		:					str    =		False
   _UpperCamelCase		:					Optional[int]    =		True
   _UpperCamelCase		:					Dict    =		None







class        lowerCamelCase__	(							__lowercase      ):






   """simple docstring"""






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







class        lowerCamelCase__	(							__lowercase      ):






   """simple docstring"""






   _UpperCamelCase		:					Tuple    =		'titi'
   _UpperCamelCase		:					List[str]    =		'toto'
   _UpperCamelCase		:					Dict    =		42







@dataclass
class        lowerCamelCase__	:






   """simple docstring"""






   _UpperCamelCase		:					Optional[Any]    =		'toto'




   def 				snake_case__				(							self     ):

      '''simple docstring'''


      UpperCamelCase__					=       BasicEnum(self.foo     )







@dataclass
class        lowerCamelCase__	:






   """simple docstring"""






   _UpperCamelCase		:					int    =		'toto'




   def 				snake_case__				(							self     ):

      '''simple docstring'''


      UpperCamelCase__					=       MixedTypeEnum(self.foo     )







@dataclass
class        lowerCamelCase__	:






   """simple docstring"""






   _UpperCamelCase		:					str    =		None
   _UpperCamelCase		:					List[str]    =		field(default=__lowercase					,	metadata={'help': 'help message'}      )
   _UpperCamelCase		:					Tuple    =		None
   _UpperCamelCase		:					List[str]    =		list_field(default=[]      )
   _UpperCamelCase		:					List[str]    =		list_field(default=[]      )







@dataclass
class        lowerCamelCase__	:






   """simple docstring"""






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







@dataclass
class        lowerCamelCase__	:






   """simple docstring"""






   _UpperCamelCase		:					str    =		field()
   _UpperCamelCase		:					Optional[int]    =		field()
   _UpperCamelCase		:					Optional[Any]    =		field()




   def 				snake_case__				(							self     ):

      '''simple docstring'''


      UpperCamelCase__					=       BasicEnum(self.required_enum     )







@dataclass
class        lowerCamelCase__	:






   """simple docstring"""






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


if is_python_no_less_than_3_10:







      @dataclass
      class        lowerCamelCase__	:






         """simple docstring"""






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







      @dataclass
      class        lowerCamelCase__	:






         """simple docstring"""






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







class        lowerCamelCase__	(							unittest.TestCase      ):






   """simple docstring"""






   def 				snake_case__				(							self      ,						snake_case      ,						snake_case     ):

      '''simple docstring'''


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

         self.assertEqual(_A      ,						_A     )




   def 				snake_case__				(							self     ):

      '''simple docstring'''


      UpperCamelCase__					=       HfArgumentParser(_A     )

      UpperCamelCase__					=       argparse.ArgumentParser()
      expected.add_argument("--foo"      ,						type=_A      ,						required=_A     )
      expected.add_argument("--bar"      ,						type=_A      ,						required=_A     )
      expected.add_argument("--baz"      ,						type=_A      ,						required=_A     )
      expected.add_argument("--flag"      ,						type=_A      ,						default=_A      ,						const=_A      ,						nargs="?"     )
      self.argparsersEqual(_A      ,						_A     )

      UpperCamelCase__					=       ["--foo", "1", "--baz", "quux", "--bar", "0.5"]
      ((UpperCamelCase__						),      						)					=       parser.parse_args_into_dataclasses(_A      ,						look_for_args_file=_A     )
      self.assertFalse(example.flag     )




   def 				snake_case__				(							self     ):

      '''simple docstring'''


      UpperCamelCase__					=       HfArgumentParser(_A     )

      UpperCamelCase__					=       argparse.ArgumentParser()
      expected.add_argument("--foo"      ,						default=42      ,						type=_A     )
      expected.add_argument("--baz"      ,						default="toto"      ,						type=_A      ,						help="help message"     )
      self.argparsersEqual(_A      ,						_A     )




   def 				snake_case__				(							self     ):

      '''simple docstring'''


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

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

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

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

         UpperCamelCase__					=       parser.parse_args(["--foo", "--no_baz"]     )
         self.assertEqual(_A      ,						Namespace(foo=_A      ,						baz=_A      ,						opt=_A     )     )

         UpperCamelCase__					=       parser.parse_args(["--foo", "--baz"]     )
         self.assertEqual(_A      ,						Namespace(foo=_A      ,						baz=_A      ,						opt=_A     )     )

         UpperCamelCase__					=       parser.parse_args(["--foo", "True", "--baz", "True", "--opt", "True"]     )
         self.assertEqual(_A      ,						Namespace(foo=_A      ,						baz=_A      ,						opt=_A     )     )

         UpperCamelCase__					=       parser.parse_args(["--foo", "False", "--baz", "False", "--opt", "False"]     )
         self.assertEqual(_A      ,						Namespace(foo=_A      ,						baz=_A      ,						opt=_A     )     )




   def 				snake_case__				(							self     ):

      '''simple docstring'''


      UpperCamelCase__					=       HfArgumentParser(_A     )

      UpperCamelCase__					=       argparse.ArgumentParser()
      expected.add_argument(
          "--foo"      ,						default="toto"      ,						choices=["titi", "toto", 42]      ,						type=make_choice_type_function(["titi", "toto", 42]     )      ,						)
      self.argparsersEqual(_A      ,						_A     )

      UpperCamelCase__					=       parser.parse_args([]     )
      self.assertEqual(args.foo      ,						"toto"     )
      UpperCamelCase__					=       parser.parse_args_into_dataclasses([]     )[0]
      self.assertEqual(enum_ex.foo      ,						MixedTypeEnum.toto     )

      UpperCamelCase__					=       parser.parse_args(["--foo", "titi"]     )
      self.assertEqual(args.foo      ,						"titi"     )
      UpperCamelCase__					=       parser.parse_args_into_dataclasses(["--foo", "titi"]     )[0]
      self.assertEqual(enum_ex.foo      ,						MixedTypeEnum.titi     )

      UpperCamelCase__					=       parser.parse_args(["--foo", "42"]     )
      self.assertEqual(args.foo      ,						42     )
      UpperCamelCase__					=       parser.parse_args_into_dataclasses(["--foo", "42"]     )[0]
      self.assertEqual(enum_ex.foo      ,						MixedTypeEnum.fourtytwo     )




   def 				snake_case__				(							self     ):

      '''simple docstring'''


      @dataclass
      class        lowerCamelCase__	:






         """simple docstring"""






         _UpperCamelCase		:					List[str]    =		'toto'



      UpperCamelCase__					=       HfArgumentParser(_A     )

      UpperCamelCase__					=       argparse.ArgumentParser()
      expected.add_argument(
          "--foo"      ,						default="toto"      ,						choices=("titi", "toto", 42)      ,						type=make_choice_type_function(["titi", "toto", 42]     )      ,						)
      self.argparsersEqual(_A      ,						_A     )

      UpperCamelCase__					=       parser.parse_args([]     )
      self.assertEqual(args.foo      ,						"toto"     )

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

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




   def 				snake_case__				(							self     ):

      '''simple docstring'''


      UpperCamelCase__					=       HfArgumentParser(_A     )

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

      self.argparsersEqual(_A      ,						_A     )

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

      UpperCamelCase__					=       parser.parse_args("--foo_int 1 --bar_int 2 3 --foo_str a b c --foo_float 0.1 0.7".split()     )
      self.assertEqual(_A      ,						Namespace(foo_int=[1]      ,						bar_int=[2, 3]      ,						foo_str=["a", "b", "c"]      ,						foo_float=[0.1, 0.7]     )     )




   def 				snake_case__				(							self     ):

      '''simple docstring'''


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

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

      for dataclass_type in dataclass_types:
         UpperCamelCase__					=       HfArgumentParser(_A     )

         self.argparsersEqual(_A      ,						_A     )

         UpperCamelCase__					=       parser.parse_args([]     )
         self.assertEqual(_A      ,						Namespace(foo=_A      ,						bar=_A      ,						baz=_A      ,						ces=[]      ,						des=[]     )     )

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




   def 				snake_case__				(							self     ):

      '''simple docstring'''


      UpperCamelCase__					=       HfArgumentParser(_A     )

      UpperCamelCase__					=       argparse.ArgumentParser()
      expected.add_argument("--required_list"      ,						nargs="+"      ,						type=_A      ,						required=_A     )
      expected.add_argument("--required_str"      ,						type=_A      ,						required=_A     )
      expected.add_argument(
          "--required_enum"      ,						type=make_choice_type_function(["titi", "toto"]     )      ,						choices=["titi", "toto"]      ,						required=_A      ,						)
      self.argparsersEqual(_A      ,						_A     )




   def 				snake_case__				(							self     ):

      '''simple docstring'''


      UpperCamelCase__					=       HfArgumentParser(_A     )

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




   def 				snake_case__				(							self     ):

      '''simple docstring'''


      UpperCamelCase__					=       HfArgumentParser(_A     )

      UpperCamelCase__					=       {
          "foo": 12,
          "bar": 3.14,
          "baz": "42",
          "flag": True,
      }

      UpperCamelCase__					=       parser.parse_dict(_A     )[0]
      UpperCamelCase__					=       BasicExample(**_A     )
      self.assertEqual(_A      ,						_A     )




   def 				snake_case__				(							self     ):

      '''simple docstring'''


      UpperCamelCase__					=       HfArgumentParser(_A     )

      UpperCamelCase__					=       {
          "foo": 12,
          "bar": 3.14,
          "baz": "42",
          "flag": True,
          "extra": 42,
      }

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




   def 				snake_case__				(							self     ):

      '''simple docstring'''


      UpperCamelCase__					=       HfArgumentParser(_A     )

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

      UpperCamelCase__					=       BasicExample(**_A     )
      self.assertEqual(_A      ,						_A     )




   def 				snake_case__				(							self     ):

      '''simple docstring'''


      UpperCamelCase__					=       HfArgumentParser(_A     )

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







   def 				snake_case__				(							self     ):

      '''simple docstring'''


      UpperCamelCase__					=       HfArgumentParser(_A     )
      self.assertIsNotNone(_A     )






from typing import Any







class        lowerCamelCase__	:






			"""simple docstring"""






			def __init__(							self      ,						snake_case     ):

						'''simple docstring'''


						UpperCamelCase__					=       data
						UpperCamelCase__					=       None







class        lowerCamelCase__	:






			"""simple docstring"""






			def __init__(							self     ):

						'''simple docstring'''


						UpperCamelCase__					=       None




			def 				snake_case__				(							self     ):

						'''simple docstring'''


						UpperCamelCase__					=       self.head
						while temp is not None:
									print(temp.data      ,						end=" "     )
									UpperCamelCase__					=       temp.next
						print()




			def 				snake_case__				(							self      ,						snake_case     ):

						'''simple docstring'''


						UpperCamelCase__					=       Node(snake_case     )
						UpperCamelCase__					=       self.head
						UpperCamelCase__					=       new_node







			def 				snake_case__				(							self      ,						snake_case      ,						snake_case     ):

						'''simple docstring'''


						if node_data_a == node_data_a:
									return
						else:
									UpperCamelCase__					=       self.head
									while node_a is not None and node_a.data != node_data_a:
												UpperCamelCase__					=       node_a.next

									UpperCamelCase__					=       self.head
									while node_a is not None and node_a.data != node_data_a:
												UpperCamelCase__					=       node_a.next

									if node_a is None or node_a is None:
												return

									UpperCamelCase__,      UpperCamelCase__					=       node_a.data, node_a.data


if __name__ == "__main__":
						__UpperCamelCase    		=       LinkedList()
						for i in range(5, 0, -1):
												ll.push(i)

						ll.print_list()

						ll.swap_nodes(1, 4)
						print('After swapping')
						ll.print_list()


