




'''simple docstring'''







import argparse
import glob
import logging
import os
import time
from argparse import Namespace

import numpy as np
import torch
from lightning_base import BaseTransformer, add_generic_args, generic_train
from torch.utils.data import DataLoader, TensorDataset

from transformers import glue_compute_metrics as compute_metrics
from transformers import glue_convert_examples_to_features as convert_examples_to_features
from transformers import glue_output_modes, glue_tasks_num_labels
from transformers import glue_processors as processors


lowercase      :   List[str]      =       logging.getLogger(__name__)







class 					_a (a__	):





     '''simple docstring'''



     lowerCAmelCase_  :     int          =					"""sequence-classification"""







     def __init__(				self							,__a							)      ->				Dict:
          if type(__a							) == dict:
               snake_case			:      int        =			Namespace(**__a							)
          snake_case			:      Tuple        =			glue_output_modes[hparams.task]
          snake_case			:      List[Any]        =			glue_tasks_num_labels[hparams.task]

          super().__init__(__a							,__a							,self.mode							)







     def 			snake_case_      (				self							,**__a							)      ->				int:
          return self.model(**__a							)







     def 			snake_case_      (				self							,__a							,__a							)      ->				Any:
          snake_case			:      List[str]        =			{"""input_ids""": batch[0], """attention_mask""": batch[1], """labels""": batch[3]}

          if self.config.model_type not in ["distilbert", "bart"]:
               snake_case			:      List[str]        =			batch[2] if self.config.model_type in ["""bert""", """xlnet""", """albert"""] else None

          snake_case			:      Union[str, Any]        =			self(**__a							)
          snake_case			:      Optional[Any]        =			outputs[0]

          snake_case			:      Any        =			self.trainer.lr_schedulers[0]["""scheduler"""]
          snake_case			:      str        =			{"""loss""": loss, """rate""": lr_scheduler.get_last_lr()[-1]}
          return {"loss": loss, "log": tensorboard_logs}







     def 			snake_case_      (				self							)      ->				Optional[Any]:
          snake_case			:      Any        =			self.hparams
          snake_case			:      Union[str, Any]        =			processors[args.task]()
          snake_case			:      str        =			processor.get_labels()

          for mode in ["train", "dev"]:
               snake_case			:      Dict        =			self._feature_file(__a							)
               if os.path.exists(__a							) and not args.overwrite_cache:
                    logger.info("""Loading features from cached file %s"""							,__a							)
               else:
                    logger.info("""Creating features from dataset file at %s"""							,args.data_dir							)
                    snake_case			:      int        =			(
                        processor.get_dev_examples(args.data_dir							)
                        if mode == """dev"""
                        else processor.get_train_examples(args.data_dir							)
                    )
                    snake_case			:      Union[str, Any]        =			convert_examples_to_features(
                        __a							,self.tokenizer							,max_length=args.max_seq_length							,label_list=self.labels							,output_mode=args.glue_output_mode							,)
                    logger.info("""Saving features into cached file %s"""							,__a							)
                    torch.save(__a							,__a							)







     def 			snake_case_      (				self							,__a							,__a							,__a = False							)      ->				DataLoader:
          snake_case			:      str        =			"""dev""" if mode == """test""" else mode

          snake_case			:      Dict        =			self._feature_file(__a							)
          logger.info("""Loading features from cached file %s"""							,__a							)
          snake_case			:      Dict        =			torch.load(__a							)
          snake_case			:      List[Any]        =			torch.tensor([f.input_ids for f in features]							,dtype=torch.long							)
          snake_case			:      Union[str, Any]        =			torch.tensor([f.attention_mask for f in features]							,dtype=torch.long							)
          snake_case			:      Tuple        =			torch.tensor([f.token_type_ids for f in features]							,dtype=torch.long							)
          if self.hparams.glue_output_mode == "classification":
               snake_case			:      Any        =			torch.tensor([f.label for f in features]							,dtype=torch.long							)
          elif self.hparams.glue_output_mode == "regression":
               snake_case			:      Optional[int]        =			torch.tensor([f.label for f in features]							,dtype=torch.float							)

          return DataLoader(
              TensorDataset(__a							,__a							,__a							,__a							)							,batch_size=__a							,shuffle=__a							,)







     def 			snake_case_      (				self							,__a							,__a							)      ->				Optional[int]:
          snake_case			:      List[Any]        =			{"""input_ids""": batch[0], """attention_mask""": batch[1], """labels""": batch[3]}

          if self.config.model_type not in ["distilbert", "bart"]:
               snake_case			:      Union[str, Any]        =			batch[2] if self.config.model_type in ["""bert""", """xlnet""", """albert"""] else None

          snake_case			:      Any        =			self(**__a							)
          snake_case ,		snake_case			:      int        =			outputs[:2]
          snake_case			:      Tuple        =			logits.detach().cpu().numpy()
          snake_case			:      Optional[int]        =			inputs["""labels"""].detach().cpu().numpy()

          return {"val_loss": tmp_eval_loss.detach().cpu(), "pred": preds, "target": out_label_ids}







     def 			snake_case_      (				self							,__a							)      ->				tuple:
          snake_case			:      List[Any]        =			torch.stack([x["""val_loss"""] for x in outputs]							).mean().detach().cpu().item()
          snake_case			:      Any        =			np.concatenate([x["""pred"""] for x in outputs]							,axis=0							)

          if self.hparams.glue_output_mode == "classification":
               snake_case			:      Any        =			np.argmax(__a							,axis=1							)
          elif self.hparams.glue_output_mode == "regression":
               snake_case			:      List[str]        =			np.squeeze(__a							)

          snake_case			:      List[str]        =			np.concatenate([x["""target"""] for x in outputs]							,axis=0							)
          snake_case			:      Optional[Any]        =			[[] for _ in range(out_label_ids.shape[0]							)]
          snake_case			:      Optional[Any]        =			[[] for _ in range(out_label_ids.shape[0]							)]

          snake_case			:      Tuple        =			{**{"""val_loss""": val_loss_mean}, **compute_metrics(self.hparams.task							,__a							,__a							)}

          snake_case			:      Any        =			dict(results.items()							)
          snake_case			:      List[Any]        =			results
          return ret, preds_list, out_label_list







     def 			snake_case_      (				self							,__a							)      ->				dict:
          snake_case ,		snake_case ,		snake_case			:      int        =			self._eval_end(__a							)
          snake_case			:      List[Any]        =			ret["""log"""]
          return {"val_loss": logs["val_loss"], "log": logs, "progress_bar": logs}







     def 			snake_case_      (				self							,__a							)      ->				dict:
          snake_case ,		snake_case ,		snake_case			:      str        =			self._eval_end(__a							)
          snake_case			:      str        =			ret["""log"""]
          # `val_loss` is the key returned by `self._eval_end()` but actually refers to `test_loss`
          return {"avg_test_loss": logs["val_loss"], "log": logs, "progress_bar": logs}







     @staticmethod
     def 			snake_case_      (				__a							,__a							)      ->				List[Any]:
          BaseTransformer.add_model_specific_args(__a							,__a							)
          parser.add_argument(
              """--max_seq_length"""							,default=128							,type=__a							,help=(
                  """The maximum total input sequence length after tokenization. Sequences longer """
                  """than this will be truncated, sequences shorter will be padded."""
              )							,)

          parser.add_argument(
              """--task"""							,default=""""""							,type=__a							,required=__a							,help="""The GLUE task to run"""							,)
          parser.add_argument(
              """--gpus"""							,default=0							,type=__a							,help="""The number of GPUs allocated for this, it is by default 0 meaning none"""							,)

          parser.add_argument(
              """--overwrite_cache"""							,action="""store_true"""							,help="""Overwrite the cached training and evaluation sets"""							)

          return parser



def        lowerCamelCase__				(      ):
     snake_case			:      str        =			argparse.ArgumentParser()
     add_generic_args(__lowercase     ,   os.getcwd()				)
     snake_case			:      int        =			GLUETransformer.add_model_specific_args(__lowercase     ,   os.getcwd()				)
     snake_case			:      List[str]        =			parser.parse_args()

     # If output_dir not provided, a folder will be generated in pwd
     if args.output_dir is None:
          snake_case			:      List[str]        =			os.path.join(
              """./results"""     ,   F'''{args.task}_{time.strftime("%Y%m%d_%H%M%S"				)}'''     ,   )
          os.makedirs(args.output_dir				)

     snake_case			:      Optional[int]        =			GLUETransformer(__lowercase				)
     snake_case			:      Optional[Any]        =			generic_train(__lowercase     ,   __lowercase				)

     # Optionally, predict on dev set and write to output_dir
     if args.do_predict:
          snake_case			:      Union[str, Any]        =			sorted(glob.glob(os.path.join(args.output_dir     ,   """checkpoint-epoch=*.ckpt"""				)     ,   recursive=__lowercase				)				)
          snake_case			:      List[Any]        =			model.load_from_checkpoint(checkpoints[-1]				)
          return trainer.test(__lowercase				)


if __name__ == "__main__":
      main()









'''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							)



