


'''simple docstring'''


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


lowerCamelCase__    	=     logging.get_logger(__name__)

lowerCamelCase__    	=     {
    'bigcode/gpt_bigcode-santacoder': 'https://huggingface.co/bigcode/gpt_bigcode-santacoder/resolve/main/config.json',
}






class 	lowerCAmelCase__			(			UpperCAmelCase__	):
			lowerCAmelCase :	Optional[Any]          =     "gpt_bigcode"
			lowerCAmelCase :	Any          =     ["past_key_values"]
			lowerCAmelCase :	int          =     {
			    "hidden_size": "n_embd",
			    "max_position_embeddings": "n_positions",
			    "num_attention_heads": "n_head",
			    "num_hidden_layers": "n_layer",
			}




			def __init__(		self  :     List[Any]	,  lowerCamelCase__  :     str=5_02_57	,  lowerCamelCase__  :     str=10_24	,  lowerCamelCase__  :     Optional[Any]=7_68	,  lowerCamelCase__  :     Dict=12	,  lowerCamelCase__  :     int=12	,  lowerCamelCase__  :     int=None	,  lowerCamelCase__  :     Optional[int]="gelu_pytorch_tanh"	,  lowerCamelCase__  :     Optional[Any]=0.1	,  lowerCamelCase__  :     Dict=0.1	,  lowerCamelCase__  :     Union[str, Any]=0.1	,  lowerCamelCase__  :     Dict=1E-5	,  lowerCamelCase__  :     List[Any]=0.0_2	,  lowerCamelCase__  :     Dict=True	,  lowerCamelCase__  :     List[str]=True	,  lowerCamelCase__  :     List[Any]=5_02_56	,  lowerCamelCase__  :     Union[str, Any]=5_02_56	,  lowerCamelCase__  :     List[str]=True	,  lowerCamelCase__  :     Any=True	,  lowerCamelCase__  :     Any=True	,  **lowerCamelCase__  :     Optional[Any]	,  )   ->str:



					'''simple docstring'''







					_UpperCAmelCase		:       int								=      vocab_size
					_UpperCAmelCase		:       Union[str, Any]								=      n_positions
					_UpperCAmelCase		:       Optional[int]								=      n_embd
					_UpperCAmelCase		:       Optional[int]								=      n_layer
					_UpperCAmelCase		:       Tuple								=      n_head
					_UpperCAmelCase		:       Dict								=      n_inner
					_UpperCAmelCase		:       Any								=      activation_function
					_UpperCAmelCase		:       Tuple								=      resid_pdrop
					_UpperCAmelCase		:       Tuple								=      embd_pdrop
					_UpperCAmelCase		:       Dict								=      attn_pdrop
					_UpperCAmelCase		:       List[str]								=      layer_norm_epsilon
					_UpperCAmelCase		:       Tuple								=      initializer_range
					_UpperCAmelCase		:       int								=      scale_attn_weights
					_UpperCAmelCase		:       Union[str, Any]								=      use_cache
					_UpperCAmelCase		:       List[str]								=      attention_softmax_in_fpaa
					_UpperCAmelCase		:       List[str]								=      scale_attention_softmax_in_fpaa
					_UpperCAmelCase		:       Any								=      multi_query

					_UpperCAmelCase		:       int								=      bos_token_id
					_UpperCAmelCase		:       List[str]								=      eos_token_id

					super().__init__(bos_token_id=lowerCamelCase__	,  eos_token_id=lowerCamelCase__	,  **lowerCamelCase__ )







'''simple docstring'''


from __future__ import annotations

import math

import numpy as np
from numpy.linalg import norm






def  __lowerCAmelCase (__lowerCAmelCase      , __lowerCAmelCase   ):
		return math.sqrt(sum(pow(a - b      , 2   ) for a, b in zip(__lowerCAmelCase      , __lowerCAmelCase   )   )   )






def  __lowerCAmelCase (__lowerCAmelCase      , __lowerCAmelCase   ):

		if dataset.ndim != value_array.ndim:
				_UpperCAmelCase		:       Optional[Any]								=      (
				    "Wrong input data's dimensions... "
				    F"""dataset : {dataset.ndim}, value_array : {value_array.ndim}"""
				)
				raise ValueError(__lowerCAmelCase   )

		try:
				if dataset.shape[1] != value_array.shape[1]:
						_UpperCAmelCase		:       Optional[int]								=      (
						    "Wrong input data's shape... "
						    F"""dataset : {dataset.shape[1]}, value_array : {value_array.shape[1]}"""
						)
						raise ValueError(__lowerCAmelCase   )
		except IndexError:
				if dataset.ndim != value_array.ndim:
						raise TypeError("Wrong shape"   )

		if dataset.dtype != value_array.dtype:
				_UpperCAmelCase		:       Union[str, Any]								=      (
				    "Input data have different datatype... "
				    F"""dataset : {dataset.dtype}, value_array : {value_array.dtype}"""
				)
				raise TypeError(__lowerCAmelCase   )

		_UpperCAmelCase		:       Optional[int]								=      []

		for value in value_array:
				_UpperCAmelCase		:       List[str]								=      euclidean(__lowerCAmelCase      , dataset[0]   )
				_UpperCAmelCase		:       Dict								=      dataset[0].tolist()

				for dataset_value in dataset[1:]:
						_UpperCAmelCase		:       int								=      euclidean(__lowerCAmelCase      , __lowerCAmelCase   )

						if dist > temp_dist:
								_UpperCAmelCase		:       Tuple								=      temp_dist
								_UpperCAmelCase		:       Dict								=      dataset_value.tolist()

				answer.append([vector, dist]   )

		return answer






def  __lowerCAmelCase (__lowerCAmelCase      , __lowerCAmelCase   ):
		return np.dot(__lowerCAmelCase      , __lowerCAmelCase   ) / (norm(__lowerCAmelCase   ) * norm(__lowerCAmelCase   ))


if __name__ == "__main__":
						import doctest

						doctest.testmod()



