




import argparse
import json
import os
import sys
import tempfile
import unittest
from argparse import Namespace
from dataclasses import dataclass, field
from enum import Enum
from pathlib import Path
from typing import List, Literal, Optional

import yaml

from transformers import HfArgumentParser, TrainingArguments
from transformers.hf_argparser import make_choice_type_function, string_to_bool


# Since Python 3.10, we can use the builtin `|` operator for Union types
# See PEP 604: https://peps.python.org/pep-0604
a_   		=     sys.version_info >= (3, 10)




def 					__SCREAMING_SNAKE_CASE   (  lowercase_=None					,     lowercase_=None      )       ->	Optional[Any]:

    """simple docstring"""


    return field(default_factory=lambda: default					,     metadata=lowercase_      )

@dataclass
class  _lowerCamelCase						:

      """simple docstring"""

      lowerCAmelCase__			: int
      lowerCAmelCase__			: float
      lowerCAmelCase__			: str
      lowerCAmelCase__			: bool







@dataclass
class  _lowerCamelCase						:

      """simple docstring"""

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







@dataclass
class  _lowerCamelCase						:

      """simple docstring"""

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







class  _lowerCamelCase						(			_SCREAMING_SNAKE_CASE   ):

      """simple docstring"""

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







class  _lowerCamelCase						(			_SCREAMING_SNAKE_CASE   ):

      """simple docstring"""

      lowerCAmelCase__			: Any    =					"titi"
      lowerCAmelCase__			: List[Any]    =					"toto"
      lowerCAmelCase__			: List[Any]    =					42







@dataclass
class  _lowerCamelCase						:

      """simple docstring"""

      lowerCAmelCase__			: BasicEnum    =					"toto"







      def       snake_case	(     self					: str				):
          __UpperCamelCase  		=						BasicEnum(self.foo				)







@dataclass
class  _lowerCamelCase						:

      """simple docstring"""

      lowerCAmelCase__			: MixedTypeEnum    =					"toto"







      def       snake_case	(     self					: Any				):
          __UpperCamelCase  		=						MixedTypeEnum(self.foo				)







@dataclass
class  _lowerCamelCase						:

      """simple docstring"""

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







@dataclass
class  _lowerCamelCase						:

      """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  _lowerCamelCase						:

      """simple docstring"""

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







      def       snake_case	(     self					: Optional[Any]				):
          __UpperCamelCase  		=						BasicEnum(self.required_enum				)







@dataclass
class  _lowerCamelCase						:

      """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  _lowerCamelCase						:

       """simple docstring"""

       lowerCAmelCase__			: bool    =					False
       lowerCAmelCase__			: bool    =					True
       lowerCAmelCase__			: bool | None    =					None







 @dataclass
 class  _lowerCamelCase						:

       """simple docstring"""

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


class  _lowerCamelCase						(			unittest.TestCase   ):

      """simple docstring"""

      def       snake_case	(     self					: Union[str, Any] ,       snake_case					: argparse.ArgumentParser ,       snake_case					: argparse.ArgumentParser				):
          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(snake_case				).items() if k != '''container'''}
              __UpperCamelCase  		=						{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       snake_case	(     self					: List[str]				):
          __UpperCamelCase  		=						HfArgumentParser(snake_case				)

          __UpperCamelCase  		=						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				)

          __UpperCamelCase  		=						['''--foo''', '''1''', '''--baz''', '''quux''', '''--bar''', '''0.5''']
          ((__UpperCamelCase)		,      )  		=						parser.parse_args_into_dataclasses(snake_case ,       look_for_args_file=snake_case				)
          self.assertFalse(example.flag				)







      def       snake_case	(     self					: List[Any]				):
          __UpperCamelCase  		=						HfArgumentParser(snake_case				)

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

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

          for dataclass_type in dataclass_types:
              __UpperCamelCase  		=						HfArgumentParser(snake_case				)
              self.argparsersEqual(snake_case ,       snake_case				)

              __UpperCamelCase  		=						parser.parse_args([]				)
              self.assertEqual(snake_case ,       Namespace(foo=snake_case ,       baz=snake_case ,       opt=snake_case				)				)

              __UpperCamelCase  		=						parser.parse_args(['''--foo''', '''--no_baz''']				)
              self.assertEqual(snake_case ,       Namespace(foo=snake_case ,       baz=snake_case ,       opt=snake_case				)				)

              __UpperCamelCase  		=						parser.parse_args(['''--foo''', '''--baz''']				)
              self.assertEqual(snake_case ,       Namespace(foo=snake_case ,       baz=snake_case ,       opt=snake_case				)				)

              __UpperCamelCase  		=						parser.parse_args(['''--foo''', '''True''', '''--baz''', '''True''', '''--opt''', '''True''']				)
              self.assertEqual(snake_case ,       Namespace(foo=snake_case ,       baz=snake_case ,       opt=snake_case				)				)

              __UpperCamelCase  		=						parser.parse_args(['''--foo''', '''False''', '''--baz''', '''False''', '''--opt''', '''False''']				)
              self.assertEqual(snake_case ,       Namespace(foo=snake_case ,       baz=snake_case ,       opt=snake_case				)				)







      def       snake_case	(     self					: List[str]				):
          __UpperCamelCase  		=						HfArgumentParser(snake_case				)

          __UpperCamelCase  		=						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				)

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

          @dataclass
          class  _lowerCamelCase						:

                """simple docstring"""

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







          __UpperCamelCase  		=						HfArgumentParser(snake_case				)

          __UpperCamelCase  		=						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				)

          __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					: Any				):
          __UpperCamelCase  		=						HfArgumentParser(snake_case				)

          __UpperCamelCase  		=						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				)

          __UpperCamelCase  		=						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]				) ,       )

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







      def       snake_case	(     self					: Dict				):
          __UpperCamelCase  		=						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				)

          __UpperCamelCase  		=						[OptionalExample]
          if is_python_no_less_than_3_10:
              dataclass_types.append(snake_case				)

          for dataclass_type in dataclass_types:
              __UpperCamelCase  		=						HfArgumentParser(snake_case				)

              self.argparsersEqual(snake_case ,       snake_case				)

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

              __UpperCamelCase  		=						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       snake_case	(     self					: Optional[int]				):
          __UpperCamelCase  		=						HfArgumentParser(snake_case				)

          __UpperCamelCase  		=						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       snake_case	(     self					: Union[str, Any]				):
          __UpperCamelCase  		=						HfArgumentParser(snake_case				)

          __UpperCamelCase  		=						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       snake_case	(     self					: int				):
          __UpperCamelCase  		=						HfArgumentParser(snake_case				)

          __UpperCamelCase  		=						{
              '''foo''': 12,
              '''bar''': 3.14,
              '''baz''': '''42''',
              '''flag''': True,
          }

          __UpperCamelCase  		=						parser.parse_dict(snake_case				)[0]
          __UpperCamelCase  		=						BasicExample(**snake_case				)
          self.assertEqual(snake_case ,       snake_case				)







      def       snake_case	(     self					: Dict				):
          __UpperCamelCase  		=						HfArgumentParser(snake_case				)

          __UpperCamelCase  		=						{
              '''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       snake_case	(     self					: str				):
          __UpperCamelCase  		=						HfArgumentParser(snake_case				)

          __UpperCamelCase  		=						{
              '''foo''': 12,
              '''bar''': 3.14,
              '''baz''': '''42''',
              '''flag''': True,
          }
          with tempfile.TemporaryDirectory() as tmp_dir:
              __UpperCamelCase  		=						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				)
              __UpperCamelCase  		=						parser.parse_yaml_file(Path(temp_local_path + '''.json'''				)				)[0]

          __UpperCamelCase  		=						BasicExample(**snake_case				)
          self.assertEqual(snake_case ,       snake_case				)







      def       snake_case	(     self					: List[Any]				):
          __UpperCamelCase  		=						HfArgumentParser(snake_case				)

          __UpperCamelCase  		=						{
              '''foo''': 12,
              '''bar''': 3.14,
              '''baz''': '''42''',
              '''flag''': True,
          }
          with tempfile.TemporaryDirectory() as tmp_dir:
              __UpperCamelCase  		=						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				)
              __UpperCamelCase  		=						parser.parse_yaml_file(Path(temp_local_path + '''.yaml'''				)				)[0]
          __UpperCamelCase  		=						BasicExample(**snake_case				)
          self.assertEqual(snake_case ,       snake_case				)







      def       snake_case	(     self					: Optional[Any]				):
          __UpperCamelCase  		=						HfArgumentParser(snake_case				)
          self.assertIsNotNone(snake_case				)












from ...configuration_utils import PretrainedConfig
from ...utils import logging


a_   		=     logging.get_logger(__name__)

a_   		=     {
    "RWKV/rwkv-4-169m-pile": "https://huggingface.co/RWKV/rwkv-4-169m-pile/resolve/main/config.json",
    "RWKV/rwkv-4-430m-pile": "https://huggingface.co/RWKV/rwkv-4-430m-pile/resolve/main/config.json",
    "RWKV/rwkv-4-1b5-pile": "https://huggingface.co/RWKV/rwkv-4-1b5-pile/resolve/main/config.json",
    "RWKV/rwkv-4-3b-pile": "https://huggingface.co/RWKV/rwkv-4-3b-pile/resolve/main/config.json",
    "RWKV/rwkv-4-7b-pile": "https://huggingface.co/RWKV/rwkv-4-7b-pile/resolve/main/config.json",
    "RWKV/rwkv-4-14b-pile": "https://huggingface.co/RWKV/rwkv-4-14b-pile/resolve/main/config.json",
    "RWKV/rwkv-raven-1b5": "https://huggingface.co/RWKV/rwkv-raven-1b5/resolve/main/config.json",
    "RWKV/rwkv-raven-3b": "https://huggingface.co/RWKV/rwkv-raven-3b/resolve/main/config.json",
    "RWKV/rwkv-raven-7b": "https://huggingface.co/RWKV/rwkv-raven-7b/resolve/main/config.json",
    "RWKV/rwkv-raven-14b": "https://huggingface.co/RWKV/rwkv-raven-14b/resolve/main/config.json",
}

class  _lowerCamelCase						(			_SCREAMING_SNAKE_CASE   ):

      """simple docstring"""

      lowerCAmelCase__			: Union[str, Any]    =					"rwkv"
      lowerCAmelCase__			: Union[str, Any]    =					{"max_position_embeddings": "context_length"}







      def __init__(     self					: Optional[int] ,       snake_case					: Optional[Any]=50277 ,       snake_case					: str=1024 ,       snake_case					: str=4096 ,       snake_case					: Optional[Any]=32 ,       snake_case					: Union[str, Any]=None ,       snake_case					: Optional[Any]=None ,       snake_case					: Optional[Any]=1E-5 ,       snake_case					: List[str]=0 ,       snake_case					: Optional[Any]=0 ,       snake_case					: Union[str, Any]=6 ,       snake_case					: Tuple=False ,       snake_case					: Any=True ,       **snake_case					: List[str] ,       ):
          __UpperCamelCase  		=						vocab_size
          __UpperCamelCase  		=						context_length
          __UpperCamelCase  		=						hidden_size
          __UpperCamelCase  		=						num_hidden_layers
          __UpperCamelCase  		=						attention_hidden_size if attention_hidden_size is not None else hidden_size
          __UpperCamelCase  		=						intermediate_size if intermediate_size is not None else 4 * hidden_size
          __UpperCamelCase  		=						layer_norm_epsilon
          __UpperCamelCase  		=						rescale_every
          __UpperCamelCase  		=						use_cache

          __UpperCamelCase  		=						bos_token_id
          __UpperCamelCase  		=						eos_token_id

          super().__init__(
              tie_word_embeddings=snake_case ,       bos_token_id=snake_case ,       eos_token_id=snake_case ,       **snake_case				)






