


from dataclasses import asdict, dataclass
from typing import Optional

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


_lowercase       		= logging.get_logger(__name__)

# TODO Update this
_lowercase       		= {
    '''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 __snake_case		( __UpperCamelCase ):





		"""simple docstring"""







		UpperCamelCase_				      =   'esm'



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




								'''simple docstring'''

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

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




								'''simple docstring'''

								lowerCAmelCase_	:     Tuple          = super().to_dict()
								if isinstance(self.esmfold_config						,lowerCAmelCase__      ):
														lowerCAmelCase_	:     int          = self.esmfold_config.to_dict()
								return output






@dataclass
class __snake_case		:





		"""simple docstring"""







		UpperCamelCase_				      =   None
		UpperCamelCase_				      =   True
		UpperCamelCase_				      =   False
		UpperCamelCase_				      =   False
		UpperCamelCase_				      =   False
		UpperCamelCase_				      =   0

		UpperCamelCase_				      =   True
		UpperCamelCase_				      =   False

		UpperCamelCase_				      =   1_2_8
		UpperCamelCase_				      =   None



		def  UpperCAmelCase_							(							self    :   Tuple      )      ->							Optional[int]:




								'''simple docstring'''

								if self.trunk is None:
														lowerCAmelCase_	:     Any          = TrunkConfig()
								elif isinstance(self.trunk						,lowerCAmelCase__      ):
														lowerCAmelCase_	:     str          = TrunkConfig(**self.trunk      )



		def  UpperCAmelCase_							(							self    :   int      )      ->							int:




								'''simple docstring'''

								lowerCAmelCase_	:     Optional[int]          = asdict(self      )
								lowerCAmelCase_	:     Any          = self.trunk.to_dict()
								return output






@dataclass
class __snake_case		:





		"""simple docstring"""







		UpperCamelCase_				      =   4_8
		UpperCamelCase_				      =   1_0_2_4
		UpperCamelCase_				      =   1_2_8
		UpperCamelCase_				      =   3_2
		UpperCamelCase_				      =   3_2
		UpperCamelCase_				      =   3_2
		UpperCamelCase_				      =   0
		UpperCamelCase_				      =   0
		UpperCamelCase_				      =   False
		UpperCamelCase_				      =   4
		UpperCamelCase_				      =   1_2_8
		UpperCamelCase_				      =   None



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




								'''simple docstring'''

								if self.structure_module is None:
														lowerCAmelCase_	:     Optional[Any]          = StructureModuleConfig()
								elif isinstance(self.structure_module						,lowerCAmelCase__      ):
														lowerCAmelCase_	:     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}.'''      )

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




								'''simple docstring'''

								lowerCAmelCase_	:     int          = asdict(self      )
								lowerCAmelCase_	:     Optional[Any]          = self.structure_module.to_dict()
								return output






@dataclass
class __snake_case		:





		"""simple docstring"""







		UpperCamelCase_				      =   3_8_4
		UpperCamelCase_				      =   1_2_8
		UpperCamelCase_				      =   1_6
		UpperCamelCase_				      =   1_2_8
		UpperCamelCase_				      =   1_2
		UpperCamelCase_				      =   4
		UpperCamelCase_				      =   8
		UpperCamelCase_				      =   0.1
		UpperCamelCase_				      =   8
		UpperCamelCase_				      =   1
		UpperCamelCase_				      =   2
		UpperCamelCase_				      =   7
		UpperCamelCase_				      =   1_0
		UpperCamelCase_				      =   1e-8
		UpperCamelCase_				      =   1e5



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




								'''simple docstring'''

								return asdict(self      )






def   UpperCamelCase			(      ):
						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

from collections.abc import Iterator
from typing import Generic, TypeVar

__magic_name__  							=	TypeVar('''T''')




class        _SCREAMING_SNAKE_CASE	(   Generic[T]			):
      def __init__(      self		,						lowerCamelCase			):
          snake_case__    =					data
          snake_case__    =					None



      def __str__(      self			):
          return F"""{self.data}"""





class        _SCREAMING_SNAKE_CASE	(   Generic[T]			):
      def __init__(      self			):
          snake_case__    =					None
      def __iter__(      self			):
          snake_case__    =					self.top
          while node:
              yield node.data
              snake_case__    =					node.next
      def __str__(      self			):
          return "->".join([str(lowerCamelCase			) for item in self]			)
      def __len__(      self			):
          return len(tuple(iter(self			)			)			)
      def A_      (      self			):
          return self.top is None
      def A_      (      self		,						lowerCamelCase			):
          snake_case__    =					Node(lowerCamelCase			)
          if not self.is_empty():
              snake_case__    =					self.top
          snake_case__    =					node
      def A_      (      self			):
          if self.is_empty():
              raise IndexError("pop from empty stack"			)
          assert isinstance(self.top		,						lowerCamelCase			)
          snake_case__    =					self.top
          snake_case__    =					self.top.next
          return pop_node.data
      def A_      (      self			):
          if self.is_empty():
              raise IndexError("peek from empty stack"			)

          assert self.top is not None
          return self.top.data



      def A_      (      self			):
          snake_case__    =					None


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

     testmod()



