

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


__A      		=     logging.get_logger(__name__)

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



class   lowercase_   (  __lowercase					):
      UpperCamelCase_      :		int										=    "open-llama"



      def __init__(      self				:    Optional[Any]      , A__				:    List[str]=100000      , A__				:    Tuple=4096      , A__				:    Dict=11008      , A__				:    str=32      , A__				:    Any=32      , A__				:    int="silu"      , A__				:    List[Any]=2048      , A__				:    Tuple=0.02      , A__				:    List[Any]=1e-6      , A__				:    Dict=True      , A__				:    int=0      , A__				:    Tuple=1      , A__				:    List[Any]=2      , A__				:    Optional[Any]=False      , A__				:    Optional[int]=True      , A__				:    Optional[int]=0.1      , A__				:    str=0.1      , A__				:    int=True      , A__				:    Any=True      , A__				:    List[str]=None      , **A__				:    Dict      , )   ->					Optional[int]:
        _snake_case						=							vocab_size
        _snake_case						=							max_position_embeddings
        _snake_case						=							hidden_size
        _snake_case						=							intermediate_size
        _snake_case						=							num_hidden_layers
        _snake_case						=							num_attention_heads
        _snake_case						=							hidden_act
        _snake_case						=							initializer_range
        _snake_case						=							rms_norm_eps
        _snake_case						=							use_cache
        _snake_case						=							kwargs.pop(
            '''use_memorry_efficient_attention'''      , A__		)
        _snake_case						=							hidden_dropout_prob
        _snake_case						=							attention_dropout_prob
        _snake_case						=							use_stable_embedding
        _snake_case						=							shared_input_output_embedding
        _snake_case						=							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 						UpperCamelCase_		(      self				:    Union[str, Any]		)   ->					Any:
        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}"""		)
        _snake_case						=							self.rope_scaling.get('''type'''      , A__		)
        _snake_case						=							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}"""		)




from __future__ import annotations



def 				snake_case_(_UpperCamelCase			,	_UpperCamelCase					)							->     bool:



  """simple docstring"""






  _snake_case						=							get_failure_array(_UpperCamelCase					)

  # 2) Step through text searching for pattern
  _snake_case,					_snake_case						=							0, 0  # index into text, pattern
  while i < len(_UpperCamelCase					):
    if pattern[j] == text[i]:
      if j == (len(_UpperCamelCase					) - 1):
        return True
      j += 1

    # if this is a prefix in our pattern
    # just go back far enough to continue
    elif j > 0:
      _snake_case						=							failure[j - 1]
      continue
    i += 1
  return False



def 				snake_case_(_UpperCamelCase					)							->     list[int]:



  """simple docstring"""






  _snake_case						=							[0]
  _snake_case						=							0
  _snake_case						=							1
  while j < len(_UpperCamelCase					):
    if pattern[i] == pattern[j]:
      i += 1
    elif i > 0:
      _snake_case						=							failure[i - 1]
      continue
    j += 1
    failure.append(_UpperCamelCase					)
  return failure


if __name__ == "__main__":
 # Test 1)
 __A      		=     '''abc1abc12'''
 __A      		=     '''alskfjaldsabc1abc1abc12k23adsfabcabc'''
 __A      		=     '''alskfjaldsk23adsfabcabc'''
 assert kmp(pattern, texta) and not kmp(pattern, texta)

 # Test 2)
 __A      		=     '''ABABX'''
 __A      		=     '''ABABZABABYABABX'''
 assert kmp(pattern, text)

 # Test 3)
 __A      		=     '''AAAB'''
 __A      		=     '''ABAAAAAB'''
 assert kmp(pattern, text)

 # Test 4)
 __A      		=     '''abcdabcy'''
 __A      		=     '''abcxabcdabxabcdabcdabcy'''
 assert kmp(pattern, text)

 # Test 5)
 __A      		=     '''aabaabaaa'''
 assert get_failure_array(pattern) == [0, 1, 0, 1, 2, 3, 4, 5, 2]

