



'''simple docstring'''




from dataclasses import asdict, dataclass
from typing import Optional

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


UpperCamelCase__ :			str												=				logging.get_logger(__name__)

# TODO Update this
UpperCamelCase__ :			int												=				{
    """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						(							__UpperCAmelCase					):


			'''simple docstring'''

			_A   :	List[Any]    					=	'''esm'''

			def __init__(							self  :				Union[str, Any]							,  lowerCAmelCase__  :				List[Any]=None							,  lowerCAmelCase__  :				str=None							,  lowerCAmelCase__  :				Union[str, Any]=None							,  lowerCAmelCase__  :				List[Any]=7_6_8							,  lowerCAmelCase__  :				Any=1_2							,  lowerCAmelCase__  :				Optional[Any]=1_2							,  lowerCAmelCase__  :				Optional[Any]=3_0_7_2							,  lowerCAmelCase__  :				Optional[Any]=0.1							,  lowerCAmelCase__  :				Optional[int]=0.1							,  lowerCAmelCase__  :				List[str]=1_0_2_6							,  lowerCAmelCase__  :				Any=0.02							,  lowerCAmelCase__  :				str=1E-12							,  lowerCAmelCase__  :				Optional[int]="absolute"							,  lowerCAmelCase__  :				Dict=True							,  lowerCAmelCase__  :				Dict=None							,  lowerCAmelCase__  :				Optional[Any]=False							,  lowerCAmelCase__  :				int=False							,  lowerCAmelCase__  :				List[str]=None							,  lowerCAmelCase__  :				str=None							,  **lowerCAmelCase__  :				int							,  ):





					"""simple docstring"""






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

					__SCREAMING_SNAKE_CASE :	Optional[int]					 =	vocab_size
					__SCREAMING_SNAKE_CASE :	List[str]					 =	hidden_size
					__SCREAMING_SNAKE_CASE :	Optional[Any]					 =	num_hidden_layers
					__SCREAMING_SNAKE_CASE :	Optional[Any]					 =	num_attention_heads
					__SCREAMING_SNAKE_CASE :	List[str]					 =	intermediate_size
					__SCREAMING_SNAKE_CASE :	Optional[int]					 =	hidden_dropout_prob
					__SCREAMING_SNAKE_CASE :	List[str]					 =	attention_probs_dropout_prob
					__SCREAMING_SNAKE_CASE :	str					 =	max_position_embeddings
					__SCREAMING_SNAKE_CASE :	List[Any]					 =	initializer_range
					__SCREAMING_SNAKE_CASE :	Any					 =	layer_norm_eps
					__SCREAMING_SNAKE_CASE :	str					 =	position_embedding_type
					__SCREAMING_SNAKE_CASE :	List[str]					 =	use_cache
					__SCREAMING_SNAKE_CASE :	Optional[int]					 =	emb_layer_norm_before
					__SCREAMING_SNAKE_CASE :	Optional[int]					 =	token_dropout
					__SCREAMING_SNAKE_CASE :	Union[str, 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."""		)
									__SCREAMING_SNAKE_CASE :	List[Any]					 =	EsmFoldConfig()
							elif isinstance(lowerCAmelCase__							,  lowerCAmelCase__		):
									__SCREAMING_SNAKE_CASE :	Dict					 =	EsmFoldConfig(**lowerCAmelCase__		)
							__SCREAMING_SNAKE_CASE :	Union[str, Any]					 =	esmfold_config
							if vocab_list is None:
									logger.warning("""No vocab_list supplied for folding model, assuming the ESM-2 vocabulary!"""		)
									__SCREAMING_SNAKE_CASE :	Any					 =	get_default_vocab_list()
							else:
									__SCREAMING_SNAKE_CASE :	List[Any]					 =	vocab_list
					else:
							__SCREAMING_SNAKE_CASE :	Tuple					 =	None
							__SCREAMING_SNAKE_CASE :	List[Any]					 =	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 UpperCamelCase__      (							self  :				List[str]		):





					"""simple docstring"""






					__SCREAMING_SNAKE_CASE :	Optional[int]					 =	super().to_dict()
					if isinstance(self.esmfold_config							,  lowerCAmelCase__		):
							__SCREAMING_SNAKE_CASE :	List[str]					 =	self.esmfold_config.to_dict()
					return output






@dataclass
class 		_UpperCamelCase						:


			'''simple docstring'''

			_A   :	List[str]    					=	None
			_A   :	List[str]    					=	True
			_A   :	List[Any]    					=	False
			_A   :	str    					=	False
			_A   :	Optional[int]    					=	False
			_A   :	List[Any]    					=	0

			_A   :	Union[str, Any]    					=	True
			_A   :	List[Any]    					=	False

			_A   :	List[str]    					=	128
			_A   :	Optional[Any]    					=	None

			def UpperCamelCase__      (							self  :				List[str]		):





					"""simple docstring"""






					if self.trunk is None:
							__SCREAMING_SNAKE_CASE :	Tuple					 =	TrunkConfig()
					elif isinstance(self.trunk							,  lowerCAmelCase__		):
							__SCREAMING_SNAKE_CASE :	Optional[Any]					 =	TrunkConfig(**self.trunk		)



			def UpperCamelCase__      (							self  :				List[str]		):





					"""simple docstring"""






					__SCREAMING_SNAKE_CASE :	str					 =	asdict(self		)
					__SCREAMING_SNAKE_CASE :	List[str]					 =	self.trunk.to_dict()
					return output






@dataclass
class 		_UpperCamelCase						:


			'''simple docstring'''

			_A   :	List[Any]    					=	48
			_A   :	Any    					=	1024
			_A   :	Optional[Any]    					=	128
			_A   :	Optional[int]    					=	32
			_A   :	List[str]    					=	32
			_A   :	str    					=	32
			_A   :	str    					=	0
			_A   :	List[Any]    					=	0
			_A   :	List[str]    					=	False
			_A   :	Dict    					=	4
			_A   :	str    					=	128
			_A   :	List[str]    					=	None

			def UpperCamelCase__      (							self  :				Tuple		):





					"""simple docstring"""






					if self.structure_module is None:
							__SCREAMING_SNAKE_CASE :	int					 =	StructureModuleConfig()
					elif isinstance(self.structure_module							,  lowerCAmelCase__		):
							__SCREAMING_SNAKE_CASE :	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 :	Dict					 =	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  :				Optional[int]		):





					"""simple docstring"""






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






@dataclass
class 		_UpperCamelCase						:


			'''simple docstring'''

			_A   :	int    					=	384
			_A   :	Union[str, Any]    					=	128
			_A   :	Union[str, Any]    					=	16
			_A   :	Union[str, Any]    					=	128
			_A   :	str    					=	12
			_A   :	Union[str, Any]    					=	4
			_A   :	Optional[int]    					=	8
			_A   :	Optional[int]    					=	0.1
			_A   :	Any    					=	8
			_A   :	Optional[Any]    					=	1
			_A   :	str    					=	2
			_A   :	int    					=	7
			_A   :	Tuple    					=	10
			_A   :	Any    					=	1E-8
			_A   :	Any    					=	1E5

			def UpperCamelCase__      (							self  :				str		):





					"""simple docstring"""






					return asdict(self		)


def        lowerCAmelCase_     (			):
		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 ..utils import DummyObject, requires_backends






class 		_UpperCamelCase						(							metaclass=lowerCamelCase__					):


			'''simple docstring'''

			_A   :	Optional[int]    					=	['''onnx''']

			def __init__(							self  :				List[str]							,  *lowerCAmelCase__  :				Optional[int]							,  **lowerCAmelCase__  :				List[Any]		):





					"""simple docstring"""






					requires_backends(self							,  ["""onnx"""]		)

			@classmethod
			def UpperCamelCase__      (							cls  :				Optional[int]							,  *lowerCAmelCase__  :				int							,  **lowerCAmelCase__  :				int		):





					"""simple docstring"""






					requires_backends(cls							,  ["""onnx"""]		)



			@classmethod
			def UpperCamelCase__      (							cls  :				Tuple							,  *lowerCAmelCase__  :				List[str]							,  **lowerCAmelCase__  :				Optional[Any]		):





					"""simple docstring"""






					requires_backends(cls							,  ["""onnx"""]		)