



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


A:     Optional[Any]										=	logging.get_logger(__name__)

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



class    SCREAMING_SNAKE_CASE__						(      UpperCAmelCase__				):
   __lowerCAmelCase						:     str		=		'open-llama'

   def __init__(     self   ,  _SCREAMING_SNAKE_CASE=100000   ,  _SCREAMING_SNAKE_CASE=4096   ,  _SCREAMING_SNAKE_CASE=11008   ,  _SCREAMING_SNAKE_CASE=32   ,  _SCREAMING_SNAKE_CASE=32   ,  _SCREAMING_SNAKE_CASE="silu"   ,  _SCREAMING_SNAKE_CASE=2048   ,  _SCREAMING_SNAKE_CASE=0.02   ,  _SCREAMING_SNAKE_CASE=1E-6   ,  _SCREAMING_SNAKE_CASE=True   ,  _SCREAMING_SNAKE_CASE=0   ,  _SCREAMING_SNAKE_CASE=1   ,  _SCREAMING_SNAKE_CASE=2   ,  _SCREAMING_SNAKE_CASE=False   ,  _SCREAMING_SNAKE_CASE=True   ,  _SCREAMING_SNAKE_CASE=0.1   ,  _SCREAMING_SNAKE_CASE=0.1   ,  _SCREAMING_SNAKE_CASE=True   ,  _SCREAMING_SNAKE_CASE=True   ,  _SCREAMING_SNAKE_CASE=None   ,  **_SCREAMING_SNAKE_CASE   ,  )						->   Optional[int]:





    '''simple docstring'''




    UpperCAmelCase			:      Dict			=			vocab_size
    UpperCAmelCase			:      Optional[Any]			=			max_position_embeddings
    UpperCAmelCase			:      Any			=			hidden_size
    UpperCAmelCase			:      Any			=			intermediate_size
    UpperCAmelCase			:      Any			=			num_hidden_layers
    UpperCAmelCase			:      Optional[Any]			=			num_attention_heads
    UpperCAmelCase			:      Optional[Any]			=			hidden_act
    UpperCAmelCase			:      Tuple			=			initializer_range
    UpperCAmelCase			:      Tuple			=			rms_norm_eps
    UpperCAmelCase			:      str			=			use_cache
    UpperCAmelCase			:      List[str]			=			kwargs.pop(
        """use_memorry_efficient_attention"""   ,  _SCREAMING_SNAKE_CASE		)
    UpperCAmelCase			:      Optional[int]			=			hidden_dropout_prob
    UpperCAmelCase			:      Optional[int]			=			attention_dropout_prob
    UpperCAmelCase			:      str			=			use_stable_embedding
    UpperCAmelCase			:      str			=			shared_input_output_embedding
    UpperCAmelCase			:      Tuple			=			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 			SCREAMING_SNAKE_CASE  (     self		)						->   Tuple:





    '''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}"		)
    UpperCAmelCase			:      Optional[Any]			=			self.rope_scaling.get("""type"""   ,  _SCREAMING_SNAKE_CASE		)
    UpperCAmelCase			:      str			=			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}"		)





"""simple docstring"""
from __future__ import annotations

from decimal import Decimal

from numpy import array

def    _snake_case		(		UpperCamelCase		:	list[list[float]]		):
 UpperCAmelCase			:      str			=			Decimal

 # Check if the provided matrix has 2 rows and 2 columns
 # since this implementation only works for 2x2 matrices
 if len(UpperCamelCase		) == 2 and len(matrix[0]		) == 2 and len(matrix[1]		) == 2:
  # Calculate the determinant of the matrix
  UpperCAmelCase			:      Optional[int]			=			float(
      d(matrix[0][0]		) * d(matrix[1][1]		) - d(matrix[1][0]		) * d(matrix[0][1]		)		)
  if determinant == 0:
   raise ValueError("""This matrix has no inverse."""		)

  # Creates a copy of the matrix with swapped positions of the elements
  UpperCAmelCase			:      Optional[Any]			=			[[0.0, 0.0], [0.0, 0.0]]
  UpperCAmelCase			,	UpperCAmelCase			:      Any			=			matrix[1][1], matrix[0][0]
  UpperCAmelCase			,	UpperCAmelCase			:      Union[str, Any]			=			-matrix[1][0], -matrix[0][1]

  # Calculate the inverse of the matrix
  return [
      [(float(d(UpperCamelCase		)		) / determinant) or 0.0 for n in row] for row in swapped_matrix
  ]
 elif (
     len(UpperCamelCase		) == 3
     and len(matrix[0]		) == 3
     and len(matrix[1]		) == 3
     and len(matrix[2]		) == 3
 ):
  # Calculate the determinant of the matrix using Sarrus rule
  UpperCAmelCase			:      str			=			float(
      (
          (d(matrix[0][0]		) * d(matrix[1][1]		) * d(matrix[2][2]		))
          + (d(matrix[0][1]		) * d(matrix[1][2]		) * d(matrix[2][0]		))
          + (d(matrix[0][2]		) * d(matrix[1][0]		) * d(matrix[2][1]		))
      )
      - (
          (d(matrix[0][2]		) * d(matrix[1][1]		) * d(matrix[2][0]		))
          + (d(matrix[0][1]		) * d(matrix[1][0]		) * d(matrix[2][2]		))
          + (d(matrix[0][0]		) * d(matrix[1][2]		) * d(matrix[2][1]		))
      )		)
  if determinant == 0:
   raise ValueError("""This matrix has no inverse."""		)

  # Creating cofactor matrix
  UpperCAmelCase			:      Optional[int]			=			[
      [d(0.0		), d(0.0		), d(0.0		)],
      [d(0.0		), d(0.0		), d(0.0		)],
      [d(0.0		), d(0.0		), d(0.0		)],
  ]
  UpperCAmelCase			:      str			=			(d(matrix[1][1]		) * d(matrix[2][2]		)) - (
      d(matrix[1][2]		) * d(matrix[2][1]		)
  )
  UpperCAmelCase			:      List[str]			=			-(
      (d(matrix[1][0]		) * d(matrix[2][2]		)) - (d(matrix[1][2]		) * d(matrix[2][0]		))
  )
  UpperCAmelCase			:      Optional[int]			=			(d(matrix[1][0]		) * d(matrix[2][1]		)) - (
      d(matrix[1][1]		) * d(matrix[2][0]		)
  )
  UpperCAmelCase			:      Optional[int]			=			-(
      (d(matrix[0][1]		) * d(matrix[2][2]		)) - (d(matrix[0][2]		) * d(matrix[2][1]		))
  )
  UpperCAmelCase			:      str			=			(d(matrix[0][0]		) * d(matrix[2][2]		)) - (
      d(matrix[0][2]		) * d(matrix[2][0]		)
  )
  UpperCAmelCase			:      Union[str, Any]			=			-(
      (d(matrix[0][0]		) * d(matrix[2][1]		)) - (d(matrix[0][1]		) * d(matrix[2][0]		))
  )
  UpperCAmelCase			:      Dict			=			(d(matrix[0][1]		) * d(matrix[1][2]		)) - (
      d(matrix[0][2]		) * d(matrix[1][1]		)
  )
  UpperCAmelCase			:      Optional[Any]			=			-(
      (d(matrix[0][0]		) * d(matrix[1][2]		)) - (d(matrix[0][2]		) * d(matrix[1][0]		))
  )
  UpperCAmelCase			:      str			=			(d(matrix[0][0]		) * d(matrix[1][1]		)) - (
      d(matrix[0][1]		) * d(matrix[1][0]		)
  )

  # Transpose the cofactor matrix (Adjoint matrix)
  UpperCAmelCase			:      str			=			array(UpperCamelCase		)
  for i in range(3		):
   for j in range(3		):
    UpperCAmelCase			:      Any			=			cofactor_matrix[j][i]

        # Inverse of the matrix using the formula (1/determinant) * adjoint matrix
  UpperCAmelCase			:      Tuple			=			array(UpperCamelCase		)
  for i in range(3		):
   for j in range(3		):
    inverse_matrix[i][j] /= d(UpperCamelCase		)

        # Calculate the inverse of the matrix
  return [[float(d(UpperCamelCase		)		) or 0.0 for n in row] for row in inverse_matrix]
 raise ValueError("""Please provide a matrix of size 2x2 or 3x3."""		)
