
"""simple docstring"""






from dataclasses import asdict, dataclass
from typing import Optional

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


lowerCamelCase__ :       str						     =			logging.get_logger(__name__)

# TODO Update this
lowerCamelCase__ :       str						     =			{
    "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 				lowercase__(				_UpperCAmelCase   ):
	'''simple docstring'''

	UpperCamelCase				=  """esm"""





	def __init__(						self    :int		, lowerCamelCase_    :int=None		, lowerCamelCase_    :int=None		, lowerCamelCase_    :Union[str, Any]=None		, lowerCamelCase_    :Dict=7_68		, lowerCamelCase_    :Optional[Any]=12		, lowerCamelCase_    :Optional[Any]=12		, lowerCamelCase_    :Dict=30_72		, lowerCamelCase_    :Optional[int]=0.1		, lowerCamelCase_    :Any=0.1		, lowerCamelCase_    :Dict=10_26		, lowerCamelCase_    :List[str]=0.0_2		, lowerCamelCase_    :Optional[Any]=1E-12		, lowerCamelCase_    :Dict="absolute"		, lowerCamelCase_    :str=True		, lowerCamelCase_    :Optional[Any]=None		, lowerCamelCase_    :List[Any]=False		, lowerCamelCase_    :Optional[Any]=False		, lowerCamelCase_    :Dict=None		, lowerCamelCase_    :Optional[int]=None		, **lowerCamelCase_    :Dict		, )							->			Union[str, Any]:







			'''simple docstring'''




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

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







	def   __lowerCAmelCase (						self    :Any					)							->			Optional[int]:







			'''simple docstring'''




			SCREAMING_SNAKE_CASE       :     Any				= super().to_dict()
			if isinstance(self.esmfold_config		, lowerCamelCase_					):
					SCREAMING_SNAKE_CASE       :     List[str]				= self.esmfold_config.to_dict()
			return output





@dataclass
class 				lowercase__:
	'''simple docstring'''

	UpperCamelCase				=  None
	UpperCamelCase				=  True
	UpperCamelCase				=  False
	UpperCamelCase				=  False
	UpperCamelCase				=  False
	UpperCamelCase				=  0

	UpperCamelCase				=  True
	UpperCamelCase				=  False

	UpperCamelCase				=  1_28
	UpperCamelCase				=  None





	def   __lowerCAmelCase (						self    :str					)							->			Tuple:







			'''simple docstring'''




			if self.trunk is None:
					SCREAMING_SNAKE_CASE       :     str				= TrunkConfig()
			elif isinstance(self.trunk		, lowerCamelCase_					):
					SCREAMING_SNAKE_CASE       :     int				= TrunkConfig(**self.trunk					)







	def   __lowerCAmelCase (						self    :List[str]					)							->			Optional[Any]:







			'''simple docstring'''




			SCREAMING_SNAKE_CASE       :     Union[str, Any]				= asdict(self					)
			SCREAMING_SNAKE_CASE       :     Union[str, Any]				= self.trunk.to_dict()
			return output





@dataclass
class 				lowercase__:
	'''simple docstring'''

	UpperCamelCase				=  48
	UpperCamelCase				=  10_24
	UpperCamelCase				=  1_28
	UpperCamelCase				=  32
	UpperCamelCase				=  32
	UpperCamelCase				=  32
	UpperCamelCase				=  0
	UpperCamelCase				=  0
	UpperCamelCase				=  False
	UpperCamelCase				=  4
	UpperCamelCase				=  1_28
	UpperCamelCase				=  None





	def   __lowerCAmelCase (						self    :Dict					)							->			int:







			'''simple docstring'''




			if self.structure_module is None:
					SCREAMING_SNAKE_CASE       :     Dict				= StructureModuleConfig()
			elif isinstance(self.structure_module		, lowerCamelCase_					):
					SCREAMING_SNAKE_CASE       :     Union[str, Any]				= 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}."					)

			SCREAMING_SNAKE_CASE       :     Tuple				= self.sequence_state_dim // self.sequence_head_width
			SCREAMING_SNAKE_CASE       :     Any				= 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    :List[Any]					)							->			Optional[Any]:







			'''simple docstring'''




			SCREAMING_SNAKE_CASE       :     Union[str, Any]				= asdict(self					)
			SCREAMING_SNAKE_CASE       :     Tuple				= self.structure_module.to_dict()
			return output





@dataclass
class 				lowercase__:
	'''simple docstring'''

	UpperCamelCase				=  3_84
	UpperCamelCase				=  1_28
	UpperCamelCase				=  16
	UpperCamelCase				=  1_28
	UpperCamelCase				=  12
	UpperCamelCase				=  4
	UpperCamelCase				=  8
	UpperCamelCase				=  0.1
	UpperCamelCase				=  8
	UpperCamelCase				=  1
	UpperCamelCase				=  2
	UpperCamelCase				=  7
	UpperCamelCase				=  10
	UpperCamelCase				=  1E-8
	UpperCamelCase				=  1E5





	def   __lowerCAmelCase (						self    :Union[str, Any]					)							->			Any:







			'''simple docstring'''




			return asdict(self					)





def __A						(   )->							str:




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






def __A						(   a_ :							list		,		a_ :							int		,		a_ :							int = 0		,		a_ :							int = 0     )->							int:




		'''simple docstring'''






		SCREAMING_SNAKE_CASE       :     str				= right or len(a_     ) - 1
		if left > right:
				return -1
		elif list_data[left] == key:
				return left
		elif list_data[right] == key:
				return right
		else:
				return search(a_		,		a_		,		left + 1		,		right - 1     )


if __name__ == "__main__":
					import doctest

					doctest.testmod()





