

"""simple docstring"""

import unittest
from pathlib import Path
from tempfile import TemporaryDirectory

from transformers import AutoConfig, TFGPTaLMHeadModel, is_keras_nlp_available, is_tf_available
from transformers.models.gpta.tokenization_gpta import GPTaTokenizer
from transformers.testing_utils import require_keras_nlp, require_tf, slow


if is_tf_available():
    import tensorflow as tf

if is_keras_nlp_available():
    from transformers.models.gpta import TFGPTaTokenizer


_UpperCamelCase		     =    ["""gpt2"""]
_UpperCamelCase		     =    """gpt2"""

if is_tf_available():






    class 			__a					(						tf.Module       ):





           """simple docstring"""


           def __init__(   self			,					snake_case   ):





            """simple docstring"""

            super().__init__()
            lowerCAmelCase__   :				Optional[int] 			=				tokenizer
            lowerCAmelCase__   :				Union[str, Any] 			=				AutoConfig.from_pretrained(snake_case   )
            lowerCAmelCase__   :				Dict 			=				TFGPTaLMHeadModel.from_config(snake_case   )






           @tf.function(input_signature=(tf.TensorSpec((None,)			,					tf.string			,					name="text"   ),)   )
           def 			SCREAMING_SNAKE_CASE_	(   self			,					snake_case   ):





            """simple docstring"""

            lowerCAmelCase__   :				int 			=				self.tokenizer(snake_case   )
            lowerCAmelCase__   :				Optional[Any] 			=				tokenized["input_ids"].to_tensor()

            lowerCAmelCase__   :				Optional[Any] 			=				tf.cast(input_ids_dense > 0			,					tf.intaa   )
            # input_mask = tf.reshape(input_mask, [-1, MAX_SEQ_LEN])

            lowerCAmelCase__   :				Optional[int] 			=				self.model(input_ids=snake_case			,					attention_mask=snake_case   )["logits"]

            return outputs






@require_tf
@require_keras_nlp
class 			__a					(						unittest.TestCase       ):





       """simple docstring"""


       def 			SCREAMING_SNAKE_CASE_	(   self   ):





        """simple docstring"""

        super().setUp()

        lowerCAmelCase__   :				Any 			=				[GPTaTokenizer.from_pretrained(snake_case   ) for checkpoint in (TOKENIZER_CHECKPOINTS)]
        lowerCAmelCase__   :				int 			=				[TFGPTaTokenizer.from_pretrained(snake_case   ) for checkpoint in TOKENIZER_CHECKPOINTS]
        assert len(self.tokenizers   ) == len(self.tf_tokenizers   )

        lowerCAmelCase__   :				Any 			=				[
            "This is a straightforward English test sentence.",
            "This one has some weird characters\rto\nsee\r\nif  those\u00E9break things.",
            "Now we're going to add some Chinese: 一 二 三 一二三",
            "And some much more rare Chinese: 齉 堃 齉堃",
            "Je vais aussi écrire en français pour tester les accents",
            "Classical Irish also has some unusual characters, so in they go: Gaelaċ, ꝼ",
        ]
        lowerCAmelCase__   :				List[str] 			=				list(zip(self.test_sentences			,					self.test_sentences[::-1]   )   )






       def 			SCREAMING_SNAKE_CASE_	(   self   ):





        """simple docstring"""

        for tokenizer, tf_tokenizer in zip(self.tokenizers			,					self.tf_tokenizers   ):
         for test_inputs in self.test_sentences:
          lowerCAmelCase__   :				int 			=				tokenizer([test_inputs]			,					return_tensors="tf"   )
          lowerCAmelCase__   :				int 			=				tf_tokenizer([test_inputs]   )

          for key in python_outputs.keys():
           # convert them to numpy to avoid messing with ragged tensors
           lowerCAmelCase__   :				str 			=				python_outputs[key].numpy()
           lowerCAmelCase__   :				str 			=				tf_outputs[key].numpy()

           self.assertTrue(tf.reduce_all(python_outputs_values.shape == tf_outputs_values.shape   )   )
           self.assertTrue(tf.reduce_all(tf.cast(snake_case			,					tf.intaa   ) == tf_outputs_values   )   )






       @slow
       def 			SCREAMING_SNAKE_CASE_	(   self   ):





        """simple docstring"""

        for tf_tokenizer in self.tf_tokenizers:
         lowerCAmelCase__   :				Union[str, Any] 			=				tf.function(snake_case   )
         for test_inputs in self.test_sentences:
          lowerCAmelCase__   :				List[str] 			=				tf.constant(snake_case   )
          lowerCAmelCase__   :				List[str] 			=				compiled_tokenizer(snake_case   )
          lowerCAmelCase__   :				str 			=				tf_tokenizer(snake_case   )

          for key in eager_outputs.keys():
           self.assertTrue(tf.reduce_all(eager_outputs[key] == compiled_outputs[key]   )   )






       @slow
       def 			SCREAMING_SNAKE_CASE_	(   self   ):





        """simple docstring"""

        for tf_tokenizer in self.tf_tokenizers:
         lowerCAmelCase__   :				str 			=				ModelToSave(tokenizer=snake_case   )
         lowerCAmelCase__   :				Union[str, Any] 			=				tf.convert_to_tensor([self.test_sentences[0]]   )
         lowerCAmelCase__   :				Tuple 			=				model.serving(snake_case   )  # Build model with some sample inputs
         with TemporaryDirectory() as tempdir:
          lowerCAmelCase__   :				Any 			=				Path(snake_case   ) / "saved.model"
          tf.saved_model.save(snake_case			,					snake_case			,					signatures={"serving_default": model.serving}   )
          lowerCAmelCase__   :				List[str] 			=				tf.saved_model.load(snake_case   )
         lowerCAmelCase__   :				List[Any] 			=				loaded_model.signatures["serving_default"](snake_case   )["output_0"]
         # We may see small differences because the loaded model is compiled, so we need an epsilon for the test
         self.assertTrue(tf.reduce_all(out == loaded_output   )   )






       @slow
       def 			SCREAMING_SNAKE_CASE_	(   self   ):





        """simple docstring"""

        for tf_tokenizer in self.tf_tokenizers:
         lowerCAmelCase__   :				Union[str, Any] 			=				tf.convert_to_tensor([self.test_sentences[0]]   )
         lowerCAmelCase__   :				List[Any] 			=				tf_tokenizer(snake_case   )  # Build model with some sample inputs

         lowerCAmelCase__   :				Any 			=				tf_tokenizer.get_config()
         lowerCAmelCase__   :				Optional[int] 			=				TFGPTaTokenizer.from_config(snake_case   )
         lowerCAmelCase__   :				Any 			=				model_from_config(snake_case   )

         for key in from_config_output.keys():
          self.assertTrue(tf.reduce_all(from_config_output[key] == out[key]   )   )






       @slow
       def 			SCREAMING_SNAKE_CASE_	(   self   ):





        """simple docstring"""

        for tf_tokenizer in self.tf_tokenizers:
         # for the test to run
         lowerCAmelCase__   :				Dict 			=				123_123

         for max_length in [3, 5, 1_024]:
          lowerCAmelCase__   :				Tuple 			=				tf.convert_to_tensor([self.test_sentences[0]]   )
          lowerCAmelCase__   :				Any 			=				tf_tokenizer(snake_case			,					max_length=snake_case   )

          lowerCAmelCase__   :				Any 			=				out["input_ids"].numpy().shape[1]

          assert out_length == max_length









"""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, 1_0)



def       SCREAMING_SNAKE_CASE							( lowercase__=None					,					lowercase__=None   )			->						List[Any]:
 return field(default_factory=lambda: default					,					metadata=lowercase__   )






@dataclass
class 			__a					:





       """simple docstring"""


       __UpperCamelCase					:      int
       __UpperCamelCase					:      float
       __UpperCamelCase					:      str
       __UpperCamelCase					:      bool






@dataclass
class 			__a					:





       """simple docstring"""


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






@dataclass
class 			__a					:





       """simple docstring"""


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






class 			__a					(						__magic_name__       ):





       """simple docstring"""


       __UpperCamelCase					:      List[str]    =						'titi'
       __UpperCamelCase					:      Tuple    =						'toto'






class 			__a					(						__magic_name__       ):





       """simple docstring"""


       __UpperCamelCase					:      Tuple    =						'titi'
       __UpperCamelCase					:      List[Any]    =						'toto'
       __UpperCamelCase					:      List[str]    =						42






@dataclass
class 			__a					:





       """simple docstring"""


       __UpperCamelCase					:      BasicEnum    =						"toto"






       def 			SCREAMING_SNAKE_CASE_	(   self   ):





        """simple docstring"""

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






@dataclass
class 			__a					:





       """simple docstring"""


       __UpperCamelCase					:      MixedTypeEnum    =						"toto"






       def 			SCREAMING_SNAKE_CASE_	(   self   ):





        """simple docstring"""

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






@dataclass
class 			__a					:





       """simple docstring"""


       __UpperCamelCase					:      Optional[int]    =						None
       __UpperCamelCase					:      Optional[float]    =						field(default=__magic_name__       ,	metadata={'help': 'help message'}       )
       __UpperCamelCase					:      Optional[str]    =						None
       __UpperCamelCase					:      Optional[List[str]]    =						list_field(default=[]       )
       __UpperCamelCase					:      Optional[List[int]]    =						list_field(default=[]       )






@dataclass
class 			__a					:





       """simple docstring"""


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






@dataclass
class 			__a					:





       """simple docstring"""


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






       def 			SCREAMING_SNAKE_CASE_	(   self   ):





        """simple docstring"""

        lowerCAmelCase__   :				Optional[Any] 			=				BasicEnum(self.required_enum   )






@dataclass
class 			__a					:





       """simple docstring"""


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


if is_python_no_less_than_3_10:






    @dataclass
    class 			__a					:





           """simple docstring"""


           __UpperCamelCase					:      bool    =						False
           __UpperCamelCase					:      bool    =						True
           __UpperCamelCase					:      bool | None    =						None






    @dataclass
    class 			__a					:





           """simple docstring"""


           __UpperCamelCase					:      int | None    =						None
           __UpperCamelCase					:      float | None    =						field(default=__magic_name__       ,	metadata={'help': 'help message'}       )
           __UpperCamelCase					:      str | None    =						None
           __UpperCamelCase					:      list[str] | None    =						list_field(default=[]       )
           __UpperCamelCase					:      list[int] | None    =						list_field(default=[]       )






class 			__a					(						unittest.TestCase       ):





       """simple docstring"""


       def 			SCREAMING_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   ):
         lowerCAmelCase__   :				Union[str, Any] 			=				{k: v for k, v in vars(snake_case   ).items() if k != "container"}
         lowerCAmelCase__   :				Union[str, Any] 			=				{k: v for k, v in vars(snake_case   ).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"			,					snake_case   ) and yy.get("choices"			,					snake_case   ):
          for expected_choice in yy["choices"] + xx["choices"]:
           self.assertEqual(xx["type"](snake_case   )			,					yy["type"](snake_case   )   )
          del xx["type"], yy["type"]

         self.assertEqual(snake_case			,					snake_case   )






       def 			SCREAMING_SNAKE_CASE_	(   self   ):





        """simple docstring"""

        lowerCAmelCase__   :				Union[str, Any] 			=				HfArgumentParser(snake_case   )

        lowerCAmelCase__   :				Optional[int] 			=				argparse.ArgumentParser()
        expected.add_argument("--foo"			,					type=snake_case			,					required=snake_case   )
        expected.add_argument("--bar"			,					type=snake_case			,					required=snake_case   )
        expected.add_argument("--baz"			,					type=snake_case			,					required=snake_case   )
        expected.add_argument("--flag"			,					type=snake_case			,					default=snake_case			,					const=snake_case			,					nargs="?"   )
        self.argparsersEqual(snake_case			,					snake_case   )

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






       def 			SCREAMING_SNAKE_CASE_	(   self   ):





        """simple docstring"""

        lowerCAmelCase__   :				Tuple 			=				HfArgumentParser(snake_case   )

        lowerCAmelCase__   :				Optional[int] 			=				argparse.ArgumentParser()
        expected.add_argument("--foo"			,					default=42			,					type=snake_case   )
        expected.add_argument("--baz"			,					default="toto"			,					type=snake_case			,					help="help message"   )
        self.argparsersEqual(snake_case			,					snake_case   )






       def 			SCREAMING_SNAKE_CASE_	(   self   ):





        """simple docstring"""

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

        lowerCAmelCase__   :				Optional[Any] 			=				[WithDefaultBoolExample]
        if is_python_no_less_than_3_10:
         dataclass_types.append(snake_case   )

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

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

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

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

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

         lowerCAmelCase__   :				Optional[int] 			=				parser.parse_args(["--foo", "False", "--baz", "False", "--opt", "False"]   )
         self.assertEqual(snake_case			,					Namespace(foo=snake_case			,					baz=snake_case			,					opt=snake_case   )   )






       def 			SCREAMING_SNAKE_CASE_	(   self   ):





        """simple docstring"""

        lowerCAmelCase__   :				Tuple 			=				HfArgumentParser(snake_case   )

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

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

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

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






       def 			SCREAMING_SNAKE_CASE_	(   self   ):





        """simple docstring"""

        @dataclass
        class 			__a					:





               """simple docstring"""


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




        lowerCAmelCase__   :				Dict 			=				HfArgumentParser(snake_case   )

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

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

        lowerCAmelCase__   :				Optional[int] 			=				parser.parse_args(["--foo", "titi"]   )
        self.assertEqual(args.foo			,					"titi"   )

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






       def 			SCREAMING_SNAKE_CASE_	(   self   ):





        """simple docstring"""

        lowerCAmelCase__   :				str 			=				HfArgumentParser(snake_case   )

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

        self.argparsersEqual(snake_case			,					snake_case   )

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

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






       def 			SCREAMING_SNAKE_CASE_	(   self   ):





        """simple docstring"""

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

        lowerCAmelCase__   :				Optional[Any] 			=				[OptionalExample]
        if is_python_no_less_than_3_10:
         dataclass_types.append(snake_case   )

        for dataclass_type in dataclass_types:
         lowerCAmelCase__   :				Tuple 			=				HfArgumentParser(snake_case   )

         self.argparsersEqual(snake_case			,					snake_case   )

         lowerCAmelCase__   :				Any 			=				parser.parse_args([]   )
         self.assertEqual(snake_case			,					Namespace(foo=snake_case			,					bar=snake_case			,					baz=snake_case			,					ces=[]			,					des=[]   )   )

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






       def 			SCREAMING_SNAKE_CASE_	(   self   ):





        """simple docstring"""

        lowerCAmelCase__   :				Optional[Any] 			=				HfArgumentParser(snake_case   )

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






       def 			SCREAMING_SNAKE_CASE_	(   self   ):





        """simple docstring"""

        lowerCAmelCase__   :				Dict 			=				HfArgumentParser(snake_case   )

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






       def 			SCREAMING_SNAKE_CASE_	(   self   ):





        """simple docstring"""

        lowerCAmelCase__   :				Any 			=				HfArgumentParser(snake_case   )

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

        lowerCAmelCase__   :				Tuple 			=				parser.parse_dict(snake_case   )[0]
        lowerCAmelCase__   :				Any 			=				BasicExample(**snake_case   )
        self.assertEqual(snake_case			,					snake_case   )






       def 			SCREAMING_SNAKE_CASE_	(   self   ):





        """simple docstring"""

        lowerCAmelCase__   :				Union[str, Any] 			=				HfArgumentParser(snake_case   )

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

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






       def 			SCREAMING_SNAKE_CASE_	(   self   ):





        """simple docstring"""

        lowerCAmelCase__   :				Union[str, Any] 			=				HfArgumentParser(snake_case   )

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

        lowerCAmelCase__   :				str 			=				BasicExample(**snake_case   )
        self.assertEqual(snake_case			,					snake_case   )






       def 			SCREAMING_SNAKE_CASE_	(   self   ):





        """simple docstring"""

        lowerCAmelCase__   :				str 			=				HfArgumentParser(snake_case   )

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






       def 			SCREAMING_SNAKE_CASE_	(   self   ):





        """simple docstring"""

        lowerCAmelCase__   :				Union[str, Any] 			=				HfArgumentParser(snake_case   )
        self.assertIsNotNone(snake_case   )






