



"""simple docstring"""





from dataclasses import asdict, dataclass
from typing import Optional

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


lowerCamelCase  			=		logging.get_logger(__name__)

# TODO Update this
lowerCamelCase  			=		{
    """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__  (       SCREAMING_SNAKE_CASE ):







       '''simple docstring'''


       UpperCamelCase		=	'''esm'''



       def __init__(				self     :    Union[str, Any]						,							_UpperCAmelCase     :    Optional[int]=None						,							_UpperCAmelCase     :    List[str]=None						,							_UpperCAmelCase     :    str=None						,							_UpperCAmelCase     :    List[str]=768						,							_UpperCAmelCase     :    Optional[int]=12						,							_UpperCAmelCase     :    List[str]=12						,							_UpperCAmelCase     :    str=3072						,							_UpperCAmelCase     :    List[Any]=0.1						,							_UpperCAmelCase     :    Optional[int]=0.1						,							_UpperCAmelCase     :    Any=1026						,							_UpperCAmelCase     :    str=0.02						,							_UpperCAmelCase     :    List[str]=1e-12						,							_UpperCAmelCase     :    Tuple="absolute"						,							_UpperCAmelCase     :    str=True						,							_UpperCAmelCase     :    Optional[Any]=None						,							_UpperCAmelCase     :    Optional[int]=False						,							_UpperCAmelCase     :    Optional[Any]=False						,							_UpperCAmelCase     :    List[str]=None						,							_UpperCAmelCase     :    List[str]=None						,							**_UpperCAmelCase     :    Dict						,							)					->		Tuple:


             '''simple docstring'''




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

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







       def 	lowercase__							(				self     :    Optional[Any]       )					->		Dict:


             '''simple docstring'''




             UpperCAmelCase_     					=				super().to_dict()
             if isinstance(self.esmfold_config						,							_UpperCAmelCase       ):
                   UpperCAmelCase_     					=				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 	lowercase__							(				self     :    Union[str, Any]       )					->		str:


             '''simple docstring'''




             if self.trunk is None:
                   UpperCAmelCase_     					=				TrunkConfig()
             elif isinstance(self.trunk						,							_UpperCAmelCase       ):
                   UpperCAmelCase_     					=				TrunkConfig(**self.trunk       )







       def 	lowercase__							(				self     :    Any       )					->		Tuple:


             '''simple docstring'''




             UpperCAmelCase_     					=				asdict(self       )
             UpperCAmelCase_     					=				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 	lowercase__							(				self     :    List[str]       )					->		str:


             '''simple docstring'''




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

             UpperCAmelCase_     					=				self.sequence_state_dim // self.sequence_head_width
             UpperCAmelCase_     					=				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 	lowercase__							(				self     :    List[str]       )					->		List[Any]:


             '''simple docstring'''




             UpperCAmelCase_     					=				asdict(self       )
             UpperCAmelCase_     					=				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 	lowercase__							(				self     :    List[str]       )					->		Optional[int]:


             '''simple docstring'''




             return asdict(self       )



def   a__      ( ):
      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 functools import lru_cache

@lru_cache
def  __lowerCamelCase					( _lowercase			)       ->      int:
     if num < 0:
          raise ValueError('Number should not be negative.'			)

     return 1 if num in (0, 1) else num * factorial(num - 1			)


if __name__ == "__main__":
 import doctest

 doctest.testmod()


