


'''simple docstring'''



from dataclasses import asdict, dataclass
from typing import Optional

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


_lowercase    :    Union[str, Any]			     =  logging.get_logger(__name__)

# TODO Update this
_lowercase    :    int			     =  {
    """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__(     lowerCAmelCase ):
				__magic_name__       :   Tuple							= "esm"




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

										"""simple docstring"""




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

										UpperCAmelCase         =			vocab_size
										UpperCAmelCase         =			hidden_size
										UpperCAmelCase         =			num_hidden_layers
										UpperCAmelCase         =			num_attention_heads
										UpperCAmelCase         =			intermediate_size
										UpperCAmelCase         =			hidden_dropout_prob
										UpperCAmelCase         =			attention_probs_dropout_prob
										UpperCAmelCase         =			max_position_embeddings
										UpperCAmelCase         =			initializer_range
										UpperCAmelCase         =			layer_norm_eps
										UpperCAmelCase         =			position_embedding_type
										UpperCAmelCase         =			use_cache
										UpperCAmelCase         =			emb_layer_norm_before
										UpperCAmelCase         =			token_dropout
										UpperCAmelCase         =			is_folding_model
										if is_folding_model:
																if esmfold_config is None:
																						logger.info('''No esmfold_config supplied for folding model, using default values.'''   )
																						UpperCAmelCase         =			EsmFoldConfig()
																elif isinstance(lowerCAmelCase   ,					lowerCAmelCase   ):
																						UpperCAmelCase         =			EsmFoldConfig(**lowerCAmelCase   )
																UpperCAmelCase         =			esmfold_config
																if vocab_list is None:
																						logger.warning('''No vocab_list supplied for folding model, assuming the ESM-2 vocabulary!'''   )
																						UpperCAmelCase         =			get_default_vocab_list()
																else:
																						UpperCAmelCase         =			vocab_list
										else:
																UpperCAmelCase         =			None
																UpperCAmelCase         =			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   a__(	self    :				Any   )->  List[str]:

										"""simple docstring"""




										UpperCAmelCase         =			super().to_dict()
										if isinstance(self.esmfold_config   ,					lowerCAmelCase   ):
																UpperCAmelCase         =			self.esmfold_config.to_dict()
										return output







@dataclass
class  UpperCamelCase__:
				__magic_name__       :   str							= None
				__magic_name__       :   bool							= True
				__magic_name__       :   bool							= False
				__magic_name__       :   bool							= False
				__magic_name__       :   bool							= False
				__magic_name__       :   float							= 0

				__magic_name__       :   bool							= True
				__magic_name__       :   bool							= False

				__magic_name__       :   int							= 128
				__magic_name__       :   "TrunkConfig"							= None




				def   a__(	self    :				Any   )->  Optional[int]:

										"""simple docstring"""




										if self.trunk is None:
																UpperCAmelCase         =			TrunkConfig()
										elif isinstance(self.trunk   ,					lowerCAmelCase   ):
																UpperCAmelCase         =			TrunkConfig(**self.trunk   )





				def   a__(	self    :				List[str]   )->  Dict:

										"""simple docstring"""




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







@dataclass
class  UpperCamelCase__:
				__magic_name__       :   int							= 48
				__magic_name__       :   int							= 1024
				__magic_name__       :   int							= 128
				__magic_name__       :   int							= 32
				__magic_name__       :   int							= 32
				__magic_name__       :   int							= 32
				__magic_name__       :   float							= 0
				__magic_name__       :   float							= 0
				__magic_name__       :   bool							= False
				__magic_name__       :   int							= 4
				__magic_name__       :   Optional[int]							= 128
				__magic_name__       :   "StructureModuleConfig"							= None




				def   a__(	self    :				Optional[int]   )->  Union[str, Any]:

										"""simple docstring"""




										if self.structure_module is None:
																UpperCAmelCase         =			StructureModuleConfig()
										elif isinstance(self.structure_module   ,					lowerCAmelCase   ):
																UpperCAmelCase         =			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}."""   )

										UpperCAmelCase         =			self.sequence_state_dim // self.sequence_head_width
										UpperCAmelCase         =			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    :				List[Any]   )->  List[Any]:

										"""simple docstring"""




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







@dataclass
class  UpperCamelCase__:
				__magic_name__       :   int							= 384
				__magic_name__       :   int							= 128
				__magic_name__       :   int							= 16
				__magic_name__       :   int							= 128
				__magic_name__       :   int							= 12
				__magic_name__       :   int							= 4
				__magic_name__       :   int							= 8
				__magic_name__       :   float							= 0.1
				__magic_name__       :   int							= 8
				__magic_name__       :   int							= 1
				__magic_name__       :   int							= 2
				__magic_name__       :   int							= 7
				__magic_name__       :   int							= 10
				__magic_name__       :   float							= 1e-8
				__magic_name__       :   float							= 1e5




				def   a__(	self    :				Any   )->  Optional[Any]:

										"""simple docstring"""




										return asdict(self   )







def    lowerCamelCase__   ( ):




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

from ...processing_utils import ProcessorMixin
from ...tokenization_utils_base import BatchEncoding






class  UpperCamelCase__(     lowerCAmelCase ):
				__magic_name__       :   Tuple							= ["image_processor", "tokenizer"]
				__magic_name__       :   Any							= "ViTImageProcessor"
				__magic_name__       :   str							= ("CLIPTokenizer", "CLIPTokenizerFast")




				def __init__(	self    :				List[str]   ,					lowerCAmelCase    :				List[Any]=None   ,					lowerCAmelCase    :				List[str]=None   ,					**lowerCAmelCase    :				Optional[int]   )->  List[Any]:

										"""simple docstring"""




										UpperCAmelCase         =			None
										if "feature_extractor" in kwargs:
																warnings.warn(
																    '''The `feature_extractor` argument is deprecated and will be removed in v5, use `image_processor`'''
																    ''' instead.'''   ,					lowerCAmelCase   ,					)
																UpperCAmelCase         =			kwargs.pop('''feature_extractor'''   )

										UpperCAmelCase         =			image_processor if image_processor is not None else feature_extractor
										if image_processor is None:
																raise ValueError('''You need to specify an `image_processor`.'''   )
										if tokenizer is None:
																raise ValueError('''You need to specify a `tokenizer`.'''   )

										super().__init__(lowerCAmelCase   ,					lowerCAmelCase   )




				def __call__(	self    :				str   ,					lowerCAmelCase    :				Optional[Any]=None   ,					lowerCAmelCase    :				Optional[Any]=None   ,					lowerCAmelCase    :				Dict=None   ,					lowerCAmelCase    :				str=None   ,					**lowerCAmelCase    :				List[str]   )->  List[Any]:

										"""simple docstring"""




										if text is None and visual_prompt is None and images is None:
																raise ValueError('''You have to specify either text, visual prompt or images.'''   )

										if text is not None and visual_prompt is not None:
																raise ValueError('''You have to specify exactly one type of prompt. Either text or visual prompt.'''   )

										if text is not None:
																UpperCAmelCase         =			self.tokenizer(lowerCAmelCase   ,					return_tensors=lowerCAmelCase   ,					**lowerCAmelCase   )

										if visual_prompt is not None:
																UpperCAmelCase         =			self.image_processor(lowerCAmelCase   ,					return_tensors=lowerCAmelCase   ,					**lowerCAmelCase   )

										if images is not None:
																UpperCAmelCase         =			self.image_processor(lowerCAmelCase   ,					return_tensors=lowerCAmelCase   ,					**lowerCAmelCase   )

										if visual_prompt is not None and images is not None:
																UpperCAmelCase         =			{
																    '''pixel_values''': image_features.pixel_values,
																    '''conditional_pixel_values''': prompt_features.pixel_values,
																}
																return encoding
										elif text is not None and images is not None:
																UpperCAmelCase         =			image_features.pixel_values
																return encoding
										elif text is not None:
																return encoding
										elif visual_prompt is not None:
																UpperCAmelCase         =			{
																    '''conditional_pixel_values''': prompt_features.pixel_values,
																}
																return encoding
										else:
																return BatchEncoding(data=dict(**lowerCAmelCase   )   ,					tensor_type=lowerCAmelCase   )




				def   a__(	self    :				List[str]   ,					*lowerCAmelCase    :				str   ,					**lowerCAmelCase    :				Optional[int]   )->  Union[str, Any]:

										"""simple docstring"""




										return self.tokenizer.batch_decode(*lowerCAmelCase   ,					**lowerCAmelCase   )




				def   a__(	self    :				Dict   ,					*lowerCAmelCase    :				Tuple   ,					**lowerCAmelCase    :				List[str]   )->  Optional[Any]:

										"""simple docstring"""




										return self.tokenizer.decode(*lowerCAmelCase   ,					**lowerCAmelCase   )




				@property
				def   a__(	self    :				List[Any]   )->  Optional[Any]:

										"""simple docstring"""




										warnings.warn(
										    '''`feature_extractor_class` is deprecated and will be removed in v5. Use `image_processor_class` instead.'''   ,					lowerCAmelCase   ,					)
										return self.image_processor_class





				@property
				def   a__(	self    :				Any   )->  List[Any]:

										"""simple docstring"""




										warnings.warn(
										    '''`feature_extractor` is deprecated and will be removed in v5. Use `image_processor` instead.'''   ,					lowerCAmelCase   ,					)
										return self.image_processor





