






from dataclasses import asdict, dataclass
from typing import Optional

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


lowerCamelCase      :       Union[str, Any]    =						logging.get_logger(__name__)

# TODO Update this
lowerCamelCase      :       List[str]    =						{
    '''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      (__lowerCamelCase      ):
      snake_case_	=				'esm'


      def __init__(						self       ,    __UpperCamelCase=None       ,    __UpperCamelCase=None       ,    __UpperCamelCase=None       ,    __UpperCamelCase=7_6_8       ,    __UpperCamelCase=1_2       ,    __UpperCamelCase=1_2       ,    __UpperCamelCase=3_0_7_2       ,    __UpperCamelCase=0.1       ,    __UpperCamelCase=0.1       ,    __UpperCamelCase=1_0_2_6       ,    __UpperCamelCase=0.0_2       ,    __UpperCamelCase=1e-12       ,    __UpperCamelCase="absolute"       ,    __UpperCamelCase=True       ,    __UpperCamelCase=None       ,    __UpperCamelCase=False       ,    __UpperCamelCase=False       ,    __UpperCamelCase=None       ,    __UpperCamelCase=None       ,    **__UpperCamelCase       ,    )->						Union[str, Any]:
           super().__init__(pad_token_id=__UpperCamelCase       ,    mask_token_id=__UpperCamelCase       ,    **__UpperCamelCase						)

           __lowerCAmelCase             =       vocab_size
           __lowerCAmelCase             =       hidden_size
           __lowerCAmelCase             =       num_hidden_layers
           __lowerCAmelCase             =       num_attention_heads
           __lowerCAmelCase             =       intermediate_size
           __lowerCAmelCase             =       hidden_dropout_prob
           __lowerCAmelCase             =       attention_probs_dropout_prob
           __lowerCAmelCase             =       max_position_embeddings
           __lowerCAmelCase             =       initializer_range
           __lowerCAmelCase             =       layer_norm_eps
           __lowerCAmelCase             =       position_embedding_type
           __lowerCAmelCase             =       use_cache
           __lowerCAmelCase             =       emb_layer_norm_before
           __lowerCAmelCase             =       token_dropout
           __lowerCAmelCase             =       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             =       EsmFoldConfig()
                elif isinstance(__UpperCamelCase       ,    __UpperCamelCase						):
                     __lowerCAmelCase             =       EsmFoldConfig(**__UpperCamelCase						)
                __lowerCAmelCase             =       esmfold_config
                if vocab_list is None:
                     logger.warning("No vocab_list supplied for folding model, assuming the ESM-2 vocabulary!"						)
                     __lowerCAmelCase             =       get_default_vocab_list()
                else:
                     __lowerCAmelCase             =       vocab_list
           else:
                __lowerCAmelCase             =       None
                __lowerCAmelCase             =       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 			__UpperCAmelCase		(						self						)->						str:
           __lowerCAmelCase             =       super().to_dict()
           if isinstance(self.esmfold_config       ,    __UpperCamelCase						):
                __lowerCAmelCase             =       self.esmfold_config.to_dict()
           return output



@dataclass
class 				_UpperCamelCase      :
      snake_case_	=				None
      snake_case_	=				True
      snake_case_	=				False
      snake_case_	=				False
      snake_case_	=				False
      snake_case_	=				0

      snake_case_	=				True
      snake_case_	=				False

      snake_case_	=				128
      snake_case_	=				None


      def 			__UpperCAmelCase		(						self						)->						Dict:






           if self.trunk is None:
                __lowerCAmelCase             =       TrunkConfig()
           elif isinstance(self.trunk       ,    __UpperCamelCase						):
                __lowerCAmelCase             =       TrunkConfig(**self.trunk						)


      def 			__UpperCAmelCase		(						self						)->						Dict:
           __lowerCAmelCase             =       asdict(self						)
           __lowerCAmelCase             =       self.trunk.to_dict()
           return output



@dataclass
class 				_UpperCamelCase      :
      snake_case_	=				48
      snake_case_	=				1024
      snake_case_	=				128
      snake_case_	=				32
      snake_case_	=				32
      snake_case_	=				32
      snake_case_	=				0
      snake_case_	=				0
      snake_case_	=				False
      snake_case_	=				4
      snake_case_	=				128
      snake_case_	=				None


      def 			__UpperCAmelCase		(						self						)->						int:






           if self.structure_module is None:
                __lowerCAmelCase             =       StructureModuleConfig()
           elif isinstance(self.structure_module       ,    __UpperCamelCase						):
                __lowerCAmelCase             =       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             =       self.sequence_state_dim // self.sequence_head_width
           __lowerCAmelCase             =       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             =       asdict(self						)
           __lowerCAmelCase             =       self.structure_module.to_dict()
           return output



@dataclass
class 				_UpperCamelCase      :
      snake_case_	=				384
      snake_case_	=				128
      snake_case_	=				16
      snake_case_	=				128
      snake_case_	=				12
      snake_case_	=				4
      snake_case_	=				8
      snake_case_	=				0.1
      snake_case_	=				8
      snake_case_	=				1
      snake_case_	=				2
      snake_case_	=				7
      snake_case_	=				10
      snake_case_	=				1E-8
      snake_case_	=				1E5


      def 			__UpperCAmelCase		(						self						)->						Union[str, Any]:
           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>",
     )








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


__lowerCAmelCase					   =       logging.get_logger(__name__)

__lowerCAmelCase					   =       {
    'alibaba-damo/mgp-str-base': 'https://huggingface.co/alibaba-damo/mgp-str-base/resolve/main/config.json',
}





class     lowerCamelCase      (       __lowerCamelCase					):
	UpperCamelCase_  :					Union[str, Any]    		=	'mgp-str'







	def __init__(     self      :Union[str, Any]   ,     lowercase      :Union[str, Any]=[3_2, 1_2_8]   ,     lowercase      :Tuple=4   ,     lowercase      :Optional[int]=3   ,     lowercase      :Union[str, Any]=2_7   ,     lowercase      :List[str]=3_8   ,     lowercase      :Optional[Any]=5_0_2_5_7   ,     lowercase      :str=3_0_5_2_2   ,     lowercase      :Dict=7_6_8   ,     lowercase      :List[Any]=1_2   ,     lowercase      :List[str]=1_2   ,     lowercase      :Optional[Any]=4.0   ,     lowercase      :Optional[Any]=True   ,     lowercase      :str=False   ,     lowercase      :Optional[Any]=1e-5   ,     lowercase      :List[str]=0.0   ,     lowercase      :List[Any]=0.0   ,     lowercase      :Optional[int]=0.0   ,     lowercase      :Dict=False   ,     lowercase      :Optional[Any]=0.02   ,     **lowercase      :Optional[Any]   ,     )		->      Dict:







				"""simple docstring"""






				super().__init__(**lowercase			)

				SCREAMING_SNAKE_CASE     						= image_size
				SCREAMING_SNAKE_CASE     						= patch_size
				SCREAMING_SNAKE_CASE     						= num_channels
				SCREAMING_SNAKE_CASE     						= max_token_length
				SCREAMING_SNAKE_CASE     						= num_character_labels
				SCREAMING_SNAKE_CASE     						= num_bpe_labels
				SCREAMING_SNAKE_CASE     						= num_wordpiece_labels
				SCREAMING_SNAKE_CASE     						= hidden_size
				SCREAMING_SNAKE_CASE     						= num_hidden_layers
				SCREAMING_SNAKE_CASE     						= num_attention_heads
				SCREAMING_SNAKE_CASE     						= mlp_ratio
				SCREAMING_SNAKE_CASE     						= distilled
				SCREAMING_SNAKE_CASE     						= layer_norm_eps
				SCREAMING_SNAKE_CASE     						= drop_rate
				SCREAMING_SNAKE_CASE     						= qkv_bias
				SCREAMING_SNAKE_CASE     						= attn_drop_rate
				SCREAMING_SNAKE_CASE     						= drop_path_rate
				SCREAMING_SNAKE_CASE     						= output_aa_attentions
				SCREAMING_SNAKE_CASE     						= initializer_range