




from dataclasses import asdict, dataclass
from typing import Optional

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


A   =       logging.get_logger(__name__)

# TODO Update this
A   =       {
    """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      a__				(	__magic_name__   ):
			lowercase_    =	"esm"


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


						"""simple docstring"""




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

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


						"""simple docstring"""




						__UpperCAmelCase	: List[str]		=					super().to_dict()
						if isinstance(self.esmfold_config      ,  UpperCamelCase_):
									__UpperCAmelCase	: List[str]		=					self.esmfold_config.to_dict()
						return output






@dataclass
class      a__				:
			lowercase_    =	None
			lowercase_    =	True
			lowercase_    =	False
			lowercase_    =	False
			lowercase_    =	False
			lowercase_    =	0

			lowercase_    =	True
			lowercase_    =	False

			lowercase_    =	1_2_8
			lowercase_    =	None


			def       a_     (      self      :    Any):


						"""simple docstring"""




						if self.trunk is None:
									__UpperCAmelCase	: Optional[Any]		=					TrunkConfig()
						elif isinstance(self.trunk      ,  UpperCamelCase_):
									__UpperCAmelCase	: Tuple		=					TrunkConfig(**self.trunk)


			def       a_     (      self      :    List[str]):


						"""simple docstring"""




						__UpperCAmelCase	: Union[str, Any]		=					asdict(self)
						__UpperCAmelCase	: Union[str, Any]		=					self.trunk.to_dict()
						return output






@dataclass
class      a__				:
			lowercase_    =	4_8
			lowercase_    =	1_0_2_4
			lowercase_    =	1_2_8
			lowercase_    =	3_2
			lowercase_    =	3_2
			lowercase_    =	3_2
			lowercase_    =	0
			lowercase_    =	0
			lowercase_    =	False
			lowercase_    =	4
			lowercase_    =	1_2_8
			lowercase_    =	None


			def       a_     (      self      :    Optional[int]):


						"""simple docstring"""




						if self.structure_module is None:
									__UpperCAmelCase	: Union[str, Any]		=					StructureModuleConfig()
						elif isinstance(self.structure_module      ,  UpperCamelCase_):
									__UpperCAmelCase	: List[str]		=					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	: Dict		=					self.sequence_state_dim // self.sequence_head_width
						__UpperCAmelCase	: str		=					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       a_     (      self      :    List[Any]):


						"""simple docstring"""




						__UpperCAmelCase	: int		=					asdict(self)
						__UpperCAmelCase	: int		=					self.structure_module.to_dict()
						return output






@dataclass
class      a__				:
			lowercase_    =	3_8_4
			lowercase_    =	1_2_8
			lowercase_    =	1_6
			lowercase_    =	1_2_8
			lowercase_    =	1_2
			lowercase_    =	4
			lowercase_    =	8
			lowercase_    =	0.1
			lowercase_    =	8
			lowercase_    =	1
			lowercase_    =	2
			lowercase_    =	7
			lowercase_    =	1_0
			lowercase_    =	1E-8
			lowercase_    =	1E5


			def       a_     (      self      :    Any):


						"""simple docstring"""




						return asdict(self)






def 					_UpperCamelCase    (			)			->			int:


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





import json
import os
import tempfile

from transformers.testing_utils import check_json_file_has_correct_format



class      a__				:
			lowercase_    =	None


			def       a_     (      self      :    List[Any]):


						"""simple docstring"""




						__UpperCAmelCase	: Optional[Any]		=					self.feature_extraction_class(**self.feat_extract_dict)
						__UpperCAmelCase	: Any		=					json.loads(feat_extract.to_json_string())
						for key, value in self.feat_extract_dict.items():
									self.assertEqual(obj[key]      ,  UpperCamelCase_)


			def       a_     (      self      :    Tuple):


						"""simple docstring"""




						__UpperCAmelCase	: Optional[Any]		=					self.feature_extraction_class(**self.feat_extract_dict)

						with tempfile.TemporaryDirectory() as tmpdirname:
									__UpperCAmelCase	: Dict		=					os.path.join(UpperCamelCase_      ,  "feat_extract.json")
									feat_extract_first.to_json_file(UpperCamelCase_)
									__UpperCAmelCase	: Optional[Any]		=					self.feature_extraction_class.from_json_file(UpperCamelCase_)

						self.assertEqual(feat_extract_second.to_dict()      ,  feat_extract_first.to_dict())


			def       a_     (      self      :    List[str]):


						"""simple docstring"""




						__UpperCAmelCase	: Optional[Any]		=					self.feature_extraction_class(**self.feat_extract_dict)

						with tempfile.TemporaryDirectory() as tmpdirname:
									__UpperCAmelCase	: Tuple		=					feat_extract_first.save_pretrained(UpperCamelCase_)[0]
									check_json_file_has_correct_format(UpperCamelCase_)
									__UpperCAmelCase	: List[Any]		=					self.feature_extraction_class.from_pretrained(UpperCamelCase_)

						self.assertEqual(feat_extract_second.to_dict()      ,  feat_extract_first.to_dict())


			def       a_     (      self      :    Union[str, Any]):


						"""simple docstring"""




						__UpperCAmelCase	: Union[str, Any]		=					self.feature_extraction_class()
						self.assertIsNotNone(UpperCamelCase_)


