



"""simple docstring"""





import functools
import logging
import os
import sys
import threading
from logging import (
    CRITICAL,  # NOQA
    DEBUG,  # NOQA
    ERROR,  # NOQA
    FATAL,  # NOQA
    INFO,  # NOQA
    NOTSET,  # NOQA
    WARN,  # NOQA
    WARNING,  # NOQA
)
from typing import Optional

import huggingface_hub.utils as hf_hub_utils
from tqdm import auto as tqdm_lib


lowerCamelCase       	=						threading.Lock()
lowerCamelCase       	=						None

lowerCamelCase       	=						{
    """debug""": logging.DEBUG,
    """info""": logging.INFO,
    """warning""": logging.WARNING,
    """error""": logging.ERROR,
    """critical""": logging.CRITICAL,
}

lowerCamelCase       	=						logging.WARNING

lowerCamelCase       	=						True
def        a__     (				):
      UpperCAmelCase_      			=							os.getenv("TRANSFORMERS_VERBOSITY"     ,      __SCREAMING_SNAKE_CASE				)
      if env_level_str:
            if env_level_str in log_levels:
                  return log_levels[env_level_str]
            else:
                  logging.getLogger().warning(
                      f"""Unknown option TRANSFORMERS_VERBOSITY={env_level_str}, """
                      f"""has to be one of: { ', '.join(log_levels.keys()				) }"""				)
      return _default_log_level
def        a__     (				):
      return __name__.split("."				)[0]
def        a__     (				):
      return logging.getLogger(_get_library_name()				)
def        a__     (				):
      global _default_handler

      with _lock:
            if _default_handler:
                  # This library has already configured the library root logger.
                  return
            UpperCAmelCase_      			=							logging.StreamHandler()  # Set sys.stderr as stream.
            UpperCAmelCase_      			=							sys.stderr.flush

            # Apply our default configuration to the library root logger.
            UpperCAmelCase_      			=							_get_library_root_logger()
            library_root_logger.addHandler(_default_handler				)
            library_root_logger.setLevel(_get_default_logging_level()				)
            UpperCAmelCase_      			=							False
def        a__     (				):
      global _default_handler

      with _lock:
            if not _default_handler:
                  return

            UpperCAmelCase_      			=							_get_library_root_logger()
            library_root_logger.removeHandler(_default_handler				)
            library_root_logger.setLevel(logging.NOTSET				)
            UpperCAmelCase_      			=							None
def        a__     (				):
      return log_levels
def        a__     (				lowerCAmelCase__ = None				):

      if name is None:
            UpperCAmelCase_      			=							_get_library_name()

      _configure_library_root_logger()
      return logging.getLogger(__SCREAMING_SNAKE_CASE				)
def        a__     (				):
      _configure_library_root_logger()
      return _get_library_root_logger().getEffectiveLevel()
def        a__     (				lowerCAmelCase__				):
      _configure_library_root_logger()
      _get_library_root_logger().setLevel(__SCREAMING_SNAKE_CASE				)
def        a__     (				):
      return set_verbosity(__SCREAMING_SNAKE_CASE				)
def        a__     (				):
      return set_verbosity(__SCREAMING_SNAKE_CASE				)
def        a__     (				):
      return set_verbosity(__SCREAMING_SNAKE_CASE				)
def        a__     (				):
      return set_verbosity(__SCREAMING_SNAKE_CASE				)
def        a__     (				):
      _configure_library_root_logger()

      assert _default_handler is not None
      _get_library_root_logger().removeHandler(_default_handler				)
def        a__     (				):
      _configure_library_root_logger()

      assert _default_handler is not None
      _get_library_root_logger().addHandler(_default_handler				)
def        a__     (				lowerCAmelCase__				):
      _configure_library_root_logger()

      assert handler is not None
      _get_library_root_logger().addHandler(__SCREAMING_SNAKE_CASE				)
def        a__     (				lowerCAmelCase__				):
      _configure_library_root_logger()

      assert handler is not None and handler not in _get_library_root_logger().handlers
      _get_library_root_logger().removeHandler(__SCREAMING_SNAKE_CASE				)
def        a__     (				):
      _configure_library_root_logger()
      UpperCAmelCase_      			=							False
def        a__     (				):
      _configure_library_root_logger()
      UpperCAmelCase_      			=							True
def        a__     (				):
      UpperCAmelCase_      			=							_get_library_root_logger().handlers

      for handler in handlers:
            UpperCAmelCase_      			=							logging.Formatter("[%(levelname)s|%(filename)s:%(lineno)s] %(asctime)s >> %(message)s"				)
            handler.setFormatter(__SCREAMING_SNAKE_CASE				)
def        a__     (				):
      UpperCAmelCase_      			=							_get_library_root_logger().handlers

      for handler in handlers:
            handler.setFormatter(__SCREAMING_SNAKE_CASE				)
def        a__     (				self     ,      *lowerCAmelCase__     ,      **lowerCAmelCase__				):
      UpperCAmelCase_      			=							os.getenv("TRANSFORMERS_NO_ADVISORY_WARNINGS"     ,      __SCREAMING_SNAKE_CASE				)
      if no_advisory_warnings:
            return
      self.warning(*__SCREAMING_SNAKE_CASE     ,      **__SCREAMING_SNAKE_CASE				)


lowerCamelCase       	=						warning_advice
@functools.lru_cache(__SCREAMING_SNAKE_CASE				)
def        a__     (				self     ,      *lowerCAmelCase__     ,      **lowerCAmelCase__				):
      self.warning(*__SCREAMING_SNAKE_CASE     ,      **__SCREAMING_SNAKE_CASE				)


lowerCamelCase       	=						warning_once
class 				lowercase__       :







       '''simple docstring'''


       def __init__(							self      :  Optional[int]		,    *_UpperCAmelCase      :  Tuple		,    **_UpperCAmelCase      :  str   )			->						Union[str, Any]:  # pylint: disable=unused-argument


             '''simple docstring'''




             UpperCAmelCase_      			=							args[0] if args else None



       def __iter__(							self      :  Optional[Any]   )			->						int:


             '''simple docstring'''




             return iter(self._iterator   )



       def __getattr__(							self      :  Tuple		,    _UpperCAmelCase      :  Tuple   )			->						int:


             '''simple docstring'''




             def empty_fn(*_UpperCAmelCase      :  str		,    **_UpperCAmelCase      :  List[Any]   ):  # pylint: disable=unused-argument
                   return

             return empty_fn



       def __enter__(							self      :  Dict   )			->						List[str]:


             '''simple docstring'''




             return self







       def __exit__(							self      :  List[str]		,    _UpperCAmelCase      :  Any		,    _UpperCAmelCase      :  Optional[Any]		,    _UpperCAmelCase      :  Dict   )			->						str:


             '''simple docstring'''




             return



class 				lowercase__       :







       '''simple docstring'''


       def __call__(							self      :  List[str]		,    *_UpperCAmelCase      :  List[Any]		,    **_UpperCAmelCase      :  Union[str, Any]   )			->						str:


             '''simple docstring'''




             if _tqdm_active:
                   return tqdm_lib.tqdm(*UpperCamelCase__		,    **UpperCamelCase__   )
             else:
                   return EmptyTqdm(*UpperCamelCase__		,    **UpperCamelCase__   )



       def 					lowercase__    (							self      :  Any		,    *_UpperCAmelCase      :  Optional[int]		,    **_UpperCAmelCase      :  List[Any]   )			->						List[str]:


             '''simple docstring'''




             UpperCAmelCase_      			=							None
             if _tqdm_active:
                   return tqdm_lib.tqdm.set_lock(*UpperCamelCase__		,    **UpperCamelCase__   )







       def 					lowercase__    (							self      :  Tuple   )			->						List[Any]:


             '''simple docstring'''




             if _tqdm_active:
                   return tqdm_lib.tqdm.get_lock()



lowerCamelCase       	=						_tqdm_cls()
def        a__     (				):
      global _tqdm_active
      return bool(_tqdm_active				)
def        a__     (				):
      global _tqdm_active
      UpperCAmelCase_      			=							True
      hf_hub_utils.enable_progress_bars()


def        a__     (				):
      global _tqdm_active
      UpperCAmelCase_      			=							False
      hf_hub_utils.disable_progress_bars()




"""simple docstring"""





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


lowerCamelCase       	=						logging.get_logger(__name__)

lowerCamelCase       	=						{
    """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 				lowercase__       (   SCREAMING_SNAKE_CASE				):







       '''simple docstring'''


       UpperCamelCase						=					'''rwkv'''
       UpperCamelCase						=					{'''max_position_embeddings''': '''context_length'''}



       def __init__(							self      :  str		,    _UpperCAmelCase      :  int=50277		,    _UpperCAmelCase      :  Optional[Any]=1024		,    _UpperCAmelCase      :  str=4096		,    _UpperCAmelCase      :  Any=32		,    _UpperCAmelCase      :  Any=None		,    _UpperCAmelCase      :  Optional[int]=None		,    _UpperCAmelCase      :  Tuple=1e-5		,    _UpperCAmelCase      :  str=0		,    _UpperCAmelCase      :  Any=0		,    _UpperCAmelCase      :  Union[str, Any]=6		,    _UpperCAmelCase      :  Dict=False		,    _UpperCAmelCase      :  Any=True		,    **_UpperCAmelCase      :  Optional[Any]		,    )			->						str:


             '''simple docstring'''




             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=_UpperCAmelCase		,    bos_token_id=_UpperCAmelCase		,    eos_token_id=_UpperCAmelCase		,    **_UpperCAmelCase   )




