





from dataclasses import asdict, dataclass
from typing import Optional

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


_a						=   logging.get_logger(__name__)

# TODO Update this
_a						=   {
    "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       __A					(					UpperCAmelCase_				):

			'''simple docstring'''







			lowerCAmelCase_							  =		'esm'





			def __init__(					self ,						__lowerCAmelCase=None ,						__lowerCAmelCase=None ,						__lowerCAmelCase=None ,						__lowerCAmelCase=7_6_8 ,						__lowerCAmelCase=1_2 ,						__lowerCAmelCase=1_2 ,						__lowerCAmelCase=3_0_7_2 ,						__lowerCAmelCase=0.1 ,						__lowerCAmelCase=0.1 ,						__lowerCAmelCase=1_0_2_6 ,						__lowerCAmelCase=0.02 ,						__lowerCAmelCase=1E-12 ,						__lowerCAmelCase="absolute" ,						__lowerCAmelCase=True ,						__lowerCAmelCase=None ,						__lowerCAmelCase=False ,						__lowerCAmelCase=False ,						__lowerCAmelCase=None ,						__lowerCAmelCase=None ,						**__lowerCAmelCase ,						):



				'''simple docstring'''







				super().__init__(pad_token_id=_lowercase ,						mask_token_id=_lowercase ,						**_lowercase							)

				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(_lowercase ,						_lowercase							):
						lowerCamelCase__              =	EsmFoldConfig(**_lowercase							)
					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''' ,						_lowercase							):
					raise ValueError('''The HuggingFace port of ESMFold does not support use_esm_attn_map at this time!'''							)





			def 	__lowerCamelCase       (					self							):



				'''simple docstring'''







				lowerCamelCase__              =	super().to_dict()
				if isinstance(self.esmfold_config ,						_lowercase							):
					lowerCamelCase__              =	self.esmfold_config.to_dict()
				return output






@dataclass
class       __A					:

			'''simple docstring'''







			lowerCAmelCase_							  =		None
			lowerCAmelCase_							  =		True
			lowerCAmelCase_							  =		False
			lowerCAmelCase_							  =		False
			lowerCAmelCase_							  =		False
			lowerCAmelCase_							  =		0

			lowerCAmelCase_							  =		True
			lowerCAmelCase_							  =		False

			lowerCAmelCase_							  =		128
			lowerCAmelCase_							  =		None





			def 	__lowerCamelCase       (					self							):



				'''simple docstring'''







				if self.trunk is None:
					lowerCamelCase__              =	TrunkConfig()
				elif isinstance(self.trunk ,						_lowercase							):
					lowerCamelCase__              =	TrunkConfig(**self.trunk							)





			def 	__lowerCamelCase       (					self							):



				'''simple docstring'''







				lowerCamelCase__              =	asdict(self							)
				lowerCamelCase__              =	self.trunk.to_dict()
				return output






@dataclass
class       __A					:

			'''simple docstring'''







			lowerCAmelCase_							  =		48
			lowerCAmelCase_							  =		1024
			lowerCAmelCase_							  =		128
			lowerCAmelCase_							  =		32
			lowerCAmelCase_							  =		32
			lowerCAmelCase_							  =		32
			lowerCAmelCase_							  =		0
			lowerCAmelCase_							  =		0
			lowerCAmelCase_							  =		False
			lowerCAmelCase_							  =		4
			lowerCAmelCase_							  =		128
			lowerCAmelCase_							  =		None





			def 	__lowerCamelCase       (					self							):



				'''simple docstring'''







				if self.structure_module is None:
					lowerCamelCase__              =	StructureModuleConfig()
				elif isinstance(self.structure_module ,						_lowercase							):
					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 	__lowerCamelCase       (					self							):



				'''simple docstring'''







				lowerCamelCase__              =	asdict(self							)
				lowerCamelCase__              =	self.structure_module.to_dict()
				return output






@dataclass
class       __A					:

			'''simple docstring'''







			lowerCAmelCase_							  =		384
			lowerCAmelCase_							  =		128
			lowerCAmelCase_							  =		16
			lowerCAmelCase_							  =		128
			lowerCAmelCase_							  =		12
			lowerCAmelCase_							  =		4
			lowerCAmelCase_							  =		8
			lowerCAmelCase_							  =		0.1
			lowerCAmelCase_							  =		8
			lowerCAmelCase_							  =		1
			lowerCAmelCase_							  =		2
			lowerCAmelCase_							  =		7
			lowerCAmelCase_							  =		10
			lowerCAmelCase_							  =		1e-8
			lowerCAmelCase_							  =		1e5





			def 	__lowerCamelCase       (					self							):



				'''simple docstring'''







				return asdict(self							)





def lowerCAmelCase__()       ->   int:







	'''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>",
	)










from __future__ import annotations





def lowerCAmelCase__(__snake_case ,__snake_case = None ,__snake_case = None							)       ->   None:







	'''simple docstring'''







	if start is None:
		lowerCamelCase__              =	0

	if end is None:
		lowerCamelCase__              =	len(__snake_case							) - 1

	if start >= end:
		return

	lowerCamelCase__              =	(start + end) // 2

	slowsort(__snake_case ,__snake_case ,__snake_case							)
	slowsort(__snake_case ,mid + 1 ,__snake_case							)

	if sequence[end] < sequence[mid]:
		lowerCamelCase__       ,			lowerCamelCase__              =	sequence[mid], sequence[end]

	slowsort(__snake_case ,__snake_case ,end - 1							)


if __name__ == "__main__":
			from doctest import testmod

			testmod()



