
'''simple docstring'''







from collections import OrderedDict
from typing import Mapping

from ...configuration_utils import PretrainedConfig
from ...onnx import OnnxConfigWithPast
from ...utils import logging


_lowercase					:    int       				=			logging.get_logger(__name__)

_lowercase					:    Optional[int]       				=			{
    "uclanlp/plbart-base": "https://huggingface.co/uclanlp/plbart-base/resolve/main/config.json",
    # See all PLBART models at https://huggingface.co/models?filter=plbart
}






class 					lowerCAmelCase__  (    lowerCamelCase_	):
					lowerCAmelCase_	  =	'''plbart'''
					lowerCAmelCase_	  =	['''past_key_values''']
					lowerCAmelCase_	  =	{'''num_attention_heads''': '''encoder_attention_heads''', '''hidden_size''': '''d_model'''}






					def __init__(  self							,				__SCREAMING_SNAKE_CASE=5_00_05							,				__SCREAMING_SNAKE_CASE=10_24							,				__SCREAMING_SNAKE_CASE=6							,				__SCREAMING_SNAKE_CASE=30_72							,				__SCREAMING_SNAKE_CASE=12							,				__SCREAMING_SNAKE_CASE=6							,				__SCREAMING_SNAKE_CASE=30_72							,				__SCREAMING_SNAKE_CASE=12							,				__SCREAMING_SNAKE_CASE=0.0							,				__SCREAMING_SNAKE_CASE=0.0							,				__SCREAMING_SNAKE_CASE=True							,				__SCREAMING_SNAKE_CASE=True							,				__SCREAMING_SNAKE_CASE="gelu"							,				__SCREAMING_SNAKE_CASE=7_68							,				__SCREAMING_SNAKE_CASE=0.1							,				__SCREAMING_SNAKE_CASE=0.1							,				__SCREAMING_SNAKE_CASE=0.0							,				__SCREAMING_SNAKE_CASE=0.02							,				__SCREAMING_SNAKE_CASE=0.0							,				__SCREAMING_SNAKE_CASE=True							,				__SCREAMING_SNAKE_CASE=1							,				__SCREAMING_SNAKE_CASE=0							,				__SCREAMING_SNAKE_CASE=2							,				__SCREAMING_SNAKE_CASE=2							,				**__SCREAMING_SNAKE_CASE							,				):


											"""simple docstring"""





											lowercase_      :	Dict						=			vocab_size
											lowercase_      :	Any						=			max_position_embeddings
											lowercase_      :	str						=			d_model
											lowercase_      :	Optional[Any]						=			encoder_ffn_dim
											lowercase_      :	Tuple						=			encoder_layers
											lowercase_      :	str						=			encoder_attention_heads
											lowercase_      :	Optional[Any]						=			decoder_ffn_dim
											lowercase_      :	Union[str, Any]						=			decoder_layers
											lowercase_      :	List[Any]						=			decoder_attention_heads
											lowercase_      :	List[str]						=			dropout
											lowercase_      :	str						=			attention_dropout
											lowercase_      :	Tuple						=			activation_dropout
											lowercase_      :	Dict						=			activation_function
											lowercase_      :	Optional[Any]						=			init_std
											lowercase_      :	Tuple						=			encoder_layerdrop
											lowercase_      :	Any						=			decoder_layerdrop
											lowercase_      :	List[str]						=			classifier_dropout
											lowercase_      :	int						=			use_cache
											lowercase_      :	int						=			encoder_layers
											lowercase_      :	Optional[int]						=			scale_embedding  # scale factor will be sqrt(d_model) if True
											super().__init__(
											    pad_token_id=__SCREAMING_SNAKE_CASE							,				bos_token_id=__SCREAMING_SNAKE_CASE							,				eos_token_id=__SCREAMING_SNAKE_CASE							,				is_encoder_decoder=__SCREAMING_SNAKE_CASE							,				forced_eos_token_id=__SCREAMING_SNAKE_CASE							,				**__SCREAMING_SNAKE_CASE							,				)







class 					lowerCAmelCase__  (    lowerCamelCase_	):






					@property
					def       _snake_case       (  self						):


											"""simple docstring"""





											return OrderedDict(
											    [
											        ('''input_ids''', {0: '''batch''', 1: '''sequence'''}),
											        ('''attention_mask''', {0: '''batch''', 1: '''sequence'''}),
											    ]						)






					@property
					def       _snake_case       (  self						):


											"""simple docstring"""





											if self.use_past:
																	return OrderedDict(
																	    [
																	        ('''last_hidden_state''', {0: '''batch''', 1: '''sequence'''}),
																	        ('''past_keys''', {0: '''batch''', 2: '''sequence'''}),
																	        ('''encoder_last_hidden_state''', {0: '''batch''', 1: '''sequence'''}),
																	    ]						)
											else:
																	return OrderedDict(
																	    [
																	        ('''last_hidden_state''', {0: '''batch''', 1: '''sequence'''}),
																	        ('''encoder_last_hidden_state''', {0: '''batch''', 1: '''sequence'''}),
																	    ]						)





'''simple docstring'''







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






class 					lowerCAmelCase__  (    lowerCamelCase_	):
					lowerCAmelCase_	  =	['''image_processor''', '''tokenizer''']
					lowerCAmelCase_	  =	'''EfficientNetImageProcessor'''
					lowerCAmelCase_	  =	('''BertTokenizer''', '''BertTokenizerFast''')






					def __init__(  self							,				__SCREAMING_SNAKE_CASE							,				__SCREAMING_SNAKE_CASE						):


											"""simple docstring"""





											super().__init__(__SCREAMING_SNAKE_CASE							,				__SCREAMING_SNAKE_CASE						)






					def __call__(  self							,				__SCREAMING_SNAKE_CASE=None							,				__SCREAMING_SNAKE_CASE=None							,				__SCREAMING_SNAKE_CASE="max_length"							,				__SCREAMING_SNAKE_CASE=64							,				__SCREAMING_SNAKE_CASE=None							,				**__SCREAMING_SNAKE_CASE						):


											"""simple docstring"""





											if text is None and images is None:
																	raise ValueError('''You have to specify either text or images. Both cannot be none.'''						)

											if text is not None:
																	lowercase_      :	str						=			self.tokenizer(
																	    __SCREAMING_SNAKE_CASE							,				padding=__SCREAMING_SNAKE_CASE							,				max_length=__SCREAMING_SNAKE_CASE							,				return_tensors=__SCREAMING_SNAKE_CASE							,				**__SCREAMING_SNAKE_CASE						)

											if images is not None:
																	lowercase_      :	int						=			self.image_processor(__SCREAMING_SNAKE_CASE							,				return_tensors=__SCREAMING_SNAKE_CASE							,				**__SCREAMING_SNAKE_CASE						)

											if text is not None and images is not None:
																	lowercase_      :	Any						=			image_features.pixel_values
																	return encoding
											elif text is not None:
																	return encoding
											else:
																	return BatchEncoding(data=dict(**__SCREAMING_SNAKE_CASE						)							,				tensor_type=__SCREAMING_SNAKE_CASE						)






					def       _snake_case       (  self							,				*__SCREAMING_SNAKE_CASE							,				**__SCREAMING_SNAKE_CASE						):


											"""simple docstring"""





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






					def       _snake_case       (  self							,				*__SCREAMING_SNAKE_CASE							,				**__SCREAMING_SNAKE_CASE						):


											"""simple docstring"""





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






					@property
					def       _snake_case       (  self						):


											"""simple docstring"""





											lowercase_      :	Dict						=			self.tokenizer.model_input_names
											lowercase_      :	Optional[int]						=			self.image_processor.model_input_names
											return list(dict.fromkeys(tokenizer_input_names + image_processor_input_names						)						)



