

from typing import Dict, List, Optional

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


a__				=		logging.get_logger(__name__)


a__				=		{
    'nielsr/canine-s': 2048,
}

# Unicode defines 1,114,112 total “codepoints”
a__				=		1114112

# Below: Constants defining canonical codepoints for special, pseudo-characters.
# Copied from https://github.com/google-research/language/blob/master/language/canine/special_codepoints.py
a__				=		0

a__				=		0XE0_00
a__				=		0XE0_01
a__				=		0XE0_02
a__				=		0XE0_03
a__				=		0XE0_04

# Maps special codepoints to human-readable names.
a__				=		{
    # Special symbols are represented using codepoints values that are valid,
    # but designated as "Private Use", meaning that they will never be assigned
    # characters by the Unicode Consortium, and are thus safe for use here.
    #
    # NOTE: Do *NOT* add any sort of [UNK_CHAR] here. They are explicitly
    # excluded and should fail with a hard error.
    CLS: "[CLS]",
    SEP: "[SEP]",
    BOS: "[BOS]",
    MASK: "[MASK]",
    PAD: "[PAD]",
    RESERVED: "[RESERVED]",
}

# Maps special codepoint human-readable names to their codepoint values.
a__				=		{name: codepoint for codepoint, name in SPECIAL_CODEPOINTS.items()}

class 				UpperCAmelCase_		(			lowercase__   ):
							"""simple docstring"""







							UpperCAmelCase__       :						int	    =    PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES


							def __init__(			self       ,							_a=chr(SCREAMING_SNAKE_CASE__       )       ,							_a=chr(SCREAMING_SNAKE_CASE__       )       ,							_a=chr(SCREAMING_SNAKE_CASE__       )       ,							_a=chr(SCREAMING_SNAKE_CASE__       )       ,							_a=chr(SCREAMING_SNAKE_CASE__       )       ,							_a=chr(SCREAMING_SNAKE_CASE__       )       ,							_a=False       ,							_a=2_0_4_8       ,							**_a       ,							)    ->    List[Any]:
												_a	:    List[str]         =		AddedToken(SCREAMING_SNAKE_CASE__       ,							lstrip=SCREAMING_SNAKE_CASE__       ,							rstrip=SCREAMING_SNAKE_CASE__       ) if isinstance(SCREAMING_SNAKE_CASE__       ,							SCREAMING_SNAKE_CASE__       ) else bos_token
												_a	:    Optional[Any]         =		AddedToken(SCREAMING_SNAKE_CASE__       ,							lstrip=SCREAMING_SNAKE_CASE__       ,							rstrip=SCREAMING_SNAKE_CASE__       ) if isinstance(SCREAMING_SNAKE_CASE__       ,							SCREAMING_SNAKE_CASE__       ) else eos_token
												_a	:    Optional[int]         =		AddedToken(SCREAMING_SNAKE_CASE__       ,							lstrip=SCREAMING_SNAKE_CASE__       ,							rstrip=SCREAMING_SNAKE_CASE__       ) if isinstance(SCREAMING_SNAKE_CASE__       ,							SCREAMING_SNAKE_CASE__       ) else sep_token
												_a	:    Union[str, Any]         =		AddedToken(SCREAMING_SNAKE_CASE__       ,							lstrip=SCREAMING_SNAKE_CASE__       ,							rstrip=SCREAMING_SNAKE_CASE__       ) if isinstance(SCREAMING_SNAKE_CASE__       ,							SCREAMING_SNAKE_CASE__       ) else cls_token
												_a	:    Tuple         =		AddedToken(SCREAMING_SNAKE_CASE__       ,							lstrip=SCREAMING_SNAKE_CASE__       ,							rstrip=SCREAMING_SNAKE_CASE__       ) if isinstance(SCREAMING_SNAKE_CASE__       ,							SCREAMING_SNAKE_CASE__       ) else pad_token

												# Mask token behave like a normal word, i.e. include the space before it
												_a	:    Optional[Any]         =		AddedToken(SCREAMING_SNAKE_CASE__       ,							lstrip=SCREAMING_SNAKE_CASE__       ,							rstrip=SCREAMING_SNAKE_CASE__       ) if isinstance(SCREAMING_SNAKE_CASE__       ,							SCREAMING_SNAKE_CASE__       ) else mask_token

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

												# Creates a mapping for looking up the IDs of special symbols.
												_a	:    Dict[str, int]         =		{}
												for codepoint, name in SPECIAL_CODEPOINTS.items():
																	_a	:    Optional[int]         =		codepoint

												# Creates a mapping for looking up the string forms of special symbol IDs.
												_a	:    Dict[int, str]         =		{
												    codepoint: name for name, codepoint in self._special_codepoints.items()
												}

												_a	:    Dict         =		UNICODE_VOCAB_SIZE
												_a	:    Any         =		len(self._special_codepoints       )


							@property
							def 				__lowercase				(			self       )    ->    int:
												return self._unicode_vocab_size


							def 				__lowercase				(			self       ,							_a       )    ->    List[str]:
												return list(SCREAMING_SNAKE_CASE__       )


							def 				__lowercase				(			self       ,							_a       )    ->    int:
												try:
																	return ord(SCREAMING_SNAKE_CASE__       )
												except TypeError:
																	raise ValueError(F"""invalid token: '{token}'"""       )


							def 				__lowercase				(			self       ,							_a       )    ->    str:
												try:
																	if index in SPECIAL_CODEPOINTS:
																						return SPECIAL_CODEPOINTS[index]
																	return chr(SCREAMING_SNAKE_CASE__       )
												except TypeError:
																	raise ValueError(F"""invalid id: {index}"""       )


							def 				__lowercase				(			self       ,							_a       )    ->    Union[str, Any]:
												return "".join(SCREAMING_SNAKE_CASE__       )


							def 				__lowercase				(			self       ,							_a       ,							_a = None       )    ->    List[int]:
												_a	:    int         =		[self.sep_token_id]
												_a	:    Optional[int]         =		[self.cls_token_id]

												_a	:    Optional[int]         =		cls + token_ids_a + sep
												if token_ids_a is not None:
																	result += token_ids_a + sep
												return result


							def 				__lowercase				(			self       ,							_a       ,							_a = None       ,							_a = False       )    ->    List[int]:
												if already_has_special_tokens:
																	return super().get_special_tokens_mask(
																	    token_ids_a=SCREAMING_SNAKE_CASE__       ,							token_ids_a=SCREAMING_SNAKE_CASE__       ,							already_has_special_tokens=SCREAMING_SNAKE_CASE__       )

												_a	:    Dict         =		[1] + ([0] * len(SCREAMING_SNAKE_CASE__       )) + [1]
												if token_ids_a is not None:
																	result += ([0] * len(SCREAMING_SNAKE_CASE__       )) + [1]
												return result


							def 				__lowercase				(			self       ,							_a       ,							_a = None       )    ->    List[int]:
												_a	:    int         =		[self.sep_token_id]
												_a	:    int         =		[self.cls_token_id]

												_a	:    Optional[Any]         =		len(cls + token_ids_a + sep       ) * [0]
												if token_ids_a is not None:
																	result += len(token_ids_a + sep       ) * [1]
												return result




							def 				__lowercase				(			self       ,							_a       ,							_a = None       )    ->    Union[str, Any]:
												return ()







from collections import OrderedDict
from typing import Mapping

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


UpperCAmelCase_      : str  					=       logging.get_logger(__name__)

UpperCAmelCase_      : List[str]  					=       {
    'YituTech/conv-bert-base': 'https://huggingface.co/YituTech/conv-bert-base/resolve/main/config.json',
    'YituTech/conv-bert-medium-small': (
        'https://huggingface.co/YituTech/conv-bert-medium-small/resolve/main/config.json'
    ),
    'YituTech/conv-bert-small': 'https://huggingface.co/YituTech/conv-bert-small/resolve/main/config.json',
    # See all ConvBERT models at https://huggingface.co/models?filter=convbert
}
class  SCREAMING_SNAKE_CASE__  (				lowercase__			):
      snake_case__				:     Optional[int]        =						'''convbert'''
      def __init__(       self				:       List[Any]     ,							SCREAMING_SNAKE_CASE__				:       Optional[int]=3_0_5_2_2     ,							SCREAMING_SNAKE_CASE__				:       Dict=7_6_8     ,							SCREAMING_SNAKE_CASE__				:       Optional[int]=1_2     ,							SCREAMING_SNAKE_CASE__				:       Union[str, Any]=1_2     ,							SCREAMING_SNAKE_CASE__				:       str=3_0_7_2     ,							SCREAMING_SNAKE_CASE__				:       Dict="gelu"     ,							SCREAMING_SNAKE_CASE__				:       Dict=0.1     ,							SCREAMING_SNAKE_CASE__				:       Tuple=0.1     ,							SCREAMING_SNAKE_CASE__				:       List[str]=5_1_2     ,							SCREAMING_SNAKE_CASE__				:       Optional[Any]=2     ,							SCREAMING_SNAKE_CASE__				:       List[Any]=0.02     ,							SCREAMING_SNAKE_CASE__				:       Any=1E-12     ,							SCREAMING_SNAKE_CASE__				:       int=1     ,							SCREAMING_SNAKE_CASE__				:       int=0     ,							SCREAMING_SNAKE_CASE__				:       Optional[int]=2     ,							SCREAMING_SNAKE_CASE__				:       Optional[int]=7_6_8     ,							SCREAMING_SNAKE_CASE__				:       Union[str, Any]=2     ,							SCREAMING_SNAKE_CASE__				:       List[Any]=9     ,							SCREAMING_SNAKE_CASE__				:       List[Any]=1     ,							SCREAMING_SNAKE_CASE__				:       Dict=None     ,							**SCREAMING_SNAKE_CASE__				:       List[Any]     ,							)		->			Any:
             super().__init__(
                 pad_token_id=SCREAMING_SNAKE_CASE__     ,							bos_token_id=SCREAMING_SNAKE_CASE__     ,							eos_token_id=SCREAMING_SNAKE_CASE__     ,							**SCREAMING_SNAKE_CASE__     ,							)

             a_					:		Tuple							=  vocab_size
             a_					:		List[str]							=  hidden_size
             a_					:		List[str]							=  num_hidden_layers
             a_					:		Dict							=  num_attention_heads
             a_					:		Optional[int]							=  intermediate_size
             a_					:		int							=  hidden_act
             a_					:		Dict							=  hidden_dropout_prob
             a_					:		int							=  attention_probs_dropout_prob
             a_					:		str							=  max_position_embeddings
             a_					:		List[str]							=  type_vocab_size
             a_					:		List[str]							=  initializer_range
             a_					:		Tuple							=  layer_norm_eps
             a_					:		Optional[int]							=  embedding_size
             a_					:		List[Any]							=  head_ratio
             a_					:		List[Any]							=  conv_kernel_size
             a_					:		Tuple							=  num_groups
             a_					:		Tuple							=  classifier_dropout
class  SCREAMING_SNAKE_CASE__  (				lowercase__			):
      @property
      def        SCREAMING_SNAKE_CASE							(       self				:       List[str]     )		->			Mapping[str, Mapping[int, str]]:
             if self.task == "multiple-choice":
                    a_					:		Tuple							=  {0: 'batch', 1: 'choice', 2: 'sequence'}
             else:
                    a_					:		List[str]							=  {0: 'batch', 1: 'sequence'}
             return OrderedDict(
                 [
                     ('input_ids', dynamic_axis),
                     ('attention_mask', dynamic_axis),
                     ('token_type_ids', dynamic_axis),
                 ]     )


