


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


UpperCAmelCase__   	=							logging.get_logger(__name__)

UpperCAmelCase__   	=							{
    "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__   (       lowercase__):
     SCREAMING_SNAKE_CASE__      			=			'''rwkv'''
     SCREAMING_SNAKE_CASE__      			=			{'''max_position_embeddings''': '''context_length'''}





     def __init__(self		,     UpperCAmelCase=5_0_2_7_7		,     UpperCAmelCase=1_0_2_4		,     UpperCAmelCase=4_0_9_6		,     UpperCAmelCase=3_2		,     UpperCAmelCase=None		,     UpperCAmelCase=None		,     UpperCAmelCase=1e-5		,     UpperCAmelCase=0		,     UpperCAmelCase=0		,     UpperCAmelCase=6		,     UpperCAmelCase=False		,     UpperCAmelCase=True		,     **UpperCAmelCase		,     )     ->   Optional[Any]:
      _lowercase							      =vocab_size
      _lowercase							      =context_length
      _lowercase							      =hidden_size
      _lowercase							      =num_hidden_layers
      _lowercase							      =attention_hidden_size if attention_hidden_size is not None else hidden_size
      _lowercase							      =intermediate_size if intermediate_size is not None else 4 * hidden_size
      _lowercase							      =layer_norm_epsilon
      _lowercase							      =rescale_every
      _lowercase							      =use_cache

      _lowercase							      =bos_token_id
      _lowercase							      =eos_token_id

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





class 			_lowercase :


       """simple docstring"""




       def __init__(   self							:			Any					,      __lowerCamelCase							:			int       ):


             '''simple docstring'''



             lowerCamelCase__		:				List[str]    =  n
             lowerCamelCase__		:				Union[str, Any]    =  [None] * self.n
             lowerCamelCase__		:				List[str]    =  0  # index of the first element
             lowerCamelCase__		:				Any    =  0
             lowerCamelCase__		:				Any    =  0





       def __len__(   self							:			Tuple       ):


             '''simple docstring'''



             return self.size





       def 						lowerCAmelCase     (   self							:			Optional[int]       ):


             '''simple docstring'''



             return self.size == 0





       def 						lowerCAmelCase     (   self							:			Union[str, Any]       ):


             '''simple docstring'''



             return False if self.is_empty() else self.array[self.front]





       def 						lowerCAmelCase     (   self							:			str					,      __lowerCamelCase							:			List[str]       ):


             '''simple docstring'''



             if self.size >= self.n:
                   raise Exception("QUEUE IS FULL"       )

             lowerCamelCase__		:				Optional[Any]    =  data
             lowerCamelCase__		:				Tuple    =  (self.rear + 1) % self.n
             self.size += 1
             return self





       def 						lowerCAmelCase     (   self							:			Tuple       ):


             '''simple docstring'''



             if self.size == 0:
                   raise Exception("UNDERFLOW"       )

             lowerCamelCase__		:				Any    =  self.array[self.front]
             lowerCamelCase__		:				List[Any]    =  None
             lowerCamelCase__		:				str    =  (self.front + 1) % self.n
             self.size -= 1
             return temp


