



"""simple docstring"""





from dataclasses import asdict, dataclass
from typing import Optional

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


__lowerCAmelCase       :					Optional[int]      					=					logging.get_logger(__name__)

# TODO Update this
__lowerCAmelCase       :					List[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    _lowerCAmelCase    (				SCREAMING_SNAKE_CASE__		):





		"""simple docstring"""






		_lowerCamelCase			  =       '''esm'''





		def __init__(					self							,    _lowercase=None							,    _lowercase=None							,    _lowercase=None							,    _lowercase=7_6_8							,    _lowercase=1_2							,    _lowercase=1_2							,    _lowercase=3_0_7_2							,    _lowercase=0.1							,    _lowercase=0.1							,    _lowercase=1_0_2_6							,    _lowercase=0.02							,    _lowercase=1E-12							,    _lowercase="absolute"							,    _lowercase=True							,    _lowercase=None							,    _lowercase=False							,    _lowercase=False							,    _lowercase=None							,    _lowercase=None							,    **_lowercase							,    ) ->						str:







								'''simple docstring'''

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

								snake_case_   : List[str]						=			vocab_size
								snake_case_   : List[str]						=			hidden_size
								snake_case_   : List[str]						=			num_hidden_layers
								snake_case_   : List[Any]						=			num_attention_heads
								snake_case_   : Any						=			intermediate_size
								snake_case_   : Any						=			hidden_dropout_prob
								snake_case_   : Optional[int]						=			attention_probs_dropout_prob
								snake_case_   : str						=			max_position_embeddings
								snake_case_   : Any						=			initializer_range
								snake_case_   : Optional[int]						=			layer_norm_eps
								snake_case_   : Optional[Any]						=			position_embedding_type
								snake_case_   : str						=			use_cache
								snake_case_   : Any						=			emb_layer_norm_before
								snake_case_   : Optional[int]						=			token_dropout
								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."""   )
																				snake_case_   : Tuple						=			EsmFoldConfig()
														elif isinstance(_lowercase							,    _lowercase   ):
																				snake_case_   : List[Any]						=			EsmFoldConfig(**_lowercase   )
														snake_case_   : Tuple						=			esmfold_config
														if vocab_list is None:
																				logger.warning("""No vocab_list supplied for folding model, assuming the ESM-2 vocabulary!"""   )
																				snake_case_   : Union[str, Any]						=			get_default_vocab_list()
														else:
																				snake_case_   : List[str]						=			vocab_list
								else:
														snake_case_   : Any						=			None
														snake_case_   : Tuple						=			None
								if self.esmfold_config is not None and getattr(self.esmfold_config							,    """use_esm_attn_map"""							,    _lowercase   ):
														raise ValueError("""The HuggingFace port of ESMFold does not support use_esm_attn_map at this time!"""   )





		def    UpperCAmelCase__							(					self   ) ->						Any:







								'''simple docstring'''

								snake_case_   : Optional[Any]						=			super().to_dict()
								if isinstance(self.esmfold_config							,    _lowercase   ):
														snake_case_   : Any						=			self.esmfold_config.to_dict()
								return output




@dataclass
class    _lowerCAmelCase    :





		"""simple docstring"""






		_lowerCamelCase			  =       None
		_lowerCamelCase			  =       True
		_lowerCamelCase			  =       False
		_lowerCamelCase			  =       False
		_lowerCamelCase			  =       False
		_lowerCamelCase			  =       0

		_lowerCamelCase			  =       True
		_lowerCamelCase			  =       False

		_lowerCamelCase			  =       128
		_lowerCamelCase			  =       None





		def    UpperCAmelCase__							(					self   ) ->						List[Any]:







								'''simple docstring'''

								if self.trunk is None:
														snake_case_   : Optional[Any]						=			TrunkConfig()
								elif isinstance(self.trunk							,    _lowercase   ):
														snake_case_   : Optional[Any]						=			TrunkConfig(**self.trunk   )





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







								'''simple docstring'''

								snake_case_   : int						=			asdict(self   )
								snake_case_   : List[Any]						=			self.trunk.to_dict()
								return output




@dataclass
class    _lowerCAmelCase    :





		"""simple docstring"""






		_lowerCamelCase			  =       48
		_lowerCamelCase			  =       1_024
		_lowerCamelCase			  =       128
		_lowerCamelCase			  =       32
		_lowerCamelCase			  =       32
		_lowerCamelCase			  =       32
		_lowerCamelCase			  =       0
		_lowerCamelCase			  =       0
		_lowerCamelCase			  =       False
		_lowerCamelCase			  =       4
		_lowerCamelCase			  =       128
		_lowerCamelCase			  =       None





		def    UpperCAmelCase__							(					self   ) ->						Dict:







								'''simple docstring'''

								if self.structure_module is None:
														snake_case_   : List[str]						=			StructureModuleConfig()
								elif isinstance(self.structure_module							,    _lowercase   ):
														snake_case_   : 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}.'   )

								snake_case_   : List[Any]						=			self.sequence_state_dim // self.sequence_head_width
								snake_case_   : Tuple						=			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   ) ->						Dict:







								'''simple docstring'''

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




@dataclass
class    _lowerCAmelCase    :





		"""simple docstring"""






		_lowerCamelCase			  =       384
		_lowerCamelCase			  =       128
		_lowerCamelCase			  =       16
		_lowerCamelCase			  =       128
		_lowerCamelCase			  =       12
		_lowerCamelCase			  =       4
		_lowerCamelCase			  =       8
		_lowerCamelCase			  =       0.1
		_lowerCamelCase			  =       8
		_lowerCamelCase			  =       1
		_lowerCamelCase			  =       2
		_lowerCamelCase			  =       7
		_lowerCamelCase			  =       10
		_lowerCamelCase			  =       1E-8
		_lowerCamelCase			  =       1E5





		def    UpperCAmelCase__							(					self   ) ->						List[Any]:







								'''simple docstring'''

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






"""simple docstring"""





def 	__lowerCAmelCase						(		__UpperCamelCase      :			int					, __UpperCamelCase      :			int    ):


						'''simple docstring'''






						if a < 0 or b < 0:
												raise ValueError("""the value of both inputs must be positive"""    )

						snake_case_   : List[str]						=			str(bin(__UpperCamelCase    )    )[2:]  # remove the leading "0b"
						snake_case_   : Union[str, Any]						=			str(bin(__UpperCamelCase    )    )[2:]  # remove the leading "0b"

						snake_case_   : int						=			max(len(__UpperCamelCase    )					, len(__UpperCamelCase    )    )

						return "0b" + "".join(
						    str(int(char_a != char_b    )    )
						    for char_a, char_b in zip(a_binary.zfill(__UpperCamelCase    )					, b_binary.zfill(__UpperCamelCase    )    )    )


if __name__ == "__main__":
					import doctest

					doctest.testmod()

