
"""simple docstring"""

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 	_lowercase       (    __UpperCAmelCase		):
	lowercase_				=     'esm'




	def __init__(			self		,			UpperCAmelCase_=None		,			UpperCAmelCase_=None		,			UpperCAmelCase_=None		,			UpperCAmelCase_=768		,			UpperCAmelCase_=12		,			UpperCAmelCase_=12		,			UpperCAmelCase_=3072		,			UpperCAmelCase_=0.1		,			UpperCAmelCase_=0.1		,			UpperCAmelCase_=1026		,			UpperCAmelCase_=0.02		,			UpperCAmelCase_=1E-1_2		,			UpperCAmelCase_="absolute"		,			UpperCAmelCase_=True		,			UpperCAmelCase_=None		,			UpperCAmelCase_=False		,			UpperCAmelCase_=False		,			UpperCAmelCase_=None		,			UpperCAmelCase_=None		,			**UpperCAmelCase_		,			)		->							Any:
			super().__init__(pad_token_id=_SCREAMING_SNAKE_CASE		,			mask_token_id=_SCREAMING_SNAKE_CASE		,			**_SCREAMING_SNAKE_CASE )

			lowerCamelCase					:      Union[str, Any]          =   vocab_size
			lowerCamelCase					:      Union[str, Any]          =   hidden_size
			lowerCamelCase					:      Optional[Any]          =   num_hidden_layers
			lowerCamelCase					:      Any          =   num_attention_heads
			lowerCamelCase					:      Any          =   intermediate_size
			lowerCamelCase					:      List[str]          =   hidden_dropout_prob
			lowerCamelCase					:      str          =   attention_probs_dropout_prob
			lowerCamelCase					:      List[Any]          =   max_position_embeddings
			lowerCamelCase					:      Union[str, Any]          =   initializer_range
			lowerCamelCase					:      int          =   layer_norm_eps
			lowerCamelCase					:      Union[str, Any]          =   position_embedding_type
			lowerCamelCase					:      List[Any]          =   use_cache
			lowerCamelCase					:      int          =   emb_layer_norm_before
			lowerCamelCase					:      str          =   token_dropout
			lowerCamelCase					:      Optional[Any]          =   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					:      Tuple          =   EsmFoldConfig()
					elif isinstance(_SCREAMING_SNAKE_CASE		,			_SCREAMING_SNAKE_CASE ):
							lowerCamelCase					:      List[Any]          =   EsmFoldConfig(**_SCREAMING_SNAKE_CASE )
					lowerCamelCase					:      int          =   esmfold_config
					if vocab_list is None:
							logger.warning('No vocab_list supplied for folding model, assuming the ESM-2 vocabulary!' )
							lowerCamelCase					:      Any          =   get_default_vocab_list()
					else:
							lowerCamelCase					:      str          =   vocab_list
			else:
					lowerCamelCase					:      List[Any]          =   None
					lowerCamelCase					:      List[str]          =   None
			if self.esmfold_config is not None and getattr(self.esmfold_config		,			'use_esm_attn_map'		,			_SCREAMING_SNAKE_CASE ):
					raise ValueError('The HuggingFace port of ESMFold does not support use_esm_attn_map at this time!' )




	def       _UpperCamelCase   (			self )		->							Optional[Any]:
			lowerCamelCase					:      Union[str, Any]          =   super().to_dict()
			if isinstance(self.esmfold_config		,			_SCREAMING_SNAKE_CASE ):
					lowerCamelCase					:      Tuple          =   self.esmfold_config.to_dict()
			return output






@dataclass
class 	_lowercase       :
	lowercase_				=     None
	lowercase_				=     True
	lowercase_				=     False
	lowercase_				=     False
	lowercase_				=     False
	lowercase_				=     0

	lowercase_				=     True
	lowercase_				=     False

	lowercase_				=     1_2_8
	lowercase_				=     None




	def       _UpperCamelCase   (			self )		->							List[str]:





			if self.trunk is None:
					lowerCamelCase					:      Optional[Any]          =   TrunkConfig()
			elif isinstance(self.trunk		,			_SCREAMING_SNAKE_CASE ):
					lowerCamelCase					:      Any          =   TrunkConfig(**self.trunk )




	def       _UpperCamelCase   (			self )		->							Tuple:
			lowerCamelCase					:      Any          =   asdict(self )
			lowerCamelCase					:      int          =   self.trunk.to_dict()
			return output






@dataclass
class 	_lowercase       :
	lowercase_				=     4_8
	lowercase_				=     1_0_2_4
	lowercase_				=     1_2_8
	lowercase_				=     3_2
	lowercase_				=     3_2
	lowercase_				=     3_2
	lowercase_				=     0
	lowercase_				=     0
	lowercase_				=     False
	lowercase_				=     4
	lowercase_				=     1_2_8
	lowercase_				=     None




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





			if self.structure_module is None:
					lowerCamelCase					:      Any          =   StructureModuleConfig()
			elif isinstance(self.structure_module		,			_SCREAMING_SNAKE_CASE ):
					lowerCamelCase					:      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}.""" )

			lowerCamelCase					:      Optional[Any]          =   self.sequence_state_dim // self.sequence_head_width
			lowerCamelCase					:      Tuple          =   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       _UpperCamelCase   (			self )		->							Union[str, Any]:
			lowerCamelCase					:      List[Any]          =   asdict(self )
			lowerCamelCase					:      Union[str, Any]          =   self.structure_module.to_dict()
			return output






@dataclass
class 	_lowercase       :
	lowercase_				=     3_8_4
	lowercase_				=     1_2_8
	lowercase_				=     1_6
	lowercase_				=     1_2_8
	lowercase_				=     1_2
	lowercase_				=     4
	lowercase_				=     8
	lowercase_				=     0.1
	lowercase_				=     8
	lowercase_				=     1
	lowercase_				=     2
	lowercase_				=     7
	lowercase_				=     1_0
	lowercase_				=     1e-8
	lowercase_				=     1e5




	def       _UpperCamelCase   (			self )		->							Optional[Any]:
			return asdict(self )


def 		UpperCAmelCase (		):





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

# Lint as: python3
import dataclasses
import re
from dataclasses import dataclass
from functools import total_ordering
from typing import Optional, Union


_A						=			re.compile(r'^(?P<major>\d+)' r'\.(?P<minor>\d+)' r'\.(?P<patch>\d+)$')






@total_ordering
@dataclass
class 	_lowercase       :
	lowercase_				=     42
	lowercase_				=     None
	lowercase_				=     None
	lowercase_				=     None
	lowercase_				=     None




	def       _UpperCamelCase   (			self )		->							List[str]:
			lowerCamelCase     ,   lowerCamelCase     ,   lowerCamelCase					:      List[str]          =   _str_to_version_tuple(self.version_str )




	def __repr__(			self )		->							int:
			return F"""{self.tuple[0]}.{self.tuple[1]}.{self.tuple[2]}"""




	@property
	def       _UpperCamelCase   (			self )		->							Dict:
			return self.major, self.minor, self.patch




	def       _UpperCamelCase   (			self		,			UpperCAmelCase_ )		->							Optional[int]:
			if isinstance(UpperCAmelCase_		,			UpperCAmelCase_ ):
					return Version(UpperCAmelCase_ )
			elif isinstance(UpperCAmelCase_		,			UpperCAmelCase_ ):
					return other
			raise TypeError(F"""{other} (type {type(UpperCAmelCase_ )}) cannot be compared to version.""" )




	def __eq__(			self		,			UpperCAmelCase_ )		->							Optional[Any]:
			try:
					lowerCamelCase					:      List[str]          =   self._validate_operand(UpperCAmelCase_ )
			except (TypeError, ValueError):
					return False
			else:
					return self.tuple == other.tuple




	def __lt__(			self		,			UpperCAmelCase_ )		->							Optional[int]:
			lowerCamelCase					:      Optional[int]          =   self._validate_operand(UpperCAmelCase_ )
			return self.tuple < other.tuple




	def __hash__(			self )		->							Optional[Any]:
			return hash(_version_tuple_to_str(self.tuple ) )




	@classmethod
	def       _UpperCamelCase   (			cls		,			UpperCAmelCase_ )		->							Union[str, Any]:
			lowerCamelCase					:      str          =   {f.name for f in dataclasses.fields(cls )}
			return cls(**{k: v for k, v in dic.items() if k in field_names} )




	def       _UpperCamelCase   (			self )		->							str:
			return self.version_str


def 		UpperCAmelCase (		a_      ):





		'''simple docstring'''


		lowerCamelCase					:      Tuple          =   _VERSION_REG.match(a_      )
		if not res:
				raise ValueError(F"""Invalid version '{version_str}'. Format should be x.y.z with {{x,y,z}} being digits."""      )
		return tuple(int(a_      ) for v in [res.group('major'      ), res.group('minor'      ), res.group('patch'      )]      )





def 		UpperCAmelCase (		a_      ):





		'''simple docstring'''


		return ".".join(str(a_      ) for v in version_tuple      )






