






"""simple docstring"""






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


SCREAMING_SNAKE_CASE						:						Union[str, Any]					   =       logging.get_logger(__name__)

SCREAMING_SNAKE_CASE						:						Optional[Any]					   =       {
    "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       snake_case_       (    UpperCAmelCase_       ):



	"""simple docstring"""

	SCREAMING_SNAKE_CASE_:							int   			=					'rwkv'
	SCREAMING_SNAKE_CASE_:							int   			=					{'max_position_embeddings': 'context_length'}


	def __init__(      self  ,					__a=5_0277  ,					__a=1024  ,					__a=4096  ,					__a=32  ,					__a=None  ,					__a=None  ,					__a=1E-5  ,					__a=0  ,					__a=0  ,					__a=6  ,					__a=False  ,					__a=True  ,					**__a  ,					):


					"""simple docstring"""

					A__							 =       vocab_size
					A__							 =       context_length
					A__							 =       hidden_size
					A__							 =       num_hidden_layers
					A__							 =       attention_hidden_size if attention_hidden_size is not None else hidden_size
					A__							 =       intermediate_size if intermediate_size is not None else 4 * hidden_size
					A__							 =       layer_norm_epsilon
					A__							 =       rescale_every
					A__							 =       use_cache

					A__							 =       bos_token_id
					A__							 =       eos_token_id

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










"""simple docstring"""






from math import ceil



def  __lowerCamelCase					(					lowerCAmelCase__       ,lowerCAmelCase__				):
				A__							 =       list(range(0       ,lowerCAmelCase__				)				)

				A__							 =       [item for sublist in list(device_map.values()				) for item in sublist]

				# Duplicate check
				A__							 =       []
				for i in device_map_blocks:
								if device_map_blocks.count(lowerCAmelCase__				) > 1 and i not in duplicate_blocks:
												duplicate_blocks.append(lowerCAmelCase__				)
    # Missing blocks
				A__							 =       [i for i in blocks if i not in device_map_blocks]
				A__							 =       [i for i in device_map_blocks if i not in blocks]

				if len(lowerCAmelCase__				) != 0:
								raise ValueError(
								    'Duplicate attention blocks specified in device_map. Attention blocks must be specified to one device.'
								    ' These attention blocks were specified more than once: ' + str(lowerCAmelCase__				)				)
				if len(lowerCAmelCase__				) != 0:
								raise ValueError(
								    'There are attention blocks for this model that are not specified in the device_map. Add these attention '
								    'blocks to a device on the device_map: ' + str(lowerCAmelCase__				)				)
				if len(lowerCAmelCase__				) != 0:
								raise ValueError(
								    'The device_map contains more attention blocks than this model has. Remove these from the device_map:'
								    + str(lowerCAmelCase__				)				)







def  __lowerCamelCase					(					lowerCAmelCase__       ,lowerCAmelCase__				):
				A__							 =       list(range(lowerCAmelCase__				)				)
				A__							 =       int(ceil(n_layers / len(lowerCAmelCase__				)				)				)
				A__							 =       [layers[i : i + n_blocks] for i in range(0       ,lowerCAmelCase__       ,lowerCAmelCase__				)]

				return dict(zip(lowerCAmelCase__       ,lowerCAmelCase__				)				)


