





'''simple docstring'''



import pytest

from datasets.splits import SplitDict, SplitInfo
from datasets.utils.py_utils import asdict




@pytest.mark.parametrize(
    '''split_dict'''						,    [
        SplitDict(),
        SplitDict({'''train''': SplitInfo(name='''train'''						,    num_bytes=1_3_3_7						,    num_examples=4_2						,    dataset_name='''my_dataset'''			)}			),
        SplitDict({'''train''': SplitInfo(name='''train'''						,    num_bytes=1_3_3_7						,    num_examples=4_2			)}			),
        SplitDict({'''train''': SplitInfo()}			),
    ]						,    )
def 				_lowerCAmelCase  (			lowerCamelCase_     :					SplitDict			):
			__lowercase			  =							split_dict._to_yaml_list()
			assert len(__lowerCAmelCase			) == len(__lowerCAmelCase			)
			__lowercase			  =							SplitDict._from_yaml_list(__lowerCAmelCase			)
			for split_name, split_info in split_dict.items():
						# dataset_name field is deprecated, and is therefore not part of the YAML dump
						__lowercase			  =							None
						# the split name of split_dict takes over the name of the split info object
						__lowercase			  =							split_name
			assert split_dict == reloaded




@pytest.mark.parametrize(
    '''split_info'''						,    [SplitInfo(), SplitInfo(dataset_name=__lowerCAmelCase			), SplitInfo(dataset_name='''my_dataset'''			)]			)
def 				_lowerCAmelCase  (			lowerCamelCase_     :					int			):
			# For backward compatibility, we need asdict(split_dict) to return split info dictrionaries with the "dataset_name"
			# field even if it's deprecated. This way old versionso of `datasets` can still reload dataset_infos.json files
			__lowercase			  =							asdict(SplitDict({'''train''': split_info}			)			)
			assert "dataset_name" in split_dict_asdict["train"]
			assert split_dict_asdict["train"]["dataset_name"] == split_info.dataset_name












'''simple docstring'''



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


_SCREAMING_SNAKE_CASE   =      logging.get_logger(__name__)

_SCREAMING_SNAKE_CASE   =      {
    '''s-JoL/Open-Llama-V1''': '''https://huggingface.co/s-JoL/Open-Llama-V1/blob/main/config.json''',
}






class 							__lowercase    ( lowerCAmelCase__  ):







	'''simple docstring'''

	a      :			Dict     =    "open-llama"


	def __init__(self       ,_lowerCamelCase=100000       ,_lowerCamelCase=4096       ,_lowerCamelCase=11008       ,_lowerCamelCase=32       ,_lowerCamelCase=32       ,_lowerCamelCase="silu"       ,_lowerCamelCase=2048       ,_lowerCamelCase=0.0_2       ,_lowerCamelCase=1E-6       ,_lowerCamelCase=True       ,_lowerCamelCase=0       ,_lowerCamelCase=1       ,_lowerCamelCase=2       ,_lowerCamelCase=False       ,_lowerCamelCase=True       ,_lowerCamelCase=0.1       ,_lowerCamelCase=0.1       ,_lowerCamelCase=True       ,_lowerCamelCase=True       ,_lowerCamelCase=None       ,**_lowerCamelCase       ,)							->							Union[str, Any]:







				'''simple docstring'''





				__lowercase			  =							vocab_size
				__lowercase			  =							max_position_embeddings
				__lowercase			  =							hidden_size
				__lowercase			  =							intermediate_size
				__lowercase			  =							num_hidden_layers
				__lowercase			  =							num_attention_heads
				__lowercase			  =							hidden_act
				__lowercase			  =							initializer_range
				__lowercase			  =							rms_norm_eps
				__lowercase			  =							use_cache
				__lowercase			  =							kwargs.pop(
				    '''use_memorry_efficient_attention'''       ,_lowerCamelCase	)
				__lowercase			  =							hidden_dropout_prob
				__lowercase			  =							attention_dropout_prob
				__lowercase			  =							use_stable_embedding
				__lowercase			  =							shared_input_output_embedding
				__lowercase			  =							rope_scaling
				self._rope_scaling_validation()

				super().__init__(
				    pad_token_id=_lowerCamelCase       ,bos_token_id=_lowerCamelCase       ,eos_token_id=_lowerCamelCase       ,tie_word_embeddings=_lowerCamelCase       ,**_lowerCamelCase       ,)


	def   _UpperCAmelCase       (self	)							->							List[Any]:







				'''simple docstring'''





				if self.rope_scaling is None:
							return

				if not isinstance(self.rope_scaling       ,_lowerCamelCase	) or len(self.rope_scaling	) != 2:
							raise ValueError(
							    '''`rope_scaling` must be a dictionary with with two fields, `name` and `factor`, '''
							    f"got {self.rope_scaling}"	)
				__lowercase			  =							self.rope_scaling.get('''type'''       ,_lowerCamelCase	)
				__lowercase			  =							self.rope_scaling.get('''factor'''       ,_lowerCamelCase	)
				if rope_scaling_type is None or rope_scaling_type not in ["linear", "dynamic"]:
							raise ValueError(
							    f"`rope_scaling`'s name field must be one of ['linear', 'dynamic'], got {rope_scaling_type}"	)
				if rope_scaling_factor is None or not isinstance(_lowerCamelCase       ,_lowerCamelCase	) or rope_scaling_factor <= 1.0:
							raise ValueError(f"`rope_scaling`'s factor field must be an float > 1, got {rope_scaling_factor}"	)





