




'''simple docstring'''







import unittest

from transformers import is_torch_available
from transformers.testing_utils import require_torch, slow, torch_device

from ...generation.test_utils import GenerationTesterMixin
from ...test_configuration_common import ConfigTester
from ...test_modeling_common import ModelTesterMixin, ids_tensor
from ...test_pipeline_mixin import PipelineTesterMixin


if is_torch_available():
      import torch

      from transformers import (
          OPENAI_GPT_PRETRAINED_MODEL_ARCHIVE_LIST,
          OpenAIGPTConfig,
          OpenAIGPTDoubleHeadsModel,
          OpenAIGPTForSequenceClassification,
          OpenAIGPTLMHeadModel,
          OpenAIGPTModel,
      )







class 					_a :





     '''simple docstring'''



     def __init__(				self							,__a							,__a=13							,__a=7							,__a=True							,__a=True							,__a=True							,__a=99							,__a=32							,__a=5							,__a=4							,__a=37							,__a="gelu"							,__a=0.1							,__a=0.1							,__a=512							,__a=16							,__a=2							,__a=0.02							,__a=3							,__a=4							,__a=None							,)      ->				List[Any]:
          snake_case			:      Optional[Any]        =			parent
          snake_case			:      int        =			batch_size
          snake_case			:      Union[str, Any]        =			seq_length
          snake_case			:      str        =			is_training
          snake_case			:      Tuple        =			use_token_type_ids
          snake_case			:      int        =			use_labels
          snake_case			:      str        =			vocab_size
          snake_case			:      Union[str, Any]        =			hidden_size
          snake_case			:      List[Any]        =			num_hidden_layers
          snake_case			:      Tuple        =			num_attention_heads
          snake_case			:      Any        =			intermediate_size
          snake_case			:      int        =			hidden_act
          snake_case			:      Any        =			hidden_dropout_prob
          snake_case			:      Union[str, Any]        =			attention_probs_dropout_prob
          snake_case			:      Any        =			max_position_embeddings
          snake_case			:      str        =			type_vocab_size
          snake_case			:      Any        =			type_sequence_label_size
          snake_case			:      Optional[Any]        =			initializer_range
          snake_case			:      int        =			num_labels
          snake_case			:      Tuple        =			num_choices
          snake_case			:      Optional[Any]        =			scope
          snake_case			:      Optional[int]        =			self.vocab_size - 1







     def 			snake_case_      (				self							)      ->				Any:
          snake_case			:      Optional[int]        =			ids_tensor([self.batch_size, self.seq_length]							,self.vocab_size							)

          snake_case			:      str        =			None
          if self.use_token_type_ids:
               snake_case			:      Union[str, Any]        =			ids_tensor([self.batch_size, self.seq_length]							,self.type_vocab_size							)

          snake_case			:      Any        =			None
          snake_case			:      List[Any]        =			None
          snake_case			:      Tuple        =			None
          if self.use_labels:
               snake_case			:      Optional[Any]        =			ids_tensor([self.batch_size]							,self.type_sequence_label_size							)
               snake_case			:      Optional[int]        =			ids_tensor([self.batch_size, self.seq_length]							,self.num_labels							)
               snake_case			:      Optional[Any]        =			ids_tensor([self.batch_size]							,self.num_choices							)

          snake_case			:      List[str]        =			OpenAIGPTConfig(
              vocab_size=self.vocab_size							,n_embd=self.hidden_size							,n_layer=self.num_hidden_layers							,n_head=self.num_attention_heads							,n_positions=self.max_position_embeddings							,pad_token_id=self.pad_token_id							,)

          snake_case			:      Optional[int]        =			ids_tensor([self.num_hidden_layers, self.num_attention_heads]							,2							)

          return (
              config,
              input_ids,
              head_mask,
              token_type_ids,
              sequence_labels,
              token_labels,
              choice_labels,
          )







     def 			snake_case_      (				self							,__a							,__a							,__a							,__a							,*__a							)      ->				List[Any]:
          snake_case			:      Optional[Any]        =			OpenAIGPTModel(config=__a							)
          model.to(__a							)
          model.eval()

          snake_case			:      Optional[Any]        =			model(__a							,token_type_ids=__a							,head_mask=__a							)
          snake_case			:      Any        =			model(__a							,token_type_ids=__a							)
          snake_case			:      Any        =			model(__a							)

          self.parent.assertEqual(result.last_hidden_state.shape							,(self.batch_size, self.seq_length, self.hidden_size)							)







     def 			snake_case_      (				self							,__a							,__a							,__a							,__a							,*__a							)      ->				Union[str, Any]:
          snake_case			:      List[str]        =			OpenAIGPTLMHeadModel(__a							)
          model.to(__a							)
          model.eval()

          snake_case			:      int        =			model(__a							,token_type_ids=__a							,labels=__a							)
          self.parent.assertEqual(result.loss.shape							,()							)
          self.parent.assertEqual(result.logits.shape							,(self.batch_size, self.seq_length, self.vocab_size)							)







     def 			snake_case_      (				self							,__a							,__a							,__a							,__a							,*__a							)      ->				Any:
          snake_case			:      Optional[int]        =			OpenAIGPTDoubleHeadsModel(__a							)
          model.to(__a							)
          model.eval()

          snake_case			:      Optional[Any]        =			model(__a							,token_type_ids=__a							,labels=__a							)
          self.parent.assertEqual(result.loss.shape							,()							)
          self.parent.assertEqual(result.logits.shape							,(self.batch_size, self.seq_length, self.vocab_size)							)







     def 			snake_case_      (				self							,__a							,__a							,__a							,__a							,*__a							)      ->				Optional[int]:
          snake_case			:      Any        =			self.num_labels
          snake_case			:      Tuple        =			OpenAIGPTForSequenceClassification(__a							)
          model.to(__a							)
          model.eval()

          snake_case			:      Tuple        =			ids_tensor([self.batch_size]							,self.type_sequence_label_size							)
          snake_case			:      Tuple        =			model(__a							,token_type_ids=__a							,labels=__a							)
          self.parent.assertEqual(result.logits.shape							,(self.batch_size, self.num_labels)							)







     def 			snake_case_      (				self							)      ->				Optional[Any]:
          snake_case			:      Union[str, Any]        =			self.prepare_config_and_inputs()
          (
              (
              snake_case
          ) ,		(
              snake_case
          ) ,		(
              snake_case
          ) ,		(
              snake_case
          ) ,		(
              snake_case
          ) ,		(
              snake_case
          ) ,		(
              snake_case
          ) ,		
          )			:      List[str]        =			config_and_inputs
          snake_case			:      str        =			{
              """input_ids""": input_ids,
              """token_type_ids""": token_type_ids,
              """head_mask""": head_mask,
          }

          return config, inputs_dict







@require_torch
class 					_a (a__,		a__,		a__,		unittest.TestCase	):





     '''simple docstring'''



     lowerCAmelCase_  :     Union[str, Any]          =					(
         (OpenAIGPTModel, OpenAIGPTLMHeadModel, OpenAIGPTDoubleHeadsModel, OpenAIGPTForSequenceClassification)
         if is_torch_available()
         else ()
     )
     lowerCAmelCase_  :     str          =					(
         (OpenAIGPTLMHeadModel,) if is_torch_available() else ()
     )  # TODO (PVP): Add Double HeadsModel when generate() function is changed accordingly
     lowerCAmelCase_  :     List[str]          =					(
         {
             """feature-extraction""": OpenAIGPTModel,
             """text-classification""": OpenAIGPTForSequenceClassification,
             """text-generation""": OpenAIGPTLMHeadModel,
             """zero-shot""": OpenAIGPTForSequenceClassification,
         }
         if is_torch_available()
         else {}
     )







     def 			snake_case_      (				self							,__a							,__a							,__a							,__a							,__a							)      ->				Union[str, Any]:
          if pipeline_test_casse_name == "ZeroShotClassificationPipelineTests":
               # Get `tokenizer does not have a padding token` error for both fast/slow tokenizers.
               # `OpenAIGPTConfig` was never used in pipeline tests, either because of a missing checkpoint or because a
               # tiny config could not be created.
               return True

          return False







     def 			snake_case_      (				self							,__a							,__a							,__a=False							)      ->				Any:
          snake_case			:      str        =			super()._prepare_for_class(__a							,__a							,return_labels=__a							)

          if return_labels:
               if model_class.__name__ == "OpenAIGPTDoubleHeadsModel":
                    snake_case			:      Dict        =			torch.zeros(
                        (self.model_tester.batch_size, self.model_tester.num_choices, self.model_tester.seq_length)							,dtype=torch.long							,device=__a							,)
                    snake_case			:      Dict        =			inputs_dict["""labels"""]
                    snake_case			:      Optional[int]        =			inputs_dict["""labels"""]
                    snake_case			:      Optional[int]        =			torch.zeros(
                        (self.model_tester.batch_size, self.model_tester.num_choices)							,dtype=torch.long							,device=__a							,)
                    snake_case			:      str        =			torch.zeros(
                        self.model_tester.batch_size							,dtype=torch.long							,device=__a							)
          return inputs_dict







     def 			snake_case_      (				self							)      ->				int:
          snake_case			:      Dict        =			OpenAIGPTModelTester(self							)
          snake_case			:      str        =			ConfigTester(self							,config_class=__a							,n_embd=37							)







     def 			snake_case_      (				self							)      ->				int:
          self.config_tester.run_common_tests()







     def 			snake_case_      (				self							)      ->				Optional[int]:
          snake_case			:      str        =			self.model_tester.prepare_config_and_inputs()
          self.model_tester.create_and_check_openai_gpt_model(*__a							)







     def 			snake_case_      (				self							)      ->				int:
          snake_case			:      int        =			self.model_tester.prepare_config_and_inputs()
          self.model_tester.create_and_check_lm_head_model(*__a							)







     def 			snake_case_      (				self							)      ->				Any:
          snake_case			:      Optional[int]        =			self.model_tester.prepare_config_and_inputs()
          self.model_tester.create_and_check_double_lm_head_model(*__a							)







     def 			snake_case_      (				self							)      ->				Optional[Any]:
          snake_case			:      Tuple        =			self.model_tester.prepare_config_and_inputs()
          self.model_tester.create_and_check_openai_gpt_for_sequence_classification(*__a							)







     @slow
     def 			snake_case_      (				self							)      ->				Optional[Any]:
          for model_name in OPENAI_GPT_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
               snake_case			:      Dict        =			OpenAIGPTModel.from_pretrained(__a							)
               self.assertIsNotNone(__a							)







@require_torch
class 					_a (unittest.TestCase	):





     '''simple docstring'''



     @slow
     def 			snake_case_      (				self							)      ->				Optional[int]:
          snake_case			:      List[str]        =			OpenAIGPTLMHeadModel.from_pretrained("""openai-gpt"""							)
          model.to(__a							)
          snake_case			:      Dict        =			torch.tensor([[481, 4_735, 544]]							,dtype=torch.long							,device=__a							)  # the president is
          snake_case			:      Union[str, Any]        =			[
              481,
              4_735,
              544,
              246,
              963,
              870,
              762,
              239,
              244,
              40_477,
              244,
              249,
              719,
              881,
              487,
              544,
              240,
              244,
              603,
              481,
          ]  # the president is a very good man. " \n " i\'m sure he is, " said the

          snake_case			:      Tuple        =			model.generate(__a							,do_sample=__a							)
          self.assertListEqual(output_ids[0].tolist()							,__a							)









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



def        lowerCamelCase__				(      __lowercase=None     ,   __lowercase=None				):
     return field(default_factory=lambda: default     ,   metadata=__lowercase				)







@dataclass
class 					_a :





     '''simple docstring'''



     lowerCAmelCase_  :     int
     lowerCAmelCase_  :     float
     lowerCAmelCase_  :     str
     lowerCAmelCase_  :     bool







@dataclass
class 					_a :





     '''simple docstring'''



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







@dataclass
class 					_a :





     '''simple docstring'''



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







class 					_a (a__	):





     '''simple docstring'''



     lowerCAmelCase_  :     int          =					"""titi"""
     lowerCAmelCase_  :     Optional[int]          =					"""toto"""







class 					_a (a__	):





     '''simple docstring'''



     lowerCAmelCase_  :     Any          =					"""titi"""
     lowerCAmelCase_  :     Dict          =					"""toto"""
     lowerCAmelCase_  :     int          =					42







@dataclass
class 					_a :





     '''simple docstring'''



     lowerCAmelCase_  :     BasicEnum          =					"toto"







     def 			snake_case_      (				self							)      ->				str:
          snake_case			:      Union[str, Any]        =			BasicEnum(self.foo							)







@dataclass
class 					_a :





     '''simple docstring'''



     lowerCAmelCase_  :     MixedTypeEnum          =					"toto"







     def 			snake_case_      (				self							)      ->				Tuple:
          snake_case			:      List[str]        =			MixedTypeEnum(self.foo							)







@dataclass
class 					_a :





     '''simple docstring'''



     lowerCAmelCase_  :     Optional[int]          =					None
     lowerCAmelCase_  :     Optional[float]          =					field(default=a__,		metadata={"""help""": """help message"""}	)
     lowerCAmelCase_  :     Optional[str]          =					None
     lowerCAmelCase_  :     Optional[List[str]]          =					list_field(default=[]	)
     lowerCAmelCase_  :     Optional[List[int]]          =					list_field(default=[]	)







@dataclass
class 					_a :





     '''simple docstring'''



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







@dataclass
class 					_a :





     '''simple docstring'''



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







     def 			snake_case_      (				self							)      ->				int:
          snake_case			:      Optional[int]        =			BasicEnum(self.required_enum							)







@dataclass
class 					_a :





     '''simple docstring'''



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


if is_python_no_less_than_3_10:







      @dataclass
      class 					_a :





           '''simple docstring'''



           lowerCAmelCase_  :     bool          =					False
           lowerCAmelCase_  :     bool          =					True
           lowerCAmelCase_  :     bool | None          =					None







      @dataclass
      class 					_a :





           '''simple docstring'''



           lowerCAmelCase_  :     int | None          =					None
           lowerCAmelCase_  :     float | None          =					field(default=a__,		metadata={"""help""": """help message"""}	)
           lowerCAmelCase_  :     str | None          =					None
           lowerCAmelCase_  :     list[str] | None          =					list_field(default=[]	)
           lowerCAmelCase_  :     list[int] | None          =					list_field(default=[]	)







class 					_a (unittest.TestCase	):





     '''simple docstring'''



     def 			snake_case_      (				self							,__a							,__a							)      ->				Optional[int]:
          self.assertEqual(len(a._actions							)							,len(b._actions							)							)
          for x, y in zip(a._actions							,b._actions							):
               snake_case			:      Optional[int]        =			{k: v for k, v in vars(__a							).items() if k != """container"""}
               snake_case			:      Tuple        =			{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							)      ->				int:
          snake_case			:      str        =			HfArgumentParser(__a							)

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

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







     def 			snake_case_      (				self							)      ->				int:
          snake_case			:      Optional[int]        =			HfArgumentParser(__a							)

          snake_case			:      str        =			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							)      ->				Optional[Any]:
          snake_case			:      Optional[int]        =			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							)

          snake_case			:      str        =			[WithDefaultBoolExample]
          if is_python_no_less_than_3_10:
               dataclass_types.append(__a							)

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

               snake_case			:      List[str]        =			parser.parse_args([]							)
               self.assertEqual(__a							,Namespace(foo=__a							,baz=__a							,opt=__a							)							)

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

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

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

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







     def 			snake_case_      (				self							)      ->				str:
          snake_case			:      Any        =			HfArgumentParser(__a							)

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

          snake_case			:      Any        =			parser.parse_args([]							)
          self.assertEqual(args.foo							,"""toto"""							)
          snake_case			:      str        =			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			:      Optional[Any]        =			parser.parse_args_into_dataclasses(["""--foo""", """titi"""]							)[0]
          self.assertEqual(enum_ex.foo							,MixedTypeEnum.titi							)

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







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







          @dataclass
          class 					_a :





               '''simple docstring'''



               lowerCAmelCase_  :     Literal["titi", "toto", 42]          =					"toto"
          snake_case			:      Tuple        =			HfArgumentParser(__a							)

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

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

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

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







     def 			snake_case_      (				self							)      ->				List[Any]:
          snake_case			:      Any        =			HfArgumentParser(__a							)

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

          snake_case			:      int        =			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]							)							,)

          snake_case			:      Optional[int]        =			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							)      ->				Optional[int]:
          snake_case			:      List[Any]        =			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							)

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

          for dataclass_type in dataclass_types:
               snake_case			:      Any        =			HfArgumentParser(__a							)

               self.argparsersEqual(__a							,__a							)

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

               snake_case			:      Any        =			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							)      ->				Any:
          snake_case			:      Optional[Any]        =			HfArgumentParser(__a							)

          snake_case			:      List[Any]        =			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							)      ->				List[Any]:
          snake_case			:      Optional[int]        =			HfArgumentParser(__a							)

          snake_case			:      Any        =			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							)      ->				Tuple:
          snake_case			:      str        =			HfArgumentParser(__a							)

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

          snake_case			:      List[str]        =			parser.parse_dict(__a							)[0]
          snake_case			:      str        =			BasicExample(**__a							)
          self.assertEqual(__a							,__a							)







     def 			snake_case_      (				self							)      ->				Any:
          snake_case			:      Tuple        =			HfArgumentParser(__a							)

          snake_case			:      int        =			{
              """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							)      ->				Optional[int]:
          snake_case			:      List[str]        =			HfArgumentParser(__a							)

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

          snake_case			:      List[str]        =			BasicExample(**__a							)
          self.assertEqual(__a							,__a							)







     def 			snake_case_      (				self							)      ->				str:
          snake_case			:      Union[str, Any]        =			HfArgumentParser(__a							)

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







     def 			snake_case_      (				self							)      ->				List[str]:
          snake_case			:      Union[str, Any]        =			HfArgumentParser(__a							)
          self.assertIsNotNone(__a							)



