





'''simple docstring'''







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


snake_case_  :							str            =	logging.get_logger(__name__)

snake_case_  :							Union[str, Any]            =	{"vocab_file": "vocab.txt"}

snake_case_  :							List[Any]            =	{
    "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",
    }
}

snake_case_  :							int            =	{
    "tau/splinter-base": 5_12,
    "tau/splinter-base-qass": 5_12,
    "tau/splinter-large": 5_12,
    "tau/splinter-large-qass": 5_12,
}

snake_case_  :							Optional[Any]            =	{
    "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        __a   (lowerCamelCase  ):
							__a       : Any          =							VOCAB_FILES_NAMES
							__a       : Optional[int]          =							PRETRAINED_VOCAB_FILES_MAP
							__a       : Any          =							PRETRAINED_INIT_CONFIGURATION
							__a       : Dict          =							PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES
							__a       : Optional[Any]          =							SplinterTokenizer

							def __init__(				self				:  Union[str, Any]							,  __magic_name__				:  Optional[int]=None							,  __magic_name__				:  List[str]=None							,  __magic_name__				:  List[Any]=True							,  __magic_name__				:  int="[UNK]"							,  __magic_name__				:  Union[str, Any]="[SEP]"							,  __magic_name__				:  str="[PAD]"							,  __magic_name__				:  Dict="[CLS]"							,  __magic_name__				:  Any="[MASK]"							,  __magic_name__				:  Optional[Any]="[QUESTION]"							,  __magic_name__				:  int=True							,  __magic_name__				:  Tuple=None							,  **__magic_name__				:  List[str]							,  )       ->							Tuple:







													"""simple docstring"""
													super().__init__(
													    __magic_name__							,  tokenizer_file=__magic_name__							,  do_lower_case=__magic_name__							,  unk_token=__magic_name__							,  sep_token=__magic_name__							,  pad_token=__magic_name__							,  cls_token=__magic_name__							,  mask_token=__magic_name__							,  tokenize_chinese_chars=__magic_name__							,  strip_accents=__magic_name__							,  additional_special_tokens=(question_token,)							,  **__magic_name__							,  )

													UpperCAmelCase_      :   List[Any]      =	json.loads(self.backend_tokenizer.normalizer.__getstate__() )
													if (
													    pre_tok_state.get('''lowercase'''							,  __magic_name__ ) != do_lower_case
													    or pre_tok_state.get('''strip_accents'''							,  __magic_name__ ) != strip_accents
													):
																			UpperCAmelCase_      :   List[str]      =	getattr(__magic_name__							,  pre_tok_state.pop('''type''' ) )
																			UpperCAmelCase_      :   Optional[Any]      =	do_lower_case
																			UpperCAmelCase_      :   int      =	strip_accents
																			UpperCAmelCase_      :   List[Any]      =	pre_tok_class(**__magic_name__ )

													UpperCAmelCase_      :   Optional[Any]      =	do_lower_case

							@property
							def      UpperCAmelCase__						(				self				:  Dict )       ->							Dict:







													"""simple docstring"""
													return self.convert_tokens_to_ids(self.question_token )

							def      UpperCAmelCase__						(				self				:  Union[str, Any]							,  __magic_name__				:  List[int]							,  __magic_name__				:  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]

													UpperCAmelCase_      :   Union[str, Any]      =	[self.cls_token_id]
													UpperCAmelCase_      :   Optional[int]      =	[self.sep_token_id]
													UpperCAmelCase_      :   Optional[int]      =	[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				:  Any							,  __magic_name__				:  List[int]							,  __magic_name__				:  Optional[List[int]] = None )       ->							List[int]:







													"""simple docstring"""
													UpperCAmelCase_      :   List[str]      =	[self.sep_token_id]
													UpperCAmelCase_      :   int      =	[self.cls_token_id]
													UpperCAmelCase_      :   int      =	[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				:  List[str]							,  __magic_name__				:  str							,  __magic_name__				:  Optional[str] = None )       ->							Tuple[str]:







													"""simple docstring"""
													UpperCAmelCase_      :   Optional[Any]      =	self._tokenizer.model.save(__magic_name__							,  name=__magic_name__ )
													return tuple(__magic_name__ )













"""simple docstring"""
from __future__ import annotations






def 			lowerCamelCase_    (		_lowerCamelCase							):
 lowerCamelCase__	:     int
 lowerCamelCase__	:     list[str]								=		list(_lowerCamelCase							)
 lowerCamelCase__							,	lowerCamelCase__	:     Union[str, Any]								=		_vector[:-1], int(_vector[-1]							)
 lowerCamelCase__	:     list[int]								=		[int(_lowerCamelCase							) for digit in __vector]

 vector.reverse()
 for i, digit in enumerate(_lowerCamelCase							):
  if i & 1 == 0:
   lowerCamelCase__	:     int								=		digit * 2
   if doubled > 9:
    doubled -= 9
   check_digit += doubled
  else:
   check_digit += digit

 return check_digit % 10 == 0


if __name__ == "__main__":
      import doctest

      doctest.testmod()
      assert is_luhn("79927398713")
      assert not is_luhn("79927398714")

