






from typing import Dict, List, Optional, Tuple

from ...tokenization_utils import AddedToken, PreTrainedTokenizer
from ...utils import logging


a_      = logging.get_logger(__name__)





class 		SCREAMING_SNAKE_CASE__   (     lowercase_    ):
		_UpperCAmelCase         =['''input_ids''', '''attention_mask''']



		def __init__(    self:    Optional[Any]				,   a:    Union[str, Any]="[PAD]"				,   a:    Any="[BOS]"				,   a:    List[str]="[EOS]"				,   a:    List[str]="[MASK]"				,   a:    Dict="[CLS]"				,   a:    Tuple="[SEP]"				,   a:    Union[str, Any]=20_48				,   **a:    Optional[int]				,   )  ->None:






								'''simple docstring'''


								a_				     =   AddedToken(a				,   lstrip=a				,   rstrip=a) if isinstance(a				,   a) else pad_token
								a_				     =   AddedToken(a				,   lstrip=a				,   rstrip=a) if isinstance(a				,   a) else bos_token
								a_				     =   AddedToken(a				,   lstrip=a				,   rstrip=a) if isinstance(a				,   a) else eos_token
								a_				     =   AddedToken(a				,   lstrip=a				,   rstrip=a) if isinstance(a				,   a) else mask_token
								a_				     =   AddedToken(a				,   lstrip=a				,   rstrip=a) if isinstance(a				,   a) else cls_token
								a_				     =   AddedToken(a				,   lstrip=a				,   rstrip=a) if isinstance(a				,   a) else sep_token

								super().__init__(
								    pad_token=a				,   bos_token=a				,   eos_token=a				,   mask_token=a				,   cls_token=a				,   sep_token=a				,   model_max_length=a				,   **a				,   )

								a_				     =   2**8  # utf is 8 bits

								# define special tokens dict
								a_				     =   {
								    self.pad_token: 0,
								    self.bos_token: 1,
								    self.eos_token: 2,
								    self.mask_token: 3,
								    self.cls_token: 4,
								    self.sep_token: 5,
								}
								a_				     =   len(self.special_tokens_encoder)
								a_				     =   {v: k for k, v in self.special_tokens_encoder.items()}



		def _lowerCAmelCase     (    self:    Optional[Any])  ->Dict[str, int]:






								'''simple docstring'''


								a_				     =   self.special_tokens_encoder.copy()
								vocab.update(self.added_tokens_encoder)
								for i in range(self._utf_vocab_size):
														a_				     =   chr(a)
														a_				     =   i + len(self.special_tokens_encoder)
								return vocab



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






								'''simple docstring'''


								return self._utf_vocab_size + self._num_special_tokens



		def _lowerCAmelCase     (    self:    int				,   a:    List[int]				,   a:    Optional[List[int]] = None				,   a:    bool = False)  ->List[int]:






								'''simple docstring'''


								if already_has_special_tokens:
														return super().get_special_tokens_mask(
														    token_ids_a=a				,   token_ids_a=a				,   already_has_special_tokens=a)

								# normal case: some special tokens
								if token_ids_a is None:
														return [1] + [0] * len(a) + [1]
								return [1] + ([0] * len(a)) + [1] + ([0] * len(a)) + [1]



		def _lowerCAmelCase     (    self:    Tuple				,   a:    List[int]				,   a:    Optional[List[int]] = None)  ->List[int]:






								'''simple docstring'''


								if token_ids_a is None:
														return [self.cls_token_id] + token_ids_a + [self.sep_token_id]
								else:
														return [self.cls_token_id] + token_ids_a + [self.sep_token_id] + token_ids_a + [self.sep_token_id]



		def _lowerCAmelCase     (    self:    List[Any]				,   a:    str)  ->List[str]:






								'''simple docstring'''


								a_				     =   [chr(a) for i in text.encode("utf-8")]
								return tokens



		def _lowerCAmelCase     (    self:    Any				,   a:    Union[str, Any])  ->List[Any]:






								'''simple docstring'''


								if token in self.special_tokens_encoder:
														a_				     =   self.special_tokens_encoder[token]
								elif token in self.added_tokens_encoder:
														a_				     =   self.added_tokens_encoder[token]
								elif len(a) != 1:
														a_				     =   self.unk_token_id
								else:
														a_				     =   ord(a) + self._num_special_tokens
								return token_id



		def _lowerCAmelCase     (    self:    int				,   a:    List[Any])  ->List[str]:






								'''simple docstring'''


								if index in self.special_tokens_decoder:
														a_				     =   self.special_tokens_decoder[index]
								elif index in self.added_tokens_decoder:
														a_				     =   self.added_tokens_decoder[index]
								else:
														a_				     =   chr(index - self._num_special_tokens)
								return token



		def _lowerCAmelCase     (    self:    Optional[int]				,   a:    Optional[int])  ->Optional[int]:






								'''simple docstring'''


								a_				     =   b""
								for token in tokens:
														if token in self.special_tokens_decoder:
																				a_				     =   self.special_tokens_decoder[token].encode("utf-8")
														elif token in self.added_tokens_decoder:
																				a_				     =   self.special_tokens_decoder[token].encode("utf-8")
														elif token in self.special_tokens_encoder:
																				a_				     =   token.encode("utf-8")
														elif token in self.added_tokens_encoder:
																				a_				     =   token.encode("utf-8")
														else:
																				a_				     =   bytes([ord(a)])
														bstring += tok_string
								a_				     =   bstring.decode("utf-8"				,   errors="replace")
								return string




		def _lowerCAmelCase     (    self:    Optional[Any]				,   a:    str				,   a:    Optional[str] = None)  ->Tuple[str]:






								'''simple docstring'''


								return ()











'''simple docstring'''





from collections import OrderedDict
from typing import Mapping

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


a_      = logging.get_logger(__name__)

a_      = {
    'google/mobilebert-uncased': 'https://huggingface.co/google/mobilebert-uncased/resolve/main/config.json'
}





class 		SCREAMING_SNAKE_CASE__   (     lowercase_    ):
		_UpperCAmelCase         =MOBILEBERT_PRETRAINED_CONFIG_ARCHIVE_MAP
		_UpperCAmelCase         ='''mobilebert'''



		def __init__(    self:    Union[str, Any]				,   a:    str=3_05_22				,   a:    List[str]=5_12				,   a:    List[str]=24				,   a:    Dict=4				,   a:    List[str]=5_12				,   a:    Optional[int]="relu"				,   a:    Dict=0.0				,   a:    Union[str, Any]=0.1				,   a:    int=5_12				,   a:    Optional[Any]=2				,   a:    List[Any]=0.02				,   a:    Optional[Any]=1e-12				,   a:    List[Any]=0				,   a:    Optional[int]=1_28				,   a:    Union[str, Any]=True				,   a:    Dict=True				,   a:    List[Any]=1_28				,   a:    Any=False				,   a:    Any=True				,   a:    Dict=4				,   a:    List[Any]="no_norm"				,   a:    Any=True				,   a:    Tuple=None				,   **a:    Any				,   )  ->Any:






								'''simple docstring'''


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

								a_				     =   vocab_size
								a_				     =   hidden_size
								a_				     =   num_hidden_layers
								a_				     =   num_attention_heads
								a_				     =   hidden_act
								a_				     =   intermediate_size
								a_				     =   hidden_dropout_prob
								a_				     =   attention_probs_dropout_prob
								a_				     =   max_position_embeddings
								a_				     =   type_vocab_size
								a_				     =   initializer_range
								a_				     =   layer_norm_eps
								a_				     =   embedding_size
								a_				     =   trigram_input
								a_				     =   use_bottleneck
								a_				     =   intra_bottleneck_size
								a_				     =   use_bottleneck_attention
								a_				     =   key_query_shared_bottleneck
								a_				     =   num_feedforward_networks
								a_				     =   normalization_type
								a_				     =   classifier_activation

								if self.use_bottleneck:
														a_				     =   intra_bottleneck_size
								else:
														a_				     =   hidden_size

								a_				     =   classifier_dropout





class 		SCREAMING_SNAKE_CASE__   (     lowercase_    ):



		@property
		def _lowerCAmelCase     (    self:    Optional[int])  ->Mapping[str, Mapping[int, str]]:






								'''simple docstring'''


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



