




from dataclasses import asdict, dataclass
from typing import Optional

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


_lowerCamelCase	:		List[Any]							       =   logging.get_logger(__name__)

# TODO Update this
_lowerCamelCase	:		Union[str, 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 				UpperCamelCase_    ( UpperCAmelCase__     ):

    '''simple docstring'''






    UpperCAmelCase__							  =      '''esm'''


    def __init__(			self      :	str					, UpperCAmelCase__      :	Any=None					, UpperCAmelCase__      :	Tuple=None					, UpperCAmelCase__      :	List[str]=None					, UpperCAmelCase__      :	List[str]=768					, UpperCAmelCase__      :	int=12					, UpperCAmelCase__      :	Union[str, Any]=12					, UpperCAmelCase__      :	Dict=3_072					, UpperCAmelCase__      :	Optional[Any]=0.1					, UpperCAmelCase__      :	Optional[int]=0.1					, UpperCAmelCase__      :	Optional[int]=1_026					, UpperCAmelCase__      :	int=0.02					, UpperCAmelCase__      :	Optional[Any]=1e-12					, UpperCAmelCase__      :	Optional[Any]="absolute"					, UpperCAmelCase__      :	Union[str, Any]=True					, UpperCAmelCase__      :	int=None					, UpperCAmelCase__      :	List[Any]=False					, UpperCAmelCase__      :	Optional[int]=False					, UpperCAmelCase__      :	List[Any]=None					, UpperCAmelCase__      :	List[str]=None					, **UpperCAmelCase__      :	List[Any]					, )						->Tuple:





           '''simple docstring'''

           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        SCREAMING_SNAKE_CASE							(			self      :	Any)						->Tuple:





           '''simple docstring'''

           A__       =    super().to_dict()
           if isinstance(self.esmfold_config					, UpperCAmelCase__):
                  A__       =    self.esmfold_config.to_dict()
           return output


@dataclass
class 				UpperCamelCase_    :

    '''simple docstring'''






    UpperCAmelCase__							  =      None
    UpperCAmelCase__							  =      True
    UpperCAmelCase__							  =      False
    UpperCAmelCase__							  =      False
    UpperCAmelCase__							  =      False
    UpperCAmelCase__							  =      0

    UpperCAmelCase__							  =      True
    UpperCAmelCase__							  =      False

    UpperCAmelCase__							  =      128
    UpperCAmelCase__							  =      None


    def        SCREAMING_SNAKE_CASE							(			self      :	List[Any])						->Dict:





           '''simple docstring'''

           if self.trunk is None:
                  A__       =    TrunkConfig()
           elif isinstance(self.trunk					, UpperCAmelCase__):
                  A__       =    TrunkConfig(**self.trunk)





    def        SCREAMING_SNAKE_CASE							(			self      :	Tuple)						->Optional[int]:





           '''simple docstring'''

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


@dataclass
class 				UpperCamelCase_    :

    '''simple docstring'''






    UpperCAmelCase__							  =      48
    UpperCAmelCase__							  =      1024
    UpperCAmelCase__							  =      128
    UpperCAmelCase__							  =      32
    UpperCAmelCase__							  =      32
    UpperCAmelCase__							  =      32
    UpperCAmelCase__							  =      0
    UpperCAmelCase__							  =      0
    UpperCAmelCase__							  =      False
    UpperCAmelCase__							  =      4
    UpperCAmelCase__							  =      128
    UpperCAmelCase__							  =      None


    def        SCREAMING_SNAKE_CASE							(			self      :	List[str])						->Union[str, Any]:





           '''simple docstring'''

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





           '''simple docstring'''

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


@dataclass
class 				UpperCamelCase_    :

    '''simple docstring'''






    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        SCREAMING_SNAKE_CASE							(			self      :	Optional[int])						->Optional[int]:





           '''simple docstring'''

           return asdict(self)







def SCREAMING_SNAKE_CASE				(       )   ->       Tuple:



       """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_tf_available,
    is_torch_available,
    is_vision_available,
)


_lowerCamelCase	:		int							       =   {
    """configuration_blip""": [
        """BLIP_PRETRAINED_CONFIG_ARCHIVE_MAP""",
        """BlipConfig""",
        """BlipTextConfig""",
        """BlipVisionConfig""",
    ],
    """processing_blip""": ["""BlipProcessor"""],
}

try:
  if not is_vision_available():
    raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
  pass
else:
  _lowerCamelCase	:		Tuple							       =   ["""BlipImageProcessor"""]


try:
  if not is_torch_available():
    raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
  pass
else:
  _lowerCamelCase	:		List[Any]							       =   [
      """BLIP_PRETRAINED_MODEL_ARCHIVE_LIST""",
      """BlipModel""",
      """BlipPreTrainedModel""",
      """BlipForConditionalGeneration""",
      """BlipForQuestionAnswering""",
      """BlipVisionModel""",
      """BlipTextModel""",
      """BlipForImageTextRetrieval""",
  ]

try:
  if not is_tf_available():
    raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
  pass
else:
  _lowerCamelCase	:		Optional[Any]							       =   [
      """TF_BLIP_PRETRAINED_MODEL_ARCHIVE_LIST""",
      """TFBlipModel""",
      """TFBlipPreTrainedModel""",
      """TFBlipForConditionalGeneration""",
      """TFBlipForQuestionAnswering""",
      """TFBlipVisionModel""",
      """TFBlipTextModel""",
      """TFBlipForImageTextRetrieval""",
  ]

if TYPE_CHECKING:
  from .configuration_blip import BLIP_PRETRAINED_CONFIG_ARCHIVE_MAP, BlipConfig, BlipTextConfig, BlipVisionConfig
  from .processing_blip import BlipProcessor

  try:
    if not is_vision_available():
      raise OptionalDependencyNotAvailable()
  except OptionalDependencyNotAvailable:
    pass
  else:
    from .image_processing_blip import BlipImageProcessor

  try:
    if not is_torch_available():
      raise OptionalDependencyNotAvailable()
  except OptionalDependencyNotAvailable:
    pass
  else:
    from .modeling_blip import (
        BLIP_PRETRAINED_MODEL_ARCHIVE_LIST,
        BlipForConditionalGeneration,
        BlipForImageTextRetrieval,
        BlipForQuestionAnswering,
        BlipModel,
        BlipPreTrainedModel,
        BlipTextModel,
        BlipVisionModel,
    )

  try:
    if not is_tf_available():
      raise OptionalDependencyNotAvailable()
  except OptionalDependencyNotAvailable:
    pass
  else:
    from .modeling_tf_blip import (
        TF_BLIP_PRETRAINED_MODEL_ARCHIVE_LIST,
        TFBlipForConditionalGeneration,
        TFBlipForImageTextRetrieval,
        TFBlipForQuestionAnswering,
        TFBlipModel,
        TFBlipPreTrainedModel,
        TFBlipTextModel,
        TFBlipVisionModel,
    )

else:
  import sys

  _lowerCamelCase	:		List[Any]							       =   _LazyModule(__name__, globals()["""__file__"""], _import_structure, module_spec=__spec__)


