


from dataclasses import asdict, dataclass
from typing import Optional

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


__snake_case            =   logging.get_logger(__name__)

# TODO Update this
__snake_case            =   {
    "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					(       __snake_case    ):
			lowercase						= """esm"""




			def __init__(						self							:		str       ,       __magic_name__							:		Optional[Any]=None       ,       __magic_name__							:		Dict=None       ,       __magic_name__							:		Union[str, Any]=None       ,       __magic_name__							:		Optional[Any]=7_6_8       ,       __magic_name__							:		Union[str, Any]=1_2       ,       __magic_name__							:		List[Any]=1_2       ,       __magic_name__							:		Union[str, Any]=3_0_7_2       ,       __magic_name__							:		Any=0.1       ,       __magic_name__							:		Optional[int]=0.1       ,       __magic_name__							:		str=1_0_2_6       ,       __magic_name__							:		Union[str, Any]=0.02       ,       __magic_name__							:		List[Any]=1e-12       ,       __magic_name__							:		Dict="absolute"       ,       __magic_name__							:		Dict=True       ,       __magic_name__							:		Any=None       ,       __magic_name__							:		Union[str, Any]=False       ,       __magic_name__							:		Tuple=False       ,       __magic_name__							:		Optional[int]=None       ,       __magic_name__							:		Dict=None       ,       **__magic_name__							:		List[str]       ,       ):







						"""simple docstring"""







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

						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(__magic_name__       ,       __magic_name__						):
												UpperCamelCase         =					EsmFoldConfig(**__magic_name__						)
									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"""       ,       __magic_name__						):
									raise ValueError("""The HuggingFace port of ESMFold does not support use_esm_attn_map at this time!"""						)





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







						"""simple docstring"""







						UpperCamelCase         =					super().to_dict()
						if isinstance(self.esmfold_config       ,       __magic_name__						):
									UpperCamelCase         =					self.esmfold_config.to_dict()
						return output




@dataclass
class    UpperCAmelCase					:
			lowercase						= None
			lowercase						= True
			lowercase						= False
			lowercase						= False
			lowercase						= False
			lowercase						= 0

			lowercase						= True
			lowercase						= False

			lowercase						= 1_2_8
			lowercase						= None




			def   lowerCamelCase_					(						self							:		int						):







						"""simple docstring"""







						if self.trunk is None:
									UpperCamelCase         =					TrunkConfig()
						elif isinstance(self.trunk       ,       __magic_name__						):
									UpperCamelCase         =					TrunkConfig(**self.trunk						)





			def   lowerCamelCase_					(						self							:		List[Any]						):







						"""simple docstring"""







						UpperCamelCase         =					asdict(self						)
						UpperCamelCase         =					self.trunk.to_dict()
						return output




@dataclass
class    UpperCAmelCase					:
			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   lowerCamelCase_					(						self							:		Tuple						):







						"""simple docstring"""







						if self.structure_module is None:
									UpperCamelCase         =					StructureModuleConfig()
						elif isinstance(self.structure_module       ,       __magic_name__						):
									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   lowerCamelCase_					(						self							:		Optional[Any]						):







						"""simple docstring"""







						UpperCamelCase         =					asdict(self						)
						UpperCamelCase         =					self.structure_module.to_dict()
						return output




@dataclass
class    UpperCAmelCase					:
			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   lowerCamelCase_					(						self							:		Dict						):







						"""simple docstring"""







						return asdict(self						)






def 							_lowercase    (		):





			"""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 math
import unittest






def 							_lowercase    (		SCREAMING_SNAKE_CASE_   :		int	):





			"""simple docstring"""




			assert isinstance(SCREAMING_SNAKE_CASE_       ,  SCREAMING_SNAKE_CASE_	) and (
			    number >= 0
			), "'number' must been an int and positive"

			if 1 < number < 4:
						# 2 and 3 are primes
						return True
			elif number < 2 or number % 2 == 0 or number % 3 == 0:
						# Negatives, 0, 1, all even numbers, all multiples of 3 are not primes
						return False

			# All primes number are in format of 6k +/- 1
			for i in range(5       ,  int(math.sqrt(SCREAMING_SNAKE_CASE_	) + 1	)       ,  6	):
						if number % i == 0 or number % (i + 2) == 0:
									return False
			return True




class    UpperCAmelCase					(       unittest.TestCase    ):




			def   lowerCamelCase_					(						self							:		Any						):







						"""simple docstring"""







						self.assertTrue(is_prime(2						)						)
						self.assertTrue(is_prime(3						)						)
						self.assertTrue(is_prime(5						)						)
						self.assertTrue(is_prime(7						)						)
						self.assertTrue(is_prime(1_1						)						)
						self.assertTrue(is_prime(1_3						)						)
						self.assertTrue(is_prime(1_7						)						)
						self.assertTrue(is_prime(1_9						)						)
						self.assertTrue(is_prime(2_3						)						)
						self.assertTrue(is_prime(2_9						)						)





			def   lowerCamelCase_					(						self							:		Dict						):







						"""simple docstring"""







						with self.assertRaises(__magic_name__						):
									is_prime(-1_9						)
						self.assertFalse(
						    is_prime(0						)       ,       """Zero doesn't have any positive factors, primes must have exactly two."""       ,       )
						self.assertFalse(
						    is_prime(1						)       ,       """One only has 1 positive factor, primes must have exactly two."""       ,       )
						self.assertFalse(is_prime(2 * 2						)						)
						self.assertFalse(is_prime(2 * 3						)						)
						self.assertFalse(is_prime(3 * 3						)						)
						self.assertFalse(is_prime(3 * 5						)						)
						self.assertFalse(is_prime(3 * 5 * 7						)						)


if __name__ == "__main__":
			unittest.main()




