

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


__UpperCAmelCase      = logging.get_logger(__name__)

__UpperCAmelCase      = {"""vocab_file""": """vocab.txt"""}

__UpperCAmelCase      = {
    """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""",
    }
}

__UpperCAmelCase      = {
    """tau/splinter-base""": 512,
    """tau/splinter-base-qass""": 512,
    """tau/splinter-large""": 512,
    """tau/splinter-large-qass""": 512,
}

__UpperCAmelCase      = {
    """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 SCREAMING_SNAKE_CASE	(  a_ ):
  """simple docstring"""






  lowerCamelCase    :			Dict						      =VOCAB_FILES_NAMES
  lowerCamelCase    :			List[Any]						      =PRETRAINED_VOCAB_FILES_MAP
  lowerCamelCase    :			Optional[Any]						      =PRETRAINED_INIT_CONFIGURATION
  lowerCamelCase    :			Optional[Any]						      =PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES
  lowerCamelCase    :			Dict						      =SplinterTokenizer







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






     """simple docstring"""







     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       ,							)

     __lowerCAmelCase  :			int					    =						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
     ):
        __lowerCAmelCase  :			List[Any]					    =						getattr(lowerCAmelCase       ,							pre_tok_state.pop("""type"""    )    )
        __lowerCAmelCase  :			str					    =						do_lower_case
        __lowerCAmelCase  :			Any					    =						strip_accents
        __lowerCAmelCase  :			int					    =						pre_tok_class(**lowerCAmelCase    )

     __lowerCAmelCase  :			Tuple					    =						do_lower_case







  @property
  def        SCREAMING_SNAKE_CASE    (			self :    Optional[Any]    )							->	List[str]:






     """simple docstring"""







     return self.convert_tokens_to_ids(self.question_token    )







  def        SCREAMING_SNAKE_CASE    (			self :    int       ,							lowerCAmelCase :    List[int]       ,							lowerCAmelCase :    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]

     __lowerCAmelCase  :			Optional[int]					    =						[self.cls_token_id]
     __lowerCAmelCase  :			str					    =						[self.sep_token_id]
     __lowerCAmelCase  :			List[str]					    =						[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        SCREAMING_SNAKE_CASE    (			self :    Dict       ,							lowerCAmelCase :    List[int]       ,							lowerCAmelCase :    Optional[List[int]] = None    )							->	List[int]:






     """simple docstring"""







     __lowerCAmelCase  :			Any					    =						[self.sep_token_id]
     __lowerCAmelCase  :			str					    =						[self.cls_token_id]
     __lowerCAmelCase  :			List[Any]					    =						[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        SCREAMING_SNAKE_CASE    (			self :    List[Any]       ,							lowerCAmelCase :    str       ,							lowerCAmelCase :    Optional[str] = None    )							->	Tuple[str]:






     """simple docstring"""







     __lowerCAmelCase  :			Optional[int]					    =						self._tokenizer.model.save(lowerCAmelCase       ,							name=lowerCAmelCase    )
     return tuple(lowerCAmelCase    )







def        __a     (    lowerCAmelCase_   :					list				)      -> bool:






						'''simple docstring'''



						if not isinstance(lowerCAmelCase_			,lowerCAmelCase_				):
												raise ValueError("""Input series is not valid, valid series - [1, 2/3, 2]"""				)
						if len(lowerCAmelCase_				) == 0:
												raise ValueError("""Input list must be a non empty list"""				)
						if len(lowerCAmelCase_				) == 1 and series[0] != 0:
												return True
						UpperCAmelCase_=   []
						UpperCAmelCase_=   len(lowerCAmelCase_				)
						for i in range(0			,lowerCAmelCase_				):
												if series[i] == 0:
																		raise ValueError("""Input series cannot have 0 as an element"""				)
												rec_series.append(1 / series[i]				)
						UpperCAmelCase_=   rec_series[1] - rec_series[0]
						for index in range(2			,lowerCAmelCase_				):
												if rec_series[index] - rec_series[index - 1] != common_diff:
																		return False
						return True



def        __a     (    lowerCAmelCase_   :					list				)      -> float:






						'''simple docstring'''



						if not isinstance(lowerCAmelCase_			,lowerCAmelCase_				):
												raise ValueError("""Input series is not valid, valid series - [2, 4, 6]"""				)
						if len(lowerCAmelCase_				) == 0:
												raise ValueError("""Input list must be a non empty list"""				)
						UpperCAmelCase_=   0
						for val in series:
												answer += 1 / val
						return len(lowerCAmelCase_				) / answer


if __name__ == "__main__":
	import doctest

	doctest.testmod()




