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 			UpperCAmelCase__    (		snake_case					):



  """simple docstring"""






  lowerCAmelCase__		:	Optional[Any]    		= 'open-llama'






  def __init__(				self:			Any				,				__lowerCAmelCase:			Optional[Any]=100_000				,				__lowerCAmelCase:			int=4_096				,				__lowerCAmelCase:			Union[str, Any]=11_008				,				__lowerCAmelCase:			int=32				,				__lowerCAmelCase:			List[Any]=32				,				__lowerCAmelCase:			str="silu"				,				__lowerCAmelCase:			List[str]=2_048				,				__lowerCAmelCase:			int=0.02				,				__lowerCAmelCase:			List[str]=1E-6				,				__lowerCAmelCase:			Any=True				,				__lowerCAmelCase:			List[str]=0				,				__lowerCAmelCase:			Dict=1				,				__lowerCAmelCase:			Dict=2				,				__lowerCAmelCase:			Optional[int]=False				,				__lowerCAmelCase:			Any=True				,				__lowerCAmelCase:			str=0.1				,				__lowerCAmelCase:			List[Any]=0.1				,				__lowerCAmelCase:			List[Any]=True				,				__lowerCAmelCase:			Optional[int]=True				,				__lowerCAmelCase:			List[str]=None				,				**__lowerCAmelCase:			List[str]				,				) -> str:




    '''simple docstring'''




    __UpperCAmelCase						    =       vocab_size
    __UpperCAmelCase						    =       max_position_embeddings
    __UpperCAmelCase						    =       hidden_size
    __UpperCAmelCase						    =       intermediate_size
    __UpperCAmelCase						    =       num_hidden_layers
    __UpperCAmelCase						    =       num_attention_heads
    __UpperCAmelCase						    =       hidden_act
    __UpperCAmelCase						    =       initializer_range
    __UpperCAmelCase						    =       rms_norm_eps
    __UpperCAmelCase						    =       use_cache
    __UpperCAmelCase						    =       kwargs.pop(
        "use_memorry_efficient_attention"				,				__lowerCAmelCase   )
    __UpperCAmelCase						    =       hidden_dropout_prob
    __UpperCAmelCase						    =       attention_dropout_prob
    __UpperCAmelCase						    =       use_stable_embedding
    __UpperCAmelCase						    =       shared_input_output_embedding
    __UpperCAmelCase						    =       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]   ) -> List[str]:




    '''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}'''   )
    __UpperCAmelCase						    =       self.rope_scaling.get("type"				,				__lowerCAmelCase   )
    __UpperCAmelCase						    =       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}'''   )




def       __lowerCAmelCase      (						A_   : str					)    ->  Any:
  if not head:
    return True
  # split the list to two parts
  __UpperCAmelCase    ,		__UpperCAmelCase						    =       head.next, head
  while fast and fast.next:
    __UpperCAmelCase						    =       fast.next.next
    __UpperCAmelCase						    =       slow.next
  __UpperCAmelCase						    =       slow.next
  __UpperCAmelCase						    =       None  # Don't forget here! But forget still works!
  # reverse the second part
  __UpperCAmelCase						    =       None
  while second:
    __UpperCAmelCase						    =       second.next
    __UpperCAmelCase						    =       node
    __UpperCAmelCase						    =       second
    __UpperCAmelCase						    =       nxt
  # compare two parts
  # second part has the same or one less node
  while node:
    if node.val != head.val:
      return False
    __UpperCAmelCase						    =       node.next
    __UpperCAmelCase						    =       head.next
  return True




def       __lowerCAmelCase      (						A_   : Optional[Any]					)    ->  Optional[Any]:
  if not head or not head.next:
    return True

  # 1. Get the midpoint (slow)
  __UpperCAmelCase						    =       __UpperCAmelCase						    =       __UpperCAmelCase						    =       head
  while fast and fast.next:
    __UpperCAmelCase    ,		__UpperCAmelCase						    =       fast.next.next, slow.next

  # 2. Push the second half into the stack
  __UpperCAmelCase						    =       [slow.val]
  while slow.next:
    __UpperCAmelCase						    =       slow.next
    stack.append(slow.val					)

  # 3. Comparison
  while stack:
    if stack.pop() != cur.val:
      return False
    __UpperCAmelCase						    =       cur.next

  return True





def       __lowerCAmelCase      (						A_   : int					)    ->  Optional[int]:
  if not head or not head.next:
    return True
  __UpperCAmelCase						    =       {}
  __UpperCAmelCase						    =       0
  while head:
    if head.val in d:
      d[head.val].append(A_					)
    else:
      __UpperCAmelCase						    =       [pos]
    __UpperCAmelCase						    =       head.next
    pos += 1
  __UpperCAmelCase						    =       pos - 1
  __UpperCAmelCase						    =       0
  for v in d.values():
    if len(A_					) % 2 != 0:
      middle += 1
    else:
      __UpperCAmelCase						    =       0
      for i in range(0						,	len(A_					)					):
        if v[i] + v[len(A_					) - 1 - step] != checksum:
          return False
        step += 1
    if middle > 1:
      return False
  return True



