






"""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 						A_							(      __snake_case  ):
				UpperCAmelCase__        =				'''esm'''







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

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





@dataclass
class 						A_							:
				UpperCAmelCase__        =				None
				UpperCAmelCase__        =				True
				UpperCAmelCase__        =				False
				UpperCAmelCase__        =				False
				UpperCAmelCase__        =				False
				UpperCAmelCase__        =				0

				UpperCAmelCase__        =				True
				UpperCAmelCase__        =				False

				UpperCAmelCase__        =				1_2_8
				UpperCAmelCase__        =				None







				def     _snake_case					(							self							:						List[str]	)				->					Optional[Any]:


										if self.trunk is None:
																__magic_name__            =     TrunkConfig()
										elif isinstance(self.trunk						,    __UpperCamelCase	):
																__magic_name__            =     TrunkConfig(**self.trunk	)







				def     _snake_case					(							self							:						Any	)				->					Dict:
										__magic_name__            =     asdict(self	)
										__magic_name__            =     self.trunk.to_dict()
										return output





@dataclass
class 						A_							:
				UpperCAmelCase__        =				4_8
				UpperCAmelCase__        =				1_0_2_4
				UpperCAmelCase__        =				1_2_8
				UpperCAmelCase__        =				3_2
				UpperCAmelCase__        =				3_2
				UpperCAmelCase__        =				3_2
				UpperCAmelCase__        =				0
				UpperCAmelCase__        =				0
				UpperCAmelCase__        =				False
				UpperCAmelCase__        =				4
				UpperCAmelCase__        =				1_2_8
				UpperCAmelCase__        =				None







				def     _snake_case					(							self							:						Any	)				->					Tuple:


										if self.structure_module is None:
																__magic_name__            =     StructureModuleConfig()
										elif isinstance(self.structure_module						,    __UpperCamelCase	):
																__magic_name__            =     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}.'''	)

										__magic_name__            =     self.sequence_state_dim // self.sequence_head_width
										__magic_name__            =     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     _snake_case					(							self							:						List[str]	)				->					Tuple:
										__magic_name__            =     asdict(self	)
										__magic_name__            =     self.structure_module.to_dict()
										return output





@dataclass
class 						A_							:
				UpperCAmelCase__        =				3_8_4
				UpperCAmelCase__        =				1_2_8
				UpperCAmelCase__        =				1_6
				UpperCAmelCase__        =				1_2_8
				UpperCAmelCase__        =				1_2
				UpperCAmelCase__        =				4
				UpperCAmelCase__        =				8
				UpperCAmelCase__        =				0.1
				UpperCAmelCase__        =				8
				UpperCAmelCase__        =				1
				UpperCAmelCase__        =				2
				UpperCAmelCase__        =				7
				UpperCAmelCase__        =				1_0
				UpperCAmelCase__        =				1e-8
				UpperCAmelCase__        =				1e5







				def     _snake_case					(							self							:						Union[str, Any]	)				->					Union[str, Any]:
										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"""

from typing import List, Optional, Union

from ...image_utils import ImageInput
from ...processing_utils import ProcessorMixin
from ...tokenization_utils_base import BatchEncoding, PaddingStrategy, PreTokenizedInput, TextInput, TruncationStrategy
from ...utils import TensorType

class 						A_							(      snake_case_  ):
				UpperCAmelCase__        =				['''image_processor''', '''tokenizer''']
				UpperCAmelCase__        =				'''BlipImageProcessor'''
				UpperCAmelCase__        =				'''AutoTokenizer'''







				def __init__(							self							:						Tuple						,    __lowerCamelCase							:						str						,    __lowerCamelCase							:						int	)				->					str:
										__magic_name__            =     False
										super().__init__(__lowerCamelCase						,    __lowerCamelCase	)
										__magic_name__            =     self.image_processor







				def __call__(							self							:						List[Any]						,    __lowerCamelCase							:						ImageInput = None						,    __lowerCamelCase							:						Union[TextInput, PreTokenizedInput, List[TextInput], List[PreTokenizedInput]] = None						,    __lowerCamelCase							:						bool = True						,    __lowerCamelCase							:						Union[bool, str, PaddingStrategy] = False						,    __lowerCamelCase							:						Union[bool, str, TruncationStrategy] = None						,    __lowerCamelCase							:						Optional[int] = None						,    __lowerCamelCase							:						int = 0						,    __lowerCamelCase							:						Optional[int] = None						,    __lowerCamelCase							:						Optional[bool] = None						,    __lowerCamelCase							:						bool = False						,    __lowerCamelCase							:						bool = False						,    __lowerCamelCase							:						bool = False						,    __lowerCamelCase							:						bool = False						,    __lowerCamelCase							:						bool = False						,    __lowerCamelCase							:						bool = True						,    __lowerCamelCase							:						Optional[Union[str, TensorType]] = None						,    **__lowerCamelCase							:						Optional[int]						,    )				->					BatchEncoding:
										if images is None and text is None:
																raise ValueError("You have to specify either images or text."	)

										# Get only text
										if images is None:
																__magic_name__            =     self.tokenizer
																__magic_name__            =     self.tokenizer(
																    text=__lowerCamelCase						,    add_special_tokens=__lowerCamelCase						,    padding=__lowerCamelCase						,    truncation=__lowerCamelCase						,    max_length=__lowerCamelCase						,    stride=__lowerCamelCase						,    pad_to_multiple_of=__lowerCamelCase						,    return_attention_mask=__lowerCamelCase						,    return_overflowing_tokens=__lowerCamelCase						,    return_special_tokens_mask=__lowerCamelCase						,    return_offsets_mapping=__lowerCamelCase						,    return_token_type_ids=__lowerCamelCase						,    return_length=__lowerCamelCase						,    verbose=__lowerCamelCase						,    return_tensors=__lowerCamelCase						,    **__lowerCamelCase						,    )
																return text_encoding

										# add pixel_values
										__magic_name__            =     self.image_processor(__lowerCamelCase						,    return_tensors=__lowerCamelCase	)

										if text is not None:
																__magic_name__            =     self.tokenizer(
																    text=__lowerCamelCase						,    add_special_tokens=__lowerCamelCase						,    padding=__lowerCamelCase						,    truncation=__lowerCamelCase						,    max_length=__lowerCamelCase						,    stride=__lowerCamelCase						,    pad_to_multiple_of=__lowerCamelCase						,    return_attention_mask=__lowerCamelCase						,    return_overflowing_tokens=__lowerCamelCase						,    return_special_tokens_mask=__lowerCamelCase						,    return_offsets_mapping=__lowerCamelCase						,    return_token_type_ids=__lowerCamelCase						,    return_length=__lowerCamelCase						,    verbose=__lowerCamelCase						,    return_tensors=__lowerCamelCase						,    **__lowerCamelCase						,    )
										else:
																__magic_name__            =     None

										if text_encoding is not None:
																encoding_image_processor.update(__lowerCamelCase	)

										return encoding_image_processor







				def     _snake_case					(							self							:						Union[str, Any]						,    *__lowerCamelCase							:						Union[str, Any]						,    **__lowerCamelCase							:						Dict	)				->					Dict:
										return self.tokenizer.batch_decode(*__lowerCamelCase						,    **__lowerCamelCase	)







				def     _snake_case					(							self							:						str						,    *__lowerCamelCase							:						Optional[Any]						,    **__lowerCamelCase							:						Tuple	)				->					Optional[Any]:
										return self.tokenizer.decode(*__lowerCamelCase						,    **__lowerCamelCase	)







				@property
				# Copied from transformers.models.blip.processing_blip.BlipProcessor.model_input_names
				def     _snake_case					(							self							:						List[str]	)				->					Optional[Any]:
										__magic_name__            =     self.tokenizer.model_input_names
										__magic_name__            =     self.image_processor.model_input_names
										return list(dict.fromkeys(tokenizer_input_names + image_processor_input_names	)	)



