from dataclasses import asdict, dataclass
from typing import Optional

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


SCREAMING_SNAKE_CASE			:						Tuple				  =		logging.get_logger(__name__)

# TODO Update this
SCREAMING_SNAKE_CASE			:						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  A_			(							lowerCAmelCase__			):
  _SCREAMING_SNAKE_CASE     					=      '''esm'''

  def __init__(		self			:   Tuple  ,				__SCREAMING_SNAKE_CASE			:   str=None  ,				__SCREAMING_SNAKE_CASE			:   Optional[Any]=None  ,				__SCREAMING_SNAKE_CASE			:   Union[str, Any]=None  ,				__SCREAMING_SNAKE_CASE			:   Any=7_68  ,				__SCREAMING_SNAKE_CASE			:   Optional[int]=12  ,				__SCREAMING_SNAKE_CASE			:   Any=12  ,				__SCREAMING_SNAKE_CASE			:   List[Any]=30_72  ,				__SCREAMING_SNAKE_CASE			:   int=0.1  ,				__SCREAMING_SNAKE_CASE			:   Dict=0.1  ,				__SCREAMING_SNAKE_CASE			:   int=10_26  ,				__SCREAMING_SNAKE_CASE			:   Union[str, Any]=0.02  ,				__SCREAMING_SNAKE_CASE			:   Union[str, Any]=1E-12  ,				__SCREAMING_SNAKE_CASE			:   Any="absolute"  ,				__SCREAMING_SNAKE_CASE			:   Any=True  ,				__SCREAMING_SNAKE_CASE			:   List[str]=None  ,				__SCREAMING_SNAKE_CASE			:   List[Any]=False  ,				__SCREAMING_SNAKE_CASE			:   Any=False  ,				__SCREAMING_SNAKE_CASE			:   int=None  ,				__SCREAMING_SNAKE_CASE			:   Union[str, Any]=None  ,				**__SCREAMING_SNAKE_CASE			:   Dict  ,				):
   super().__init__(pad_token_id=__lowerCAmelCase  ,				mask_token_id=__lowerCAmelCase  ,				**__lowerCAmelCase							)

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

  def 		_UpperCAmelCase (		self			:   Any							):
   __a							=	super().to_dict()
   if isinstance(self.esmfold_config  ,				__lowerCAmelCase							):
    __a							=	self.esmfold_config.to_dict()
   return output
@dataclass
class  A_			:
  _SCREAMING_SNAKE_CASE     					=      None
  _SCREAMING_SNAKE_CASE     					=      True
  _SCREAMING_SNAKE_CASE     					=      False
  _SCREAMING_SNAKE_CASE     					=      False
  _SCREAMING_SNAKE_CASE     					=      False
  _SCREAMING_SNAKE_CASE     					=      0

  _SCREAMING_SNAKE_CASE     					=      True
  _SCREAMING_SNAKE_CASE     					=      False

  _SCREAMING_SNAKE_CASE     					=      1_28
  _SCREAMING_SNAKE_CASE     					=      None

  def 		_UpperCAmelCase (		self			:   Optional[int]							):


   if self.trunk is None:
    __a							=	TrunkConfig()
   elif isinstance(self.trunk  ,				__lowerCAmelCase							):
    __a							=	TrunkConfig(**self.trunk							)

  def 		_UpperCAmelCase (		self			:   List[str]							):
   __a							=	asdict(self							)
   __a							=	self.trunk.to_dict()
   return output
@dataclass
class  A_			:
  _SCREAMING_SNAKE_CASE     					=      48
  _SCREAMING_SNAKE_CASE     					=      10_24
  _SCREAMING_SNAKE_CASE     					=      1_28
  _SCREAMING_SNAKE_CASE     					=      32
  _SCREAMING_SNAKE_CASE     					=      32
  _SCREAMING_SNAKE_CASE     					=      32
  _SCREAMING_SNAKE_CASE     					=      0
  _SCREAMING_SNAKE_CASE     					=      0
  _SCREAMING_SNAKE_CASE     					=      False
  _SCREAMING_SNAKE_CASE     					=      4
  _SCREAMING_SNAKE_CASE     					=      1_28
  _SCREAMING_SNAKE_CASE     					=      None

  def 		_UpperCAmelCase (		self			:   int							):


   if self.structure_module is None:
    __a							=	StructureModuleConfig()
   elif isinstance(self.structure_module  ,				__lowerCAmelCase							):
    __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 		_UpperCAmelCase (		self			:   Tuple							):
   __a							=	asdict(self							)
   __a							=	self.structure_module.to_dict()
   return output
@dataclass
class  A_			:
  _SCREAMING_SNAKE_CASE     					=      3_84
  _SCREAMING_SNAKE_CASE     					=      1_28
  _SCREAMING_SNAKE_CASE     					=      16
  _SCREAMING_SNAKE_CASE     					=      1_28
  _SCREAMING_SNAKE_CASE     					=      12
  _SCREAMING_SNAKE_CASE     					=      4
  _SCREAMING_SNAKE_CASE     					=      8
  _SCREAMING_SNAKE_CASE     					=      0.1
  _SCREAMING_SNAKE_CASE     					=      8
  _SCREAMING_SNAKE_CASE     					=      1
  _SCREAMING_SNAKE_CASE     					=      2
  _SCREAMING_SNAKE_CASE     					=      7
  _SCREAMING_SNAKE_CASE     					=      10
  _SCREAMING_SNAKE_CASE     					=      1E-8
  _SCREAMING_SNAKE_CASE     					=      1E5

  def 		_UpperCAmelCase (		self			:   int							):
   return asdict(self							)



def 	__A		(      ):



 """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'''




from typing import Dict, List, Optional, Union

import numpy as np

from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict
from ...image_transforms import convert_to_rgb, normalize, rescale, resize, to_channel_dimension_format
from ...image_utils import (
    OPENAI_CLIP_MEAN,
    OPENAI_CLIP_STD,
    ChannelDimension,
    ImageInput,
    PILImageResampling,
    make_list_of_images,
    to_numpy_array,
    valid_images,
)
from ...utils import TensorType, is_vision_available, logging


if is_vision_available():
						import PIL


__lowercase        =    logging.get_logger(__name__)






class 							a__(   lowerCAmelCase__      ):


			'''simple docstring'''






			UpperCAmelCase_     :	List[Any]						=			['''pixel_values''']



			def __init__(  self			,       __lowerCAmelCase = True			,       __lowerCAmelCase = None			,       __lowerCAmelCase = PILImageResampling.BICUBIC			,       __lowerCAmelCase = True			,       __lowerCAmelCase = 1 / 255			,       __lowerCAmelCase = True			,       __lowerCAmelCase = None			,       __lowerCAmelCase = None			,       __lowerCAmelCase = True			,       **__lowerCAmelCase			,       ):




					"""simple docstring"""


					super().__init__(**__lowerCAmelCase)
					lowerCAmelCase     =    size if size is not None else {"""height""": 384, """width""": 384}
					lowerCAmelCase     =    get_size_dict(__lowerCAmelCase			,       default_to_square=__lowerCAmelCase)

					lowerCAmelCase     =    do_resize
					lowerCAmelCase     =    size
					lowerCAmelCase     =    resample
					lowerCAmelCase     =    do_rescale
					lowerCAmelCase     =    rescale_factor
					lowerCAmelCase     =    do_normalize
					lowerCAmelCase     =    image_mean if image_mean is not None else OPENAI_CLIP_MEAN
					lowerCAmelCase     =    image_std if image_std is not None else OPENAI_CLIP_STD
					lowerCAmelCase     =    do_convert_rgb



			def 				a_			(  self			,       __lowerCAmelCase			,       __lowerCAmelCase			,       __lowerCAmelCase = PILImageResampling.BICUBIC			,       __lowerCAmelCase = None			,       **__lowerCAmelCase			,       ):




					"""simple docstring"""


					lowerCAmelCase     =    get_size_dict(__lowerCAmelCase			,       default_to_square=__lowerCAmelCase)
					if "height" not in size or "width" not in size:
							raise ValueError(f"The `size` dictionary must contain the keys `height` and `width`. Got {size.keys()}")
					lowerCAmelCase     =    (size["""height"""], size["""width"""])
					return resize(__lowerCAmelCase			,       size=__lowerCAmelCase			,       resample=__lowerCAmelCase			,       data_format=__lowerCAmelCase			,       **__lowerCAmelCase)



			def 				a_			(  self			,       __lowerCAmelCase			,       __lowerCAmelCase			,       __lowerCAmelCase = None			,       **__lowerCAmelCase			,       ):




					"""simple docstring"""


					return rescale(__lowerCAmelCase			,       scale=__lowerCAmelCase			,       data_format=__lowerCAmelCase			,       **__lowerCAmelCase)



			def 				a_			(  self			,       __lowerCAmelCase			,       __lowerCAmelCase			,       __lowerCAmelCase			,       __lowerCAmelCase = None			,       **__lowerCAmelCase			,       ):




					"""simple docstring"""


					return normalize(__lowerCAmelCase			,       mean=__lowerCAmelCase			,       std=__lowerCAmelCase			,       data_format=__lowerCAmelCase			,       **__lowerCAmelCase)







			def 				a_			(  self			,       __lowerCAmelCase			,       __lowerCAmelCase = None			,       __lowerCAmelCase = None			,       __lowerCAmelCase = None			,       __lowerCAmelCase = None			,       __lowerCAmelCase = None			,       __lowerCAmelCase = None			,       __lowerCAmelCase = None			,       __lowerCAmelCase = None			,       __lowerCAmelCase = None			,       __lowerCAmelCase = None			,       __lowerCAmelCase = ChannelDimension.FIRST			,       **__lowerCAmelCase			,       ):




					"""simple docstring"""


					lowerCAmelCase     =    do_resize if do_resize is not None else self.do_resize
					lowerCAmelCase     =    resample if resample is not None else self.resample
					lowerCAmelCase     =    do_rescale if do_rescale is not None else self.do_rescale
					lowerCAmelCase     =    rescale_factor if rescale_factor is not None else self.rescale_factor
					lowerCAmelCase     =    do_normalize if do_normalize is not None else self.do_normalize
					lowerCAmelCase     =    image_mean if image_mean is not None else self.image_mean
					lowerCAmelCase     =    image_std if image_std is not None else self.image_std
					lowerCAmelCase     =    do_convert_rgb if do_convert_rgb is not None else self.do_convert_rgb

					lowerCAmelCase     =    size if size is not None else self.size
					lowerCAmelCase     =    get_size_dict(__lowerCAmelCase			,       default_to_square=__lowerCAmelCase)

					lowerCAmelCase     =    make_list_of_images(__lowerCAmelCase)

					if not valid_images(__lowerCAmelCase):
							raise ValueError(
							    """Invalid image type. Must be of type PIL.Image.Image, numpy.ndarray, """
							    """torch.Tensor, tf.Tensor or jax.ndarray.""")

					if do_resize and size is None or resample is None:
							raise ValueError("""Size and resample must be specified if do_resize is True.""")

					if do_rescale and rescale_factor is None:
							raise ValueError("""Rescale factor must be specified if do_rescale is True.""")

					if do_normalize and (image_mean is None or image_std is None):
							raise ValueError("""Image mean and std must be specified if do_normalize is True.""")

					# PIL RGBA images are converted to RGB
					if do_convert_rgb:
							lowerCAmelCase     =    [convert_to_rgb(__lowerCAmelCase) for image in images]

					# All transformations expect numpy arrays.
					lowerCAmelCase     =    [to_numpy_array(__lowerCAmelCase) for image in images]

					if do_resize:
							lowerCAmelCase     =    [self.resize(image=__lowerCAmelCase			,       size=__lowerCAmelCase			,       resample=__lowerCAmelCase) for image in images]

					if do_rescale:
							lowerCAmelCase     =    [self.rescale(image=__lowerCAmelCase			,       scale=__lowerCAmelCase) for image in images]

					if do_normalize:
							lowerCAmelCase     =    [self.normalize(image=__lowerCAmelCase			,       mean=__lowerCAmelCase			,       std=__lowerCAmelCase) for image in images]

					lowerCAmelCase     =    [to_channel_dimension_format(__lowerCAmelCase			,       __lowerCAmelCase) for image in images]

					lowerCAmelCase     =    BatchFeature(data={"""pixel_values""": images}			,       tensor_type=__lowerCAmelCase)

					return encoded_outputs




