





from dataclasses import asdict, dataclass
from typing import Optional

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


_A :   int  			=  logging.get_logger(__name__)

# TODO Update this
_A :   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        __SCREAMING_SNAKE_CASE      (			lowerCAmelCase_ ):
       _UpperCAmelCase				:  str			   =   "esm"







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

          lowerCamelCase__       :						List[Any]        =							vocab_size
          lowerCamelCase__       :						Union[str, Any]        =							hidden_size
          lowerCamelCase__       :						Union[str, Any]        =							num_hidden_layers
          lowerCamelCase__       :						Dict        =							num_attention_heads
          lowerCamelCase__       :						int        =							intermediate_size
          lowerCamelCase__       :						Dict        =							hidden_dropout_prob
          lowerCamelCase__       :						List[Any]        =							attention_probs_dropout_prob
          lowerCamelCase__       :						Any        =							max_position_embeddings
          lowerCamelCase__       :						Optional[Any]        =							initializer_range
          lowerCamelCase__       :						Tuple        =							layer_norm_eps
          lowerCamelCase__       :						List[Any]        =							position_embedding_type
          lowerCamelCase__       :						Dict        =							use_cache
          lowerCamelCase__       :						int        =							emb_layer_norm_before
          lowerCamelCase__       :						Dict        =							token_dropout
          lowerCamelCase__       :						Optional[int]        =							is_folding_model
          if is_folding_model:
             if esmfold_config is None:
                logger.info('''No esmfold_config supplied for folding model, using default values.'''      )
                lowerCamelCase__       :						Tuple        =							EsmFoldConfig()
             elif isinstance(A		, A      ):
                lowerCamelCase__       :						int        =							EsmFoldConfig(**A      )
             lowerCamelCase__       :						Any        =							esmfold_config
             if vocab_list is None:
                logger.warning('''No vocab_list supplied for folding model, assuming the ESM-2 vocabulary!'''      )
                lowerCamelCase__       :						List[str]        =							get_default_vocab_list()
             else:
                lowerCamelCase__       :						Any        =							vocab_list
          else:
             lowerCamelCase__       :						Optional[Any]        =							None
             lowerCamelCase__       :						Union[str, Any]        =							None
          if self.esmfold_config is not None and getattr(self.esmfold_config		, '''use_esm_attn_map'''		, A      ):
             raise ValueError('''The HuggingFace port of ESMFold does not support use_esm_attn_map at this time!'''      )







       def 						__lowerCamelCase   (				self					:     Dict      )       ->Optional[int]:
          lowerCamelCase__       :						List[Any]        =							super().to_dict()
          if isinstance(self.esmfold_config		, A      ):
             lowerCamelCase__       :						List[str]        =							self.esmfold_config.to_dict()
          return output


@dataclass
class        __SCREAMING_SNAKE_CASE      :
       _UpperCAmelCase				:  str			   =   None
       _UpperCAmelCase				:  bool			   =   True
       _UpperCAmelCase				:  bool			   =   False
       _UpperCAmelCase				:  bool			   =   False
       _UpperCAmelCase				:  bool			   =   False
       _UpperCAmelCase				:  float			   =   0

       _UpperCAmelCase				:  bool			   =   True
       _UpperCAmelCase				:  bool			   =   False

       _UpperCAmelCase				:  int			   =   1_2_8
       _UpperCAmelCase				:  "TrunkConfig"			   =   None







       def 						__lowerCamelCase   (				self					:     Dict      )       ->Any:
          if self.trunk is None:
             lowerCamelCase__       :						List[Any]        =							TrunkConfig()
          elif isinstance(self.trunk		, A      ):
             lowerCamelCase__       :						List[str]        =							TrunkConfig(**self.trunk      )







       def 						__lowerCamelCase   (				self					:     Dict      )       ->List[Any]:
          lowerCamelCase__       :						Optional[int]        =							asdict(self      )
          lowerCamelCase__       :						Optional[Any]        =							self.trunk.to_dict()
          return output


@dataclass
class        __SCREAMING_SNAKE_CASE      :
       _UpperCAmelCase				:  int			   =   4_8
       _UpperCAmelCase				:  int			   =   1_0_2_4
       _UpperCAmelCase				:  int			   =   1_2_8
       _UpperCAmelCase				:  int			   =   3_2
       _UpperCAmelCase				:  int			   =   3_2
       _UpperCAmelCase				:  int			   =   3_2
       _UpperCAmelCase				:  float			   =   0
       _UpperCAmelCase				:  float			   =   0
       _UpperCAmelCase				:  bool			   =   False
       _UpperCAmelCase				:  int			   =   4
       _UpperCAmelCase				:  Optional[int]			   =   1_2_8
       _UpperCAmelCase				:  "StructureModuleConfig"			   =   None







       def 						__lowerCamelCase   (				self					:     int      )       ->Union[str, Any]:
          if self.structure_module is None:
             lowerCamelCase__       :						Optional[Any]        =							StructureModuleConfig()
          elif isinstance(self.structure_module		, A      ):
             lowerCamelCase__       :						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}."      )

          lowerCamelCase__       :						List[str]        =							self.sequence_state_dim // self.sequence_head_width
          lowerCamelCase__       :						int        =							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					:     List[str]      )       ->Dict:
          lowerCamelCase__       :						Optional[Any]        =							asdict(self      )
          lowerCamelCase__       :						Tuple        =							self.structure_module.to_dict()
          return output


@dataclass
class        __SCREAMING_SNAKE_CASE      :
       _UpperCAmelCase				:  int			   =   3_8_4
       _UpperCAmelCase				:  int			   =   1_2_8
       _UpperCAmelCase				:  int			   =   1_6
       _UpperCAmelCase				:  int			   =   1_2_8
       _UpperCAmelCase				:  int			   =   1_2
       _UpperCAmelCase				:  int			   =   4
       _UpperCAmelCase				:  int			   =   8
       _UpperCAmelCase				:  float			   =   0.1
       _UpperCAmelCase				:  int			   =   8
       _UpperCAmelCase				:  int			   =   1
       _UpperCAmelCase				:  int			   =   2
       _UpperCAmelCase				:  int			   =   7
       _UpperCAmelCase				:  int			   =   1_0
       _UpperCAmelCase				:  float			   =   1e-8
       _UpperCAmelCase				:  float			   =   1e5







       def 						__lowerCamelCase   (				self					:     str      )       ->str:
          return asdict(self      )



def 	_a						(   )    ->    Optional[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>",
   )










import os
from pathlib import Path



def 	_a						(   )    ->    Tuple:







   """simple docstring"""
   from torch.utils.cpp_extension import load

   lowerCamelCase__       :						List[Any]        =							Path(UpperCAmelCase					).resolve().parent.parent.parent / '''kernels''' / '''deformable_detr'''
   lowerCamelCase__       :						Any        =							[
       root / filename
       for filename in [
           '''vision.cpp''',
           os.path.join('''cpu'''      ,  '''ms_deform_attn_cpu.cpp'''					),
           os.path.join('''cuda'''      ,  '''ms_deform_attn_cuda.cu'''					),
       ]
   ]

   load(
       '''MultiScaleDeformableAttention'''      ,  UpperCAmelCase      ,  with_cuda=UpperCAmelCase      ,  extra_include_paths=[str(UpperCAmelCase					)]      ,  extra_cflags=['''-DWITH_CUDA=1''']      ,  extra_cuda_cflags=[
           '''-DCUDA_HAS_FP16=1''',
           '''-D__CUDA_NO_HALF_OPERATORS__''',
           '''-D__CUDA_NO_HALF_CONVERSIONS__''',
           '''-D__CUDA_NO_HALF2_OPERATORS__''',
       ]      ,  )

   import MultiScaleDeformableAttention as MSDA

   return MSDA



