





'''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}"	)












'''simple docstring'''



import json
from typing import List, Optional, Tuple

from tokenizers import normalizers

from ...tokenization_utils_fast import PreTrainedTokenizerFast
from .tokenization_electra import ElectraTokenizer


_SCREAMING_SNAKE_CASE   =      {'''vocab_file''': '''vocab.txt''', '''tokenizer_file''': '''tokenizer.json'''}

_SCREAMING_SNAKE_CASE   =      {
    '''vocab_file''': {
        '''google/electra-small-generator''': (
            '''https://huggingface.co/google/electra-small-generator/resolve/main/vocab.txt'''
        ),
        '''google/electra-base-generator''': '''https://huggingface.co/google/electra-base-generator/resolve/main/vocab.txt''',
        '''google/electra-large-generator''': (
            '''https://huggingface.co/google/electra-large-generator/resolve/main/vocab.txt'''
        ),
        '''google/electra-small-discriminator''': (
            '''https://huggingface.co/google/electra-small-discriminator/resolve/main/vocab.txt'''
        ),
        '''google/electra-base-discriminator''': (
            '''https://huggingface.co/google/electra-base-discriminator/resolve/main/vocab.txt'''
        ),
        '''google/electra-large-discriminator''': (
            '''https://huggingface.co/google/electra-large-discriminator/resolve/main/vocab.txt'''
        ),
    },
    '''tokenizer_file''': {
        '''google/electra-small-generator''': (
            '''https://huggingface.co/google/electra-small-generator/resolve/main/tokenizer.json'''
        ),
        '''google/electra-base-generator''': (
            '''https://huggingface.co/google/electra-base-generator/resolve/main/tokenizer.json'''
        ),
        '''google/electra-large-generator''': (
            '''https://huggingface.co/google/electra-large-generator/resolve/main/tokenizer.json'''
        ),
        '''google/electra-small-discriminator''': (
            '''https://huggingface.co/google/electra-small-discriminator/resolve/main/tokenizer.json'''
        ),
        '''google/electra-base-discriminator''': (
            '''https://huggingface.co/google/electra-base-discriminator/resolve/main/tokenizer.json'''
        ),
        '''google/electra-large-discriminator''': (
            '''https://huggingface.co/google/electra-large-discriminator/resolve/main/tokenizer.json'''
        ),
    },
}

_SCREAMING_SNAKE_CASE   =      {
    '''google/electra-small-generator''': 5_1_2,
    '''google/electra-base-generator''': 5_1_2,
    '''google/electra-large-generator''': 5_1_2,
    '''google/electra-small-discriminator''': 5_1_2,
    '''google/electra-base-discriminator''': 5_1_2,
    '''google/electra-large-discriminator''': 5_1_2,
}

_SCREAMING_SNAKE_CASE   =      {
    '''google/electra-small-generator''': {'''do_lower_case''': True},
    '''google/electra-base-generator''': {'''do_lower_case''': True},
    '''google/electra-large-generator''': {'''do_lower_case''': True},
    '''google/electra-small-discriminator''': {'''do_lower_case''': True},
    '''google/electra-base-discriminator''': {'''do_lower_case''': True},
    '''google/electra-large-discriminator''': {'''do_lower_case''': True},
}






class 							__lowercase    ( lowerCAmelCase__  ):







	'''simple docstring'''

	a      :			str     =    VOCAB_FILES_NAMES
	a      :			Dict     =    PRETRAINED_VOCAB_FILES_MAP
	a      :			int     =    PRETRAINED_INIT_CONFIGURATION
	a      :			Tuple     =    PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES
	a      :			List[Any]     =    ElectraTokenizer


	def __init__(self       ,_lowerCamelCase=None       ,_lowerCamelCase=None       ,_lowerCamelCase=True       ,_lowerCamelCase="[UNK]"       ,_lowerCamelCase="[SEP]"       ,_lowerCamelCase="[PAD]"       ,_lowerCamelCase="[CLS]"       ,_lowerCamelCase="[MASK]"       ,_lowerCamelCase=True       ,_lowerCamelCase=None       ,**_lowerCamelCase       ,)							->							List[Any]:







				'''simple docstring'''





				super().__init__(
				    _lowerCamelCase       ,tokenizer_file=_lowerCamelCase       ,do_lower_case=_lowerCamelCase       ,unk_token=_lowerCamelCase       ,sep_token=_lowerCamelCase       ,pad_token=_lowerCamelCase       ,cls_token=_lowerCamelCase       ,mask_token=_lowerCamelCase       ,tokenize_chinese_chars=_lowerCamelCase       ,strip_accents=_lowerCamelCase       ,**_lowerCamelCase       ,)

				__lowercase			  =							json.loads(self.backend_tokenizer.normalizer.__getstate__()	)
				if (
				    normalizer_state.get('''lowercase'''       ,_lowerCamelCase	) != do_lower_case
				    or normalizer_state.get('''strip_accents'''       ,_lowerCamelCase	) != strip_accents
				    or normalizer_state.get('''handle_chinese_chars'''       ,_lowerCamelCase	) != tokenize_chinese_chars
				):
							__lowercase			  =							getattr(_lowerCamelCase       ,normalizer_state.pop('''type'''	)	)
							__lowercase			  =							do_lower_case
							__lowercase			  =							strip_accents
							__lowercase			  =							tokenize_chinese_chars
							__lowercase			  =							normalizer_class(**_lowerCamelCase	)

				__lowercase			  =							do_lower_case


	def   _UpperCAmelCase       (self       ,_lowerCamelCase       ,_lowerCamelCase=None	)							->							str:







				'''simple docstring'''





				__lowercase			  =							[self.cls_token_id] + token_ids_a + [self.sep_token_id]

				if token_ids_a:
							output += token_ids_a + [self.sep_token_id]

				return output


	def   _UpperCAmelCase       (self       ,_lowerCamelCase       ,_lowerCamelCase = None	)							->							List[int]:







				'''simple docstring'''





				__lowercase			  =							[self.sep_token_id]
				__lowercase			  =							[self.cls_token_id]
				if token_ids_a is None:
							return len(cls + token_ids_a + sep	) * [0]
				return len(cls + token_ids_a + sep	) * [0] + len(token_ids_a + sep	) * [1]


	def   _UpperCAmelCase       (self       ,_lowerCamelCase       ,_lowerCamelCase = None	)							->							Tuple[str]:







				'''simple docstring'''





				__lowercase			  =							self._tokenizer.model.save(_lowerCamelCase       ,name=_lowerCamelCase	)
				return tuple(_lowerCamelCase	)





