


from dataclasses import asdict, dataclass
from typing import Optional

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


snake_case				:    List[Any]       				=     logging.get_logger(__name__)

# TODO Update this
snake_case				:    Union[str, Any]       				=     {
    '''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  (      _snake_case							):
 SCREAMING_SNAKE_CASE__      =       'esm'




 def __init__(		self					,  _lowerCamelCase=None					,  _lowerCamelCase=None					,  _lowerCamelCase=None					,  _lowerCamelCase=768					,  _lowerCamelCase=12					,  _lowerCamelCase=12					,  _lowerCamelCase=3072					,  _lowerCamelCase=0.1					,  _lowerCamelCase=0.1					,  _lowerCamelCase=1026					,  _lowerCamelCase=0.02					,  _lowerCamelCase=1e-12					,  _lowerCamelCase="absolute"					,  _lowerCamelCase=True					,  _lowerCamelCase=None					,  _lowerCamelCase=False					,  _lowerCamelCase=False					,  _lowerCamelCase=None					,  _lowerCamelCase=None					,  **_lowerCamelCase					,  ):
       super().__init__(pad_token_id=_lowerCamelCase					,  mask_token_id=_lowerCamelCase					,  **_lowerCamelCase    )

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







@dataclass
class 		_snake_case  :
 SCREAMING_SNAKE_CASE__      =       None
 SCREAMING_SNAKE_CASE__      =       True
 SCREAMING_SNAKE_CASE__      =       False
 SCREAMING_SNAKE_CASE__      =       False
 SCREAMING_SNAKE_CASE__      =       False
 SCREAMING_SNAKE_CASE__      =       0

 SCREAMING_SNAKE_CASE__      =       True
 SCREAMING_SNAKE_CASE__      =       False

 SCREAMING_SNAKE_CASE__      =       128
 SCREAMING_SNAKE_CASE__      =       None




 def        SCREAMING_SNAKE_CASE__				(		self    ):
       if self.trunk is None:
             a						:List[str] 							=       TrunkConfig()
       elif isinstance(self.trunk					,  _lowerCamelCase    ):
             a						:List[Any] 							=       TrunkConfig(**self.trunk    )




 def        SCREAMING_SNAKE_CASE__				(		self    ):
       a						:Any 							=       asdict(self    )
       a						:Any 							=       self.trunk.to_dict()
       return output







@dataclass
class 		_snake_case  :
 SCREAMING_SNAKE_CASE__      =       48
 SCREAMING_SNAKE_CASE__      =       1024
 SCREAMING_SNAKE_CASE__      =       128
 SCREAMING_SNAKE_CASE__      =       32
 SCREAMING_SNAKE_CASE__      =       32
 SCREAMING_SNAKE_CASE__      =       32
 SCREAMING_SNAKE_CASE__      =       0
 SCREAMING_SNAKE_CASE__      =       0
 SCREAMING_SNAKE_CASE__      =       False
 SCREAMING_SNAKE_CASE__      =       4
 SCREAMING_SNAKE_CASE__      =       128
 SCREAMING_SNAKE_CASE__      =       None




 def        SCREAMING_SNAKE_CASE__				(		self    ):
       if self.structure_module is None:
             a						:List[Any] 							=       StructureModuleConfig()
       elif isinstance(self.structure_module					,  _lowerCamelCase    ):
             a						:Optional[int] 							=       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}.'''    )

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







@dataclass
class 		_snake_case  :
 SCREAMING_SNAKE_CASE__      =       384
 SCREAMING_SNAKE_CASE__      =       128
 SCREAMING_SNAKE_CASE__      =       16
 SCREAMING_SNAKE_CASE__      =       128
 SCREAMING_SNAKE_CASE__      =       12
 SCREAMING_SNAKE_CASE__      =       4
 SCREAMING_SNAKE_CASE__      =       8
 SCREAMING_SNAKE_CASE__      =       0.1
 SCREAMING_SNAKE_CASE__      =       8
 SCREAMING_SNAKE_CASE__      =       1
 SCREAMING_SNAKE_CASE__      =       2
 SCREAMING_SNAKE_CASE__      =       7
 SCREAMING_SNAKE_CASE__      =       10
 SCREAMING_SNAKE_CASE__      =       1e-8
 SCREAMING_SNAKE_CASE__      =       1e5




 def        SCREAMING_SNAKE_CASE__				(		self    ):
       return asdict(self    )







def 				__lowerCamelCase						( ):




      """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>",
      )









import sys

from .dependency_versions_table import deps
from .utils.versions import require_version, require_version_core


# define which module versions we always want to check at run time
# (usually the ones defined in `install_requires` in setup.py)
#
# order specific notes:
# - tqdm must be checked before tokenizers

snake_case				:    Union[str, Any]       				=     '''python tqdm regex requests packaging filelock numpy tokenizers'''.split()
if sys.version_info < (3, 7):
     pkgs_to_check_at_runtime.append('''dataclasses''')
if sys.version_info < (3, 8):
     pkgs_to_check_at_runtime.append('''importlib_metadata''')

for pkg in pkgs_to_check_at_runtime:
     if pkg in deps:
          if pkg == "tokenizers":
               # must be loaded here, or else tqdm check may fail
               from .utils import is_tokenizers_available

               if not is_tokenizers_available():
                    continue  # not required, check version only if installed

          require_version_core(deps[pkg])
     else:
          raise ValueError(F"""can't find {pkg} in {deps.keys()}, check dependency_versions_table.py""")
def 				__lowerCamelCase						( UpperCAmelCase_						:		Any ,  UpperCAmelCase_						:		Optional[int]=None						):




      """simple docstring"""





      require_version(deps[pkg] ,  UpperCAmelCase_						)





