






from dataclasses import asdict, dataclass
from typing import Optional

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


UpperCAmelCase__      			=						logging.get_logger(__name__)

# TODO Update this
UpperCAmelCase__      			=						{
    '''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_       (    __UpperCamelCase      ):

						"""simple docstring"""



						snake_case__        =      """esm"""



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




											'''simple docstring'''



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

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




											'''simple docstring'''



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




@dataclass
class 							snake_case_       :

						"""simple docstring"""



						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:					str   )    ->     Optional[Any]:




											'''simple docstring'''



											if self.trunk is None:
																__a					:						Union[str, Any]      =					TrunkConfig()
											elif isinstance(self.trunk ,					__UpperCAmelCase   ):
																__a					:						Dict      =					TrunkConfig(**self.trunk   )



						def        UpperCAmelCase__					(self:					List[str]   )    ->     Optional[int]:




											'''simple docstring'''



											__a					:						str      =					asdict(self   )
											__a					:						int      =					self.trunk.to_dict()
											return output




@dataclass
class 							snake_case_       :

						"""simple docstring"""



						snake_case__        =      48
						snake_case__        =      1_024
						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:					Union[str, Any]   )    ->     Dict:




											'''simple docstring'''



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

											__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        UpperCAmelCase__					(self:					Optional[int]   )    ->     List[Any]:




											'''simple docstring'''



											__a					:						Union[str, Any]      =					asdict(self   )
											__a					:						Optional[Any]      =					self.structure_module.to_dict()
											return output




@dataclass
class 							snake_case_       :

						"""simple docstring"""



						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:					str   )    ->     Dict:




											'''simple docstring'''



											return asdict(self   )







def     a_   ()				->						Optional[Any]:



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













from typing import TYPE_CHECKING

from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available


UpperCAmelCase__      			=						{
    '''configuration_poolformer''': [
        '''POOLFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP''',
        '''PoolFormerConfig''',
        '''PoolFormerOnnxConfig''',
    ]
}

try:
			if not is_vision_available():
						raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
			pass
else:
			UpperCAmelCase__      			=						['''PoolFormerFeatureExtractor''']
			UpperCAmelCase__      			=						['''PoolFormerImageProcessor''']

try:
			if not is_torch_available():
						raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
			pass
else:
			UpperCAmelCase__      			=						[
			    '''POOLFORMER_PRETRAINED_MODEL_ARCHIVE_LIST''',
			    '''PoolFormerForImageClassification''',
			    '''PoolFormerModel''',
			    '''PoolFormerPreTrainedModel''',
			]


if TYPE_CHECKING:
			from .configuration_poolformer import (
			    POOLFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP,
			    PoolFormerConfig,
			    PoolFormerOnnxConfig,
			)

			try:
						if not is_vision_available():
									raise OptionalDependencyNotAvailable()
			except OptionalDependencyNotAvailable:
						pass
			else:
						from .feature_extraction_poolformer import PoolFormerFeatureExtractor
						from .image_processing_poolformer import PoolFormerImageProcessor

			try:
						if not is_torch_available():
									raise OptionalDependencyNotAvailable()
			except OptionalDependencyNotAvailable:
						pass
			else:
						from .modeling_poolformer import (
						    POOLFORMER_PRETRAINED_MODEL_ARCHIVE_LIST,
						    PoolFormerForImageClassification,
						    PoolFormerModel,
						    PoolFormerPreTrainedModel,
						)


else:
			import sys

			UpperCAmelCase__      			=						_LazyModule(__name__, globals()['''__file__'''], _import_structure)





