


from collections import OrderedDict
from typing import Mapping

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


lowerCAmelCase__						:str         =							logging.get_logger(__name__)

lowerCAmelCase__						:Optional[Any]         =							{
    '''nghuyong/ernie-1.0-base-zh''': '''https://huggingface.co/nghuyong/ernie-1.0-base-zh/resolve/main/config.json''',
    '''nghuyong/ernie-2.0-base-en''': '''https://huggingface.co/nghuyong/ernie-2.0-base-en/resolve/main/config.json''',
    '''nghuyong/ernie-2.0-large-en''': '''https://huggingface.co/nghuyong/ernie-2.0-large-en/resolve/main/config.json''',
    '''nghuyong/ernie-3.0-base-zh''': '''https://huggingface.co/nghuyong/ernie-3.0-base-zh/resolve/main/config.json''',
    '''nghuyong/ernie-3.0-medium-zh''': '''https://huggingface.co/nghuyong/ernie-3.0-medium-zh/resolve/main/config.json''',
    '''nghuyong/ernie-3.0-mini-zh''': '''https://huggingface.co/nghuyong/ernie-3.0-mini-zh/resolve/main/config.json''',
    '''nghuyong/ernie-3.0-micro-zh''': '''https://huggingface.co/nghuyong/ernie-3.0-micro-zh/resolve/main/config.json''',
    '''nghuyong/ernie-3.0-nano-zh''': '''https://huggingface.co/nghuyong/ernie-3.0-nano-zh/resolve/main/config.json''',
    '''nghuyong/ernie-gram-zh''': '''https://huggingface.co/nghuyong/ernie-gram-zh/resolve/main/config.json''',
    '''nghuyong/ernie-health-zh''': '''https://huggingface.co/nghuyong/ernie-health-zh/resolve/main/config.json''',
}

class 	__a   (       UpperCAmelCase    ):
		_a			:						List[str]    			=			'ernie'
		def __init__(    self    ,					_SCREAMING_SNAKE_CASE=30522    ,					_SCREAMING_SNAKE_CASE=768    ,					_SCREAMING_SNAKE_CASE=12    ,					_SCREAMING_SNAKE_CASE=12    ,					_SCREAMING_SNAKE_CASE=3072    ,					_SCREAMING_SNAKE_CASE="gelu"    ,					_SCREAMING_SNAKE_CASE=0.1    ,					_SCREAMING_SNAKE_CASE=0.1    ,					_SCREAMING_SNAKE_CASE=512    ,					_SCREAMING_SNAKE_CASE=2    ,					_SCREAMING_SNAKE_CASE=3    ,					_SCREAMING_SNAKE_CASE=False    ,					_SCREAMING_SNAKE_CASE=0.02    ,					_SCREAMING_SNAKE_CASE=1e-1_2    ,					_SCREAMING_SNAKE_CASE=0    ,					_SCREAMING_SNAKE_CASE="absolute"    ,					_SCREAMING_SNAKE_CASE=True    ,					_SCREAMING_SNAKE_CASE=None    ,					**_SCREAMING_SNAKE_CASE    ,					)				-> Optional[Any]:




									"""simple docstring"""





									super().__init__(pad_token_id=_SCREAMING_SNAKE_CASE    ,					**_SCREAMING_SNAKE_CASE		)

									_UpperCAmelCase					=    vocab_size
									_UpperCAmelCase					=    hidden_size
									_UpperCAmelCase					=    num_hidden_layers
									_UpperCAmelCase					=    num_attention_heads
									_UpperCAmelCase					=    hidden_act
									_UpperCAmelCase					=    intermediate_size
									_UpperCAmelCase					=    hidden_dropout_prob
									_UpperCAmelCase					=    attention_probs_dropout_prob
									_UpperCAmelCase					=    max_position_embeddings
									_UpperCAmelCase					=    type_vocab_size
									_UpperCAmelCase					=    task_type_vocab_size
									_UpperCAmelCase					=    use_task_id
									_UpperCAmelCase					=    initializer_range
									_UpperCAmelCase					=    layer_norm_eps
									_UpperCAmelCase					=    position_embedding_type
									_UpperCAmelCase					=    use_cache
									_UpperCAmelCase					=    classifier_dropout



class 	__a   (       UpperCAmelCase    ):
		@property
		def 			UpperCAmelCase__       (    self		)				-> Mapping[str, Mapping[int, str]]:




									"""simple docstring"""





									if self.task == "multiple-choice":
																_UpperCAmelCase					=    {0: 'batch', 1: 'choice', 2: 'sequence'}
									else:
																_UpperCAmelCase					=    {0: 'batch', 1: 'sequence'}
									return OrderedDict(
									    [
									        ('input_ids', dynamic_axis),
									        ('attention_mask', dynamic_axis),
									        ('token_type_ids', dynamic_axis),
									        ('task_type_ids', dynamic_axis),
									    ]		)




import warnings

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

class 	__a   (       UpperCAmelCase    ):
		_a			:						int    			=			['image_processor', 'tokenizer']
		_a			:						Union[str, Any]    			=			'AutoImageProcessor'
		_a			:						Optional[int]    			=			'AutoTokenizer'
		def __init__(    self    ,					_SCREAMING_SNAKE_CASE=None    ,					_SCREAMING_SNAKE_CASE=None    ,					**_SCREAMING_SNAKE_CASE		)				-> Tuple:




									"""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.'    ,					_SCREAMING_SNAKE_CASE    ,					)
																_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 have to specify an image_processor.'		)
									if tokenizer is None:
																raise ValueError('You have to specify a tokenizer.'		)

									super().__init__(_SCREAMING_SNAKE_CASE    ,					_SCREAMING_SNAKE_CASE		)
									_UpperCAmelCase					=    self.image_processor
		def __call__(    self    ,					_SCREAMING_SNAKE_CASE=None    ,					_SCREAMING_SNAKE_CASE=None    ,					_SCREAMING_SNAKE_CASE=None    ,					**_SCREAMING_SNAKE_CASE		)				-> Dict:




									"""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:
																_UpperCAmelCase					=    self.tokenizer(_SCREAMING_SNAKE_CASE    ,					return_tensors=_SCREAMING_SNAKE_CASE    ,					**_SCREAMING_SNAKE_CASE		)

									if images is not None:
																_UpperCAmelCase					=    self.image_processor(_SCREAMING_SNAKE_CASE    ,					return_tensors=_SCREAMING_SNAKE_CASE    ,					**_SCREAMING_SNAKE_CASE		)

									if text is not None and images is not None:
																_UpperCAmelCase					=    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 			UpperCAmelCase__       (    self    ,					*_SCREAMING_SNAKE_CASE    ,					**_SCREAMING_SNAKE_CASE		)				-> int:




									"""simple docstring"""





									return self.tokenizer.batch_decode(*_SCREAMING_SNAKE_CASE    ,					**_SCREAMING_SNAKE_CASE		)
		def 			UpperCAmelCase__       (    self    ,					*_SCREAMING_SNAKE_CASE    ,					**_SCREAMING_SNAKE_CASE		)				-> Tuple:




									"""simple docstring"""





									return self.tokenizer.decode(*_SCREAMING_SNAKE_CASE    ,					**_SCREAMING_SNAKE_CASE		)
		@property
		def 			UpperCAmelCase__       (    self		)				-> Optional[int]:




									"""simple docstring"""





									_UpperCAmelCase					=    self.tokenizer.model_input_names
									_UpperCAmelCase					=    self.image_processor.model_input_names
									return list(dict.fromkeys(tokenizer_input_names + image_processor_input_names		)		)
		@property
		def 			UpperCAmelCase__       (    self		)				-> Any:




									"""simple docstring"""





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






		@property
		def 			UpperCAmelCase__       (    self		)				-> Any:




									"""simple docstring"""





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