


'''simple docstring'''

from dataclasses import asdict, dataclass
from typing import Optional

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


lowercase__				     =		logging.get_logger(__name__)

# TODO Update this
lowercase__				     =		{
    "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 						__SCREAMING_SNAKE_CASE					(      lowerCamelCase__ ):
     UpperCAmelCase 					=				'''esm'''






     def __init__(			self     ,							__UpperCamelCase=None     ,							__UpperCamelCase=None     ,							__UpperCamelCase=None     ,							__UpperCamelCase=768     ,							__UpperCamelCase=12     ,							__UpperCamelCase=12     ,							__UpperCamelCase=3_072     ,							__UpperCamelCase=0.1     ,							__UpperCamelCase=0.1     ,							__UpperCamelCase=1_026     ,							__UpperCamelCase=0.02     ,							__UpperCamelCase=1e-12     ,							__UpperCamelCase="absolute"     ,							__UpperCamelCase=True     ,							__UpperCamelCase=None     ,							__UpperCamelCase=False     ,							__UpperCamelCase=False     ,							__UpperCamelCase=None     ,							__UpperCamelCase=None     ,							**__UpperCamelCase     ,							)       ->    Dict:
          super().__init__(pad_token_id=__UpperCamelCase     ,							mask_token_id=__UpperCamelCase     ,							**__UpperCamelCase		)

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







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

     UpperCAmelCase 					=				True
     UpperCAmelCase 					=				False

     UpperCAmelCase 					=				128
     UpperCAmelCase 					=				None






     def  a_					(			self		)       ->    List[str]:
          if self.trunk is None:
               _a						=		TrunkConfig()
          elif isinstance(self.trunk     ,							__UpperCamelCase		):
               _a						=		TrunkConfig(**self.trunk		)






     def  a_					(			self		)       ->    Union[str, Any]:
          _a						=		asdict(self		)
          _a						=		self.trunk.to_dict()
          return output







@dataclass
class 						__SCREAMING_SNAKE_CASE					:
     UpperCAmelCase 					=				48
     UpperCAmelCase 					=				1_024
     UpperCAmelCase 					=				128
     UpperCAmelCase 					=				32
     UpperCAmelCase 					=				32
     UpperCAmelCase 					=				32
     UpperCAmelCase 					=				0
     UpperCAmelCase 					=				0
     UpperCAmelCase 					=				False
     UpperCAmelCase 					=				4
     UpperCAmelCase 					=				128
     UpperCAmelCase 					=				None






     def  a_					(			self		)       ->    List[str]:
          if self.structure_module is None:
               _a						=		StructureModuleConfig()
          elif isinstance(self.structure_module     ,							__UpperCamelCase		):
               _a						=		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						=		self.sequence_state_dim // self.sequence_head_width
          _a						=		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		)       ->    Dict:
          _a						=		asdict(self		)
          _a						=		self.structure_module.to_dict()
          return output







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






     def  a_					(			self		)       ->    List[Any]:
          return asdict(self		)







def __UpperCamelCase   (			)      ->     List[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>",
     )





'''simple docstring'''

import unittest

from transformers import load_tool

from .test_tools_common import ToolTesterMixin





class 						__SCREAMING_SNAKE_CASE					(      unittest.TestCase ,			lowerCamelCase__ ):






     def  a_					(			self		)       ->    Tuple:
          _a						=		load_tool("text-classification"		)
          self.tool.setup()
          _a						=		load_tool("text-classification"     ,							remote=__UpperCamelCase		)






     def  a_					(			self		)       ->    Optional[int]:
          _a						=		self.tool("That's quite cool"     ,							["positive", "negative"]		)
          self.assertEqual(__UpperCamelCase     ,							"positive"		)






     def  a_					(			self		)       ->    Union[str, Any]:
          _a						=		self.remote_tool("That's quite cool"     ,							["positive", "negative"]		)
          self.assertEqual(__UpperCamelCase     ,							"positive"		)






     def  a_					(			self		)       ->    Optional[int]:
          _a						=		self.tool(text="That's quite cool"     ,							labels=["positive", "negative"]		)
          self.assertEqual(__UpperCamelCase     ,							"positive"		)






     def  a_					(			self		)       ->    str:
          _a						=		self.remote_tool(text="That's quite cool"     ,							labels=["positive", "negative"]		)
          self.assertEqual(__UpperCamelCase     ,							"positive"		)

