




import json
from typing import List, Optional, Tuple

from tokenizers import normalizers

from ...tokenization_utils_fast import PreTrainedTokenizerFast
from ...utils import logging
from .tokenization_splinter import SplinterTokenizer


_lowerCAmelCase  :				Tuple						=				logging.get_logger(__name__)

_lowerCAmelCase  :				Tuple						=				{"vocab_file": "vocab.txt"}

_lowerCAmelCase  :				int						=				{
    "vocab_file": {
        "tau/splinter-base": "https://huggingface.co/tau/splinter-base/resolve/main/vocab.txt",
        "tau/splinter-base-qass": "https://huggingface.co/tau/splinter-base-qass/resolve/main/vocab.txt",
        "tau/splinter-large": "https://huggingface.co/tau/splinter-large/resolve/main/vocab.txt",
        "tau/splinter-large-qass": "https://huggingface.co/tau/splinter-large-qass/resolve/main/vocab.txt",
    }
}

_lowerCAmelCase  :				Optional[Any]						=				{
    "tau/splinter-base": 5_1_2,
    "tau/splinter-base-qass": 5_1_2,
    "tau/splinter-large": 5_1_2,
    "tau/splinter-large-qass": 5_1_2,
}

_lowerCAmelCase  :				List[str]						=				{
    "tau/splinter-base": {"do_lower_case": False},
    "tau/splinter-base-qass": {"do_lower_case": False},
    "tau/splinter-large": {"do_lower_case": False},
    "tau/splinter-large-qass": {"do_lower_case": False},
}
class      _UpperCamelCase (			lowerCAmelCase						):
      UpperCAmelCase_            =						VOCAB_FILES_NAMES
      UpperCAmelCase_            =						PRETRAINED_VOCAB_FILES_MAP
      UpperCAmelCase_            =						PRETRAINED_INIT_CONFIGURATION
      UpperCAmelCase_            =						PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES
      UpperCAmelCase_            =						SplinterTokenizer
      def __init__(     self				:Any	, lowerCamelCase				:Tuple=None	, lowerCamelCase				:List[Any]=None	, lowerCamelCase				:Optional[Any]=True	, lowerCamelCase				:int="[UNK]"	, lowerCamelCase				:int="[SEP]"	, lowerCamelCase				:Union[str, Any]="[PAD]"	, lowerCamelCase				:Optional[int]="[CLS]"	, lowerCamelCase				:Union[str, Any]="[MASK]"	, lowerCamelCase				:Tuple="[QUESTION]"	, lowerCamelCase				:Optional[int]=True	, lowerCamelCase				:Optional[int]=None	, **lowerCamelCase				:str	, )       ->     Optional[int]:
       super().__init__(
           lowerCamelCase	, tokenizer_file=lowerCamelCase	, do_lower_case=lowerCamelCase	, unk_token=lowerCamelCase	, sep_token=lowerCamelCase	, pad_token=lowerCamelCase	, cls_token=lowerCamelCase	, mask_token=lowerCamelCase	, tokenize_chinese_chars=lowerCamelCase	, strip_accents=lowerCamelCase	, additional_special_tokens=(question_token,)	, **lowerCamelCase	, )

       UpperCAmelCase__								=  json.loads(self.backend_tokenizer.normalizer.__getstate__() )
       if (
           pre_tok_state.get("lowercase"	, lowerCamelCase ) != do_lower_case
           or pre_tok_state.get("strip_accents"	, lowerCamelCase ) != strip_accents
       ):
        UpperCAmelCase__								=  getattr(lowerCamelCase	, pre_tok_state.pop("type" ) )
        UpperCAmelCase__								=  do_lower_case
        UpperCAmelCase__								=  strip_accents
        UpperCAmelCase__								=  pre_tok_class(**lowerCamelCase )

       UpperCAmelCase__								=  do_lower_case
      @property
      def 		UpperCAmelCase_  (     self				:int )       ->     List[Any]:
       return self.convert_tokens_to_ids(self.question_token )
      def 		UpperCAmelCase_  (     self				:Union[str, Any]	, lowerCamelCase				:List[int]	, lowerCamelCase				:Optional[List[int]] = None )       ->     List[int]:
       if token_ids_a is None:
        return [self.cls_token_id] + token_ids_a + [self.sep_token_id]

       UpperCAmelCase__								=  [self.cls_token_id]
       UpperCAmelCase__								=  [self.sep_token_id]
       UpperCAmelCase__								=  [self.question_token_id] + [self.convert_tokens_to_ids("." )]
       if self.padding_side == "right":
        # Input is question-then-context
        return cls + token_ids_a + question_suffix + sep + token_ids_a + sep
       else:
        # Input is context-then-question
        return cls + token_ids_a + sep + token_ids_a + question_suffix + sep
      def 		UpperCAmelCase_  (     self				:List[Any]	, lowerCamelCase				:List[int]	, lowerCamelCase				:Optional[List[int]] = None )       ->     List[int]:
       UpperCAmelCase__								=  [self.sep_token_id]
       UpperCAmelCase__								=  [self.cls_token_id]
       UpperCAmelCase__								=  [self.question_token_id] + [self.convert_tokens_to_ids("." )]
       if token_ids_a is None:
        return len(cls + token_ids_a + sep ) * [0]

       if self.padding_side == "right":
        # Input is question-then-context
        return len(cls + token_ids_a + question_suffix + sep ) * [0] + len(token_ids_a + sep ) * [1]
       else:
        # Input is context-then-question
        return len(cls + token_ids_a + sep ) * [0] + len(token_ids_a + question_suffix + sep ) * [1]







      def 		UpperCAmelCase_  (     self				:Dict	, lowerCamelCase				:str	, lowerCamelCase				:Optional[str] = None )       ->     Tuple[str]:
       UpperCAmelCase__								=  self._tokenizer.model.save(lowerCamelCase	, name=lowerCamelCase )
       return tuple(lowerCamelCase )






from collections import OrderedDict
from typing import Mapping

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


_lowerCAmelCase  :				Dict						=				logging.get_logger(__name__)

_lowerCAmelCase  :				Optional[int]						=				{
    "google/rembert": "https://huggingface.co/google/rembert/resolve/main/config.json",
    # See all RemBERT models at https://huggingface.co/models?filter=rembert
}
class      _UpperCamelCase (			lowerCAmelCase						):
      UpperCAmelCase_            =						"""rembert"""
      def __init__(     self				:Union[str, Any]	, lowerCamelCase				:Union[str, Any]=25_0300	, lowerCamelCase				:Optional[Any]=1152	, lowerCamelCase				:Optional[int]=32	, lowerCamelCase				:Union[str, Any]=18	, lowerCamelCase				:str=256	, lowerCamelCase				:Any=1664	, lowerCamelCase				:Any=4608	, lowerCamelCase				:List[str]="gelu"	, lowerCamelCase				:Optional[Any]=0.0	, lowerCamelCase				:Optional[int]=0.0	, lowerCamelCase				:Dict=0.1	, lowerCamelCase				:List[str]=512	, lowerCamelCase				:int=2	, lowerCamelCase				:str=0.02	, lowerCamelCase				:Optional[int]=1e-12	, lowerCamelCase				:List[Any]=True	, lowerCamelCase				:Optional[Any]=0	, lowerCamelCase				:Optional[Any]=312	, lowerCamelCase				:int=313	, **lowerCamelCase				:Dict	, )       ->     Any:
       super().__init__(pad_token_id=lowerCamelCase	, bos_token_id=lowerCamelCase	, eos_token_id=lowerCamelCase	, **lowerCamelCase )

       UpperCAmelCase__								=  vocab_size
       UpperCAmelCase__								=  input_embedding_size
       UpperCAmelCase__								=  output_embedding_size
       UpperCAmelCase__								=  max_position_embeddings
       UpperCAmelCase__								=  hidden_size
       UpperCAmelCase__								=  num_hidden_layers
       UpperCAmelCase__								=  num_attention_heads
       UpperCAmelCase__								=  intermediate_size
       UpperCAmelCase__								=  hidden_act
       UpperCAmelCase__								=  hidden_dropout_prob
       UpperCAmelCase__								=  attention_probs_dropout_prob
       UpperCAmelCase__								=  classifier_dropout_prob
       UpperCAmelCase__								=  initializer_range
       UpperCAmelCase__								=  type_vocab_size
       UpperCAmelCase__								=  layer_norm_eps
       UpperCAmelCase__								=  use_cache
       UpperCAmelCase__								=  False



class      _UpperCamelCase (			lowerCAmelCase						):
      @property
      def 		UpperCAmelCase_  (     self				:List[Any] )       ->     Mapping[str, Mapping[int, str]]:
       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),
           ] )







      @property
      def 		UpperCAmelCase_  (     self				:Union[str, Any] )       ->     float:
       return 1e-4





