


"""simple docstring"""


from dataclasses import asdict, dataclass
from typing import Optional

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


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

# TODO Update this
A	:  Optional[Any]            =     {
    "facebook/esm-1b": "https://huggingface.co/facebook/esm-1b/resolve/main/config.json",
    # See all ESM models at https://huggingface.co/models?filter=esm
}
class     _UpperCamelCase    (  lowerCAmelCase__						):
							'''simple docstring'''







							__UpperCAmelCase		:       List[Any]							 ="""esm"""

							def __init__(	self       ,  __a=None       ,  __a=None       ,  __a=None       ,  __a=7_68       ,  __a=12       ,  __a=12       ,  __a=30_72       ,  __a=0.1       ,  __a=0.1       ,  __a=10_26       ,  __a=0.0_2       ,  __a=1e-1_2       ,  __a="absolute"       ,  __a=True       ,  __a=None       ,  __a=False       ,  __a=False       ,  __a=None       ,  __a=None       ,  **__a       ,  ):
										super().__init__(pad_token_id=__a       ,  mask_token_id=__a       ,  **__a      )

										__lowerCAmelCase							       =     vocab_size
										__lowerCAmelCase							       =     hidden_size
										__lowerCAmelCase							       =     num_hidden_layers
										__lowerCAmelCase							       =     num_attention_heads
										__lowerCAmelCase							       =     intermediate_size
										__lowerCAmelCase							       =     hidden_dropout_prob
										__lowerCAmelCase							       =     attention_probs_dropout_prob
										__lowerCAmelCase							       =     max_position_embeddings
										__lowerCAmelCase							       =     initializer_range
										__lowerCAmelCase							       =     layer_norm_eps
										__lowerCAmelCase							       =     position_embedding_type
										__lowerCAmelCase							       =     use_cache
										__lowerCAmelCase							       =     emb_layer_norm_before
										__lowerCAmelCase							       =     token_dropout
										__lowerCAmelCase							       =     is_folding_model
										if is_folding_model:
													if esmfold_config is None:
																logger.info("No esmfold_config supplied for folding model, using default values."      )
																__lowerCAmelCase							       =     EsmFoldConfig()
													elif isinstance(__a       ,  __a      ):
																__lowerCAmelCase							       =     EsmFoldConfig(**__a      )
													__lowerCAmelCase							       =     esmfold_config
													if vocab_list is None:
																logger.warning("No vocab_list supplied for folding model, assuming the ESM-2 vocabulary!"      )
																__lowerCAmelCase							       =     get_default_vocab_list()
													else:
																__lowerCAmelCase							       =     vocab_list
										else:
													__lowerCAmelCase							       =     None
													__lowerCAmelCase							       =     None
										if self.esmfold_config is not None and getattr(self.esmfold_config       ,  "use_esm_attn_map"       ,  __a      ):
													raise ValueError("The HuggingFace port of ESMFold does not support use_esm_attn_map at this time!"      )



							def      snake_case							(	self      ):
										__lowerCAmelCase							       =     super().to_dict()
										if isinstance(self.esmfold_config       ,  __a      ):
													__lowerCAmelCase							       =     self.esmfold_config.to_dict()
										return output
@dataclass
class     _UpperCamelCase    :
							'''simple docstring'''







							__UpperCAmelCase		:       str							 =None
							__UpperCAmelCase		:       bool							 =True
							__UpperCAmelCase		:       bool							 =False
							__UpperCAmelCase		:       bool							 =False
							__UpperCAmelCase		:       bool							 =False
							__UpperCAmelCase		:       float							 =0

							__UpperCAmelCase		:       bool							 =True
							__UpperCAmelCase		:       bool							 =False

							__UpperCAmelCase		:       int							 =1_2_8
							__UpperCAmelCase		:       "TrunkConfig"							 =None

							def      snake_case							(	self      ):
										if self.trunk is None:
													__lowerCAmelCase							       =     TrunkConfig()
										elif isinstance(self.trunk       ,  __a      ):
													__lowerCAmelCase							       =     TrunkConfig(**self.trunk      )



							def      snake_case							(	self      ):
										__lowerCAmelCase							       =     asdict(self      )
										__lowerCAmelCase							       =     self.trunk.to_dict()
										return output
@dataclass
class     _UpperCamelCase    :
							'''simple docstring'''







							__UpperCAmelCase		:       int							 =4_8
							__UpperCAmelCase		:       int							 =1_0_2_4
							__UpperCAmelCase		:       int							 =1_2_8
							__UpperCAmelCase		:       int							 =3_2
							__UpperCAmelCase		:       int							 =3_2
							__UpperCAmelCase		:       int							 =3_2
							__UpperCAmelCase		:       float							 =0
							__UpperCAmelCase		:       float							 =0
							__UpperCAmelCase		:       bool							 =False
							__UpperCAmelCase		:       int							 =4
							__UpperCAmelCase		:       Optional[int]							 =1_2_8
							__UpperCAmelCase		:       "StructureModuleConfig"							 =None

							def      snake_case							(	self      ):
										if self.structure_module is None:
													__lowerCAmelCase							       =     StructureModuleConfig()
										elif isinstance(self.structure_module       ,  __a      ):
													__lowerCAmelCase							       =     StructureModuleConfig(**self.structure_module      )

										if self.max_recycles <= 0:
													raise ValueError(f"`max_recycles` should be positive, got {self.max_recycles}."      )
										if self.sequence_state_dim % self.sequence_state_dim != 0:
													raise ValueError(
													    "`sequence_state_dim` should be a round multiple of `sequence_state_dim`, got"
													    f" {self.sequence_state_dim} and {self.sequence_state_dim}."      )
										if self.pairwise_state_dim % self.pairwise_state_dim != 0:
													raise ValueError(
													    "`pairwise_state_dim` should be a round multiple of `pairwise_state_dim`, got"
													    f" {self.pairwise_state_dim} and {self.pairwise_state_dim}."      )

										__lowerCAmelCase							       =     self.sequence_state_dim // self.sequence_head_width
										__lowerCAmelCase							       =     self.pairwise_state_dim // self.pairwise_head_width

										if self.sequence_state_dim != sequence_num_heads * self.sequence_head_width:
													raise ValueError(
													    "`sequence_state_dim` should be equal to `sequence_num_heads * sequence_head_width, got"
													    f" {self.sequence_state_dim} != {sequence_num_heads} * {self.sequence_head_width}."      )
										if self.pairwise_state_dim != pairwise_num_heads * self.pairwise_head_width:
													raise ValueError(
													    "`pairwise_state_dim` should be equal to `pairwise_num_heads * pairwise_head_width, got"
													    f" {self.pairwise_state_dim} != {pairwise_num_heads} * {self.pairwise_head_width}."      )
										if self.pairwise_state_dim % 2 != 0:
													raise ValueError(f"`pairwise_state_dim` should be even, got {self.pairwise_state_dim}."      )

										if self.dropout >= 0.4:
													raise ValueError(f"`dropout` should not be greater than 0.4, got {self.dropout}."      )



							def      snake_case							(	self      ):
										__lowerCAmelCase							       =     asdict(self      )
										__lowerCAmelCase							       =     self.structure_module.to_dict()
										return output
@dataclass
class     _UpperCamelCase    :
							'''simple docstring'''







							__UpperCAmelCase		:       int							 =3_8_4
							__UpperCAmelCase		:       int							 =1_2_8
							__UpperCAmelCase		:       int							 =1_6
							__UpperCAmelCase		:       int							 =1_2_8
							__UpperCAmelCase		:       int							 =1_2
							__UpperCAmelCase		:       int							 =4
							__UpperCAmelCase		:       int							 =8
							__UpperCAmelCase		:       float							 =0.1
							__UpperCAmelCase		:       int							 =8
							__UpperCAmelCase		:       int							 =1
							__UpperCAmelCase		:       int							 =2
							__UpperCAmelCase		:       int							 =7
							__UpperCAmelCase		:       int							 =1_0
							__UpperCAmelCase		:       float							 =1E-8
							__UpperCAmelCase		:       float							 =1E5

							def      snake_case							(	self      ):
										return asdict(self      )


def _lowerCamelCase      (						):

			'''simple docstring'''




			return (
			    "<cls>",
			    "<pad>",
			    "<eos>",
			    "<unk>",
			    "L",
			    "A",
			    "G",
			    "V",
			    "S",
			    "E",
			    "R",
			    "T",
			    "I",
			    "D",
			    "P",
			    "K",
			    "Q",
			    "N",
			    "F",
			    "Y",
			    "M",
			    "H",
			    "W",
			    "C",
			    "X",
			    "B",
			    "U",
			    "Z",
			    "O",
			    ".",
			    "-",
			    "<null_1>",
			    "<mask>",
			)








"""simple docstring"""


from __future__ import annotations

import math

import numpy as np
from numpy.linalg import norm


def _lowerCamelCase      (						_UpperCamelCase       ,					_UpperCamelCase ):

			'''simple docstring'''




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


def _lowerCamelCase      (						_UpperCamelCase       ,					_UpperCamelCase ):

			'''simple docstring'''




			if dataset.ndim != value_array.ndim:
						__lowerCAmelCase							       =     (
						    "Wrong input data's dimensions... "
						    f"dataset : {dataset.ndim}, value_array : {value_array.ndim}"
						)
						raise ValueError(_UpperCamelCase )

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

			if dataset.dtype != value_array.dtype:
						__lowerCAmelCase							       =     (
						    "Input data have different datatype... "
						    f"dataset : {dataset.dtype}, value_array : {value_array.dtype}"
						)
						raise TypeError(_UpperCamelCase )

			__lowerCAmelCase							       =     []

			for value in value_array:
						__lowerCAmelCase							       =     euclidean(_UpperCamelCase       ,					dataset[0] )
						__lowerCAmelCase							       =     dataset[0].tolist()

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

									if dist > temp_dist:
												__lowerCAmelCase							       =     temp_dist
												__lowerCAmelCase							       =     dataset_value.tolist()

						answer.append([vector, dist] )

			return answer


def _lowerCamelCase      (						_UpperCamelCase       ,					_UpperCamelCase ):

			'''simple docstring'''




			return np.dot(_UpperCamelCase       ,					_UpperCamelCase ) / (norm(_UpperCamelCase ) * norm(_UpperCamelCase ))


if __name__ == "__main__":
	import doctest

	doctest.testmod()




