



'''simple docstring'''






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


A_							: Tuple						 =	logging.get_logger(__name__)

A_							: Optional[int]						 =	{}



class 							lowercase       (  _lowerCamelCase				):


 """simple docstring"""


 UpperCAmelCase							=  """llama"""
 UpperCAmelCase							=  ["""past_key_values"""]







 def __init__(							self  ,a_=32_000  ,a_=4_096  ,a_=11_008  ,a_=32  ,a_=32  ,a_=None  ,a_="silu"  ,a_=2_048  ,a_=0.02  ,a_=1E-6  ,a_=True  ,a_=0  ,a_=1  ,a_=2  ,a_=1  ,a_=False  ,a_=None  ,**a_  ,)		->   Tuple:
        _UpperCAmelCase  :						int			     = vocab_size
        _UpperCAmelCase  :						List[str]			     = max_position_embeddings
        _UpperCAmelCase  :						Tuple			     = hidden_size
        _UpperCAmelCase  :						Optional[int]			     = intermediate_size
        _UpperCAmelCase  :						List[str]			     = num_hidden_layers
        _UpperCAmelCase  :						str			     = num_attention_heads

        # for backward compatibility
        if num_key_value_heads is None:
               _UpperCAmelCase  :						List[Any]			     = num_attention_heads

        _UpperCAmelCase  :						Optional[int]			     = num_key_value_heads
        _UpperCAmelCase  :						Any			     = hidden_act
        _UpperCAmelCase  :						List[str]			     = initializer_range
        _UpperCAmelCase  :						Optional[Any]			     = rms_norm_eps
        _UpperCAmelCase  :						List[Any]			     = pretraining_tp
        _UpperCAmelCase  :						List[str]			     = use_cache
        _UpperCAmelCase  :						List[str]			     = rope_scaling
        self._rope_scaling_validation()

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







 def _snake_case (							self							)		->   Tuple:
        if self.rope_scaling is None:
               return

        if not isinstance(self.rope_scaling  ,a_							) 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}'''							)
        _UpperCAmelCase  :						Tuple			     = self.rope_scaling.get("""type"""  ,a_							)
        _UpperCAmelCase  :						Any			     = self.rope_scaling.get("""factor"""  ,a_							)
        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(a_  ,a_							) 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'''






from typing import TYPE_CHECKING

from ...utils import (
    OptionalDependencyNotAvailable,
    _LazyModule,
    is_sentencepiece_available,
    is_tokenizers_available,
    is_torch_available,
)


A_							: Optional[Any]						 =	{
    """configuration_llama""": ["""LLAMA_PRETRAINED_CONFIG_ARCHIVE_MAP""", """LlamaConfig"""],
}

try:
   if not is_sentencepiece_available():
      raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
   pass
else:
   A_							: List[str]						 =	["""LlamaTokenizer"""]

try:
   if not is_tokenizers_available():
      raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
   pass
else:
   A_							: Dict						 =	["""LlamaTokenizerFast"""]

try:
   if not is_torch_available():
      raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
   pass
else:
   A_							: Optional[int]						 =	[
       """LlamaForCausalLM""",
       """LlamaModel""",
       """LlamaPreTrainedModel""",
       """LlamaForSequenceClassification""",
   ]


if TYPE_CHECKING:
   from .configuration_llama import LLAMA_PRETRAINED_CONFIG_ARCHIVE_MAP, LlamaConfig

   try:
      if not is_sentencepiece_available():
         raise OptionalDependencyNotAvailable()
   except OptionalDependencyNotAvailable:
      pass
   else:
      from .tokenization_llama import LlamaTokenizer

   try:
      if not is_tokenizers_available():
         raise OptionalDependencyNotAvailable()
   except OptionalDependencyNotAvailable:
      pass
   else:
      from .tokenization_llama_fast import LlamaTokenizerFast

   try:
      if not is_torch_available():
         raise OptionalDependencyNotAvailable()
   except OptionalDependencyNotAvailable:
      pass
   else:
      from .modeling_llama import LlamaForCausalLM, LlamaForSequenceClassification, LlamaModel, LlamaPreTrainedModel


else:
   import sys

   A_							: Any						 =	_LazyModule(__name__, globals()["""__file__"""], _import_structure, module_spec=__spec__)



