





"""simple docstring"""
import importlib.metadata
import operator
import re
import sys
from typing import Optional

from packaging import version


lowerCamelCase_								=		{
    "<": operator.lt,
    "<=": operator.le,
    "==": operator.eq,
    "!=": operator.ne,
    ">=": operator.ge,
    ">": operator.gt,
}



def      __lowerCamelCase   (							a_     :		Optional[Any] ,   a_     :		Union[str, Any] ,   a_     :		List[Any] ,   a_     :		Optional[int] ,   a_     :		Any ,   a_     :		int							)			->      Dict:
      if got_ver is None or want_ver is None:
            raise ValueError(
                f'''Unable to compare versions for {requirement}: need={want_ver} found={got_ver}. This is unusual. Consider'''
                f''' reinstalling {pkg}.'''							)
      if not ops[op](version.parse(a_							) ,   version.parse(a_							)							):
            raise ImportError(
                f'''{requirement} is required for a normal functioning of this module, but found {pkg}=={got_ver}.{hint}'''							)



def      __lowerCamelCase   (							a_     :		str ,   a_     :		Optional[str] = None							)			->      None:
      __SCREAMING_SNAKE_CASE   :Tuple						=  f'''\n{hint}''' if hint is not None else ''''''

      # non-versioned check
      if re.match(r'''^[\w_\-\d]+$''' ,   a_							):
            __SCREAMING_SNAKE_CASE				,__SCREAMING_SNAKE_CASE				,__SCREAMING_SNAKE_CASE   :int						=  requirement, None, None
      else:
            __SCREAMING_SNAKE_CASE   :Tuple						=  re.findall(r'''^([^!=<>\s]+)([\s!=<>]{1,2}.+)''' ,   a_							)
            if not match:
                  raise ValueError(
                      '''requirement needs to be in the pip package format, .e.g., package_a==1.23, or package_b>=1.23, but'''
                      f''' got {requirement}'''							)
            __SCREAMING_SNAKE_CASE				,__SCREAMING_SNAKE_CASE   :Dict						=  match[0]
            __SCREAMING_SNAKE_CASE   :str						=  want_full.split(''','''							)  # there could be multiple requirements
            __SCREAMING_SNAKE_CASE   :Optional[int]						=  {}
            for w in want_range:
                  __SCREAMING_SNAKE_CASE   :Any						=  re.findall(r'''^([\s!=<>]{1,2})(.+)''' ,   a_							)
                  if not match:
                        raise ValueError(
                            '''requirement needs to be in the pip package format, .e.g., package_a==1.23, or package_b>=1.23,'''
                            f''' but got {requirement}'''							)
                  __SCREAMING_SNAKE_CASE				,__SCREAMING_SNAKE_CASE   :Dict						=  match[0]
                  __SCREAMING_SNAKE_CASE   :List[Any]						=  want_ver
                  if op not in ops:
                        raise ValueError(f'''{requirement}: need one of {list(ops.keys()							)}, but got {op}'''							)

    # special case
      if pkg == "python":
            __SCREAMING_SNAKE_CASE   :Dict						=  '''.'''.join([str(a_							) for x in sys.version_info[:3]]							)
            for op, want_ver in wanted.items():
                  _compare_versions(a_ ,   a_ ,   a_ ,   a_ ,   a_ ,   a_							)
            return

      # check if any version is installed
      try:
            __SCREAMING_SNAKE_CASE   :Union[str, Any]						=  importlib.metadata.version(a_							)
      except importlib.metadata.PackageNotFoundError:
            raise importlib.metadata.PackageNotFoundError(
                f'''The \'{requirement}\' distribution was not found and is required by this application. {hint}'''							)

      # check that the right version is installed if version number or a range was provided
      if want_ver is not None:
            for op, want_ver in wanted.items():
                  _compare_versions(a_ ,   a_ ,   a_ ,   a_ ,   a_ ,   a_							)







def      __lowerCamelCase   (							a_     :		List[str]							)			->      Union[str, Any]:
      __SCREAMING_SNAKE_CASE   :Dict						=  '''Try: pip install transformers -U or pip install -e \'.[dev]\' if you\'re working with git main'''
      return require_version(a_ ,   a_							)






"""simple docstring"""
from ...configuration_utils import PretrainedConfig
from ...utils import logging


lowerCamelCase_								=		logging.get_logger(__name__)

lowerCamelCase_								=		{}






class 					_SCREAMING_SNAKE_CASE(   A  ):
       SCREAMING_SNAKE_CASE_   :      List[Any]							=  '''llama'''
       SCREAMING_SNAKE_CASE_   :      Optional[int]							=  ['''past_key_values''']




       def __init__(						self		,SCREAMING_SNAKE_CASE__=3_20_00		,SCREAMING_SNAKE_CASE__=40_96		,SCREAMING_SNAKE_CASE__=1_10_08		,SCREAMING_SNAKE_CASE__=32		,SCREAMING_SNAKE_CASE__=32		,SCREAMING_SNAKE_CASE__=None		,SCREAMING_SNAKE_CASE__="silu"		,SCREAMING_SNAKE_CASE__=20_48		,SCREAMING_SNAKE_CASE__=0.0_2		,SCREAMING_SNAKE_CASE__=1E-6		,SCREAMING_SNAKE_CASE__=True		,SCREAMING_SNAKE_CASE__=0		,SCREAMING_SNAKE_CASE__=1		,SCREAMING_SNAKE_CASE__=2		,SCREAMING_SNAKE_CASE__=1		,SCREAMING_SNAKE_CASE__=False		,SCREAMING_SNAKE_CASE__=None		,**SCREAMING_SNAKE_CASE__		,)			->      Union[str, Any]:





             """simple docstring"""






             __SCREAMING_SNAKE_CASE   :Optional[Any]						=  vocab_size
             __SCREAMING_SNAKE_CASE   :int						=  max_position_embeddings
             __SCREAMING_SNAKE_CASE   :List[str]						=  hidden_size
             __SCREAMING_SNAKE_CASE   :Tuple						=  intermediate_size
             __SCREAMING_SNAKE_CASE   :List[str]						=  num_hidden_layers
             __SCREAMING_SNAKE_CASE   :List[Any]						=  num_attention_heads

             # for backward compatibility
             if num_key_value_heads is None:
                   __SCREAMING_SNAKE_CASE   :Optional[int]						=  num_attention_heads

             __SCREAMING_SNAKE_CASE   :str						=  num_key_value_heads
             __SCREAMING_SNAKE_CASE   :Union[str, Any]						=  hidden_act
             __SCREAMING_SNAKE_CASE   :List[str]						=  initializer_range
             __SCREAMING_SNAKE_CASE   :Union[str, Any]						=  rms_norm_eps
             __SCREAMING_SNAKE_CASE   :Dict						=  pretraining_tp
             __SCREAMING_SNAKE_CASE   :Optional[Any]						=  use_cache
             __SCREAMING_SNAKE_CASE   :Optional[Any]						=  rope_scaling
             self._rope_scaling_validation()

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




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





             """simple docstring"""






             if self.rope_scaling is None:
                   return

             if not isinstance(self.rope_scaling		,SCREAMING_SNAKE_CASE__							) 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}'''							)
             __SCREAMING_SNAKE_CASE   :Optional[Any]						=  self.rope_scaling.get('''type'''		,SCREAMING_SNAKE_CASE__							)
             __SCREAMING_SNAKE_CASE   :Optional[int]						=  self.rope_scaling.get('''factor'''		,SCREAMING_SNAKE_CASE__							)
             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(SCREAMING_SNAKE_CASE__		,SCREAMING_SNAKE_CASE__							) or rope_scaling_factor <= 1.0:
                   raise ValueError(f'''`rope_scaling`\'s factor field must be an float > 1, got {rope_scaling_factor}'''							)