"""simple docstring"""







import os
import re
import unicodedata
from shutil import copyfile
from typing import Any, Dict, List, Optional, Tuple

import sentencepiece as spm

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


_SCREAMING_SNAKE_CASE	:		Any   =   logging.get_logger(__name__)
_SCREAMING_SNAKE_CASE	:		Dict   =   {'''vocab_file''': '''spiece.model'''}

_SCREAMING_SNAKE_CASE	:		List[str]   =   {
    '''vocab_file''': {
        '''google/fnet-base''': '''https://huggingface.co/google/fnet-base/resolve/main/spiece.model''',
        '''google/fnet-large''': '''https://huggingface.co/google/fnet-large/resolve/main/spiece.model''',
    },
}

_SCREAMING_SNAKE_CASE	:		Tuple   =   {
    '''google/fnet-base''': 5_1_2,
    '''google/fnet-large''': 5_1_2,
}

_SCREAMING_SNAKE_CASE	:		List[str]   =   '''▁'''






class      _SCREAMING_SNAKE_CASE							(			_lowerCamelCase				):



   '''simple docstring'''



   __UpperCAmelCase	:							Any    =    VOCAB_FILES_NAMES
   __UpperCAmelCase	:							Union[str, Any]    =    PRETRAINED_VOCAB_FILES_MAP
   __UpperCAmelCase	:							List[Any]    =    PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES
   __UpperCAmelCase	:							Optional[Any]    =    ["input_ids", "token_type_ids"]







   def __init__(	self ,				_SCREAMING_SNAKE_CASE ,				_SCREAMING_SNAKE_CASE=False ,				_SCREAMING_SNAKE_CASE=True ,				_SCREAMING_SNAKE_CASE=True ,				_SCREAMING_SNAKE_CASE="<unk>" ,				_SCREAMING_SNAKE_CASE="[SEP]" ,				_SCREAMING_SNAKE_CASE="<pad>" ,				_SCREAMING_SNAKE_CASE="[CLS]" ,				_SCREAMING_SNAKE_CASE="[MASK]" ,				_SCREAMING_SNAKE_CASE = None ,				**_SCREAMING_SNAKE_CASE ,				):


      '''simple docstring'''

      __lowerCamelCase    		=					(
          AddedToken(__UpperCamelCase ,				lstrip=__UpperCamelCase ,				rstrip=__UpperCamelCase ,				normalized=__UpperCamelCase	)
          if isinstance(__UpperCamelCase ,				__UpperCamelCase	)
          else mask_token
      )

      __lowerCamelCase    		=					{} if sp_model_kwargs is None else sp_model_kwargs

      super().__init__(
          do_lower_case=__UpperCamelCase ,				remove_space=__UpperCamelCase ,				keep_accents=__UpperCamelCase ,				unk_token=__UpperCamelCase ,				sep_token=__UpperCamelCase ,				pad_token=__UpperCamelCase ,				cls_token=__UpperCamelCase ,				mask_token=__UpperCamelCase ,				sp_model_kwargs=self.sp_model_kwargs ,				**__UpperCamelCase ,				)

      __lowerCamelCase    		=					do_lower_case
      __lowerCamelCase    		=					remove_space
      __lowerCamelCase    		=					keep_accents
      __lowerCamelCase    		=					vocab_file

      __lowerCamelCase    		=					spm.SentencePieceProcessor(**self.sp_model_kwargs	)
      self.sp_model.Load(__UpperCamelCase	)







   @property
   def    _A				(	self	):


      '''simple docstring'''

      return len(self.sp_model	)







   def    _A				(	self	):


      '''simple docstring'''

      __lowerCamelCase    		=					{self.convert_ids_to_tokens(__UpperCamelCase	): i for i in range(self.vocab_size	)}
      vocab.update(self.added_tokens_encoder	)
      return vocab







   def __getstate__(	self	):


      '''simple docstring'''

      __lowerCamelCase    		=					self.__dict__.copy()
      __lowerCamelCase    		=					None
      return state







   def __setstate__(	self ,				_SCREAMING_SNAKE_CASE	):


      '''simple docstring'''

      __lowerCamelCase    		=					d

      # for backward compatibility
      if not hasattr(self ,				'sp_model_kwargs'	):
         __lowerCamelCase    		=					{}

      __lowerCamelCase    		=					spm.SentencePieceProcessor(**self.sp_model_kwargs	)
      self.sp_model.Load(self.vocab_file	)







   def    _A				(	self ,				_SCREAMING_SNAKE_CASE	):


      '''simple docstring'''

      if self.remove_space:
         __lowerCamelCase    		=					' '.join(inputs.strip().split()	)
      else:
         __lowerCamelCase    		=					inputs
      __lowerCamelCase    		=					outputs.replace('``' ,				'"'	).replace('\'\'' ,				'"'	)

      if not self.keep_accents:
         __lowerCamelCase    		=					unicodedata.normalize('NFKD' ,				__UpperCamelCase	)
         __lowerCamelCase    		=					''.join([c for c in outputs if not unicodedata.combining(__UpperCamelCase	)]	)
      if self.do_lower_case:
         __lowerCamelCase    		=					outputs.lower()

      return outputs







   def    _A				(	self ,				_SCREAMING_SNAKE_CASE	):


      '''simple docstring'''

      __lowerCamelCase    		=					self.preprocess_text(__UpperCamelCase	)
      __lowerCamelCase    		=					self.sp_model.encode(__UpperCamelCase ,				out_type=__UpperCamelCase	)
      __lowerCamelCase    		=					[]
      for piece in pieces:
         if len(__UpperCamelCase	) > 1 and piece[-1] == str(','	) and piece[-2].isdigit():
            __lowerCamelCase    		=					self.sp_model.EncodeAsPieces(piece[:-1].replace(__UpperCamelCase ,				''	)	)
            if piece[0] != SPIECE_UNDERLINE and cur_pieces[0][0] == SPIECE_UNDERLINE:
               if len(cur_pieces[0]	) == 1:
                  __lowerCamelCase    		=					cur_pieces[1:]
               else:
                  __lowerCamelCase    		=					cur_pieces[0][1:]
            cur_pieces.append(piece[-1]	)
            new_pieces.extend(__UpperCamelCase	)
         else:
            new_pieces.append(__UpperCamelCase	)

      return new_pieces







   def    _A				(	self ,				_SCREAMING_SNAKE_CASE	):


      '''simple docstring'''

      return self.sp_model.PieceToId(__UpperCamelCase	)







   def    _A				(	self ,				_SCREAMING_SNAKE_CASE	):


      '''simple docstring'''

      return self.sp_model.IdToPiece(__UpperCamelCase	)







   def    _A				(	self ,				_SCREAMING_SNAKE_CASE	):


      '''simple docstring'''

      __lowerCamelCase    		=					[]
      __lowerCamelCase    		=					''
      __lowerCamelCase    		=					False
      for token in tokens:
         # make sure that special tokens are not decoded using sentencepiece model
         if token in self.all_special_tokens:
            if not prev_is_special:
               out_string += " "
            out_string += self.sp_model.decode(__UpperCamelCase	) + token
            __lowerCamelCase    		=					True
            __lowerCamelCase    		=					[]
         else:
            current_sub_tokens.append(__UpperCamelCase	)
            __lowerCamelCase    		=					False
      out_string += self.sp_model.decode(__UpperCamelCase	)
      return out_string.strip()







   def    _A				(	self ,				_SCREAMING_SNAKE_CASE ,				_SCREAMING_SNAKE_CASE = False ,				_SCREAMING_SNAKE_CASE = None ,				_SCREAMING_SNAKE_CASE = True ,				**_SCREAMING_SNAKE_CASE ,				):


      '''simple docstring'''

      __lowerCamelCase    		=					kwargs.pop('use_source_tokenizer' ,				__UpperCamelCase	)

      __lowerCamelCase    		=					self.convert_ids_to_tokens(__UpperCamelCase ,				skip_special_tokens=__UpperCamelCase	)

      # To avoid mixing byte-level and unicode for byte-level BPT
      # we need to build string separately for added tokens and byte-level tokens
      # cf. https://github.com/huggingface/transformers/issues/1133
      __lowerCamelCase    		=					[]
      __lowerCamelCase    		=					[]
      for token in filtered_tokens:
         if skip_special_tokens and token in self.all_special_ids:
            continue
         if token in self.added_tokens_encoder:
            if current_sub_text:
               sub_texts.append(self.convert_tokens_to_string(__UpperCamelCase	)	)
               __lowerCamelCase    		=					[]
            sub_texts.append(__UpperCamelCase	)
         else:
            current_sub_text.append(__UpperCamelCase	)
      if current_sub_text:
         sub_texts.append(self.convert_tokens_to_string(__UpperCamelCase	)	)

      # Mimic the behavior of the Rust tokenizer:
      # No space after <unk>
      if spaces_between_special_tokens:
         __lowerCamelCase    		=					re.sub(r'(<unk>) ' ,				r'\1' ,				' '.join(__UpperCamelCase	)	)
      else:
         __lowerCamelCase    		=					''.join(__UpperCamelCase	)

      __lowerCamelCase    		=					(
          clean_up_tokenization_spaces
          if clean_up_tokenization_spaces is not None
          else self.clean_up_tokenization_spaces
      )
      if clean_up_tokenization_spaces:
         __lowerCamelCase    		=					self.clean_up_tokenization(__UpperCamelCase	)
         return clean_text
      else:
         return text







   def    _A				(	self ,				_SCREAMING_SNAKE_CASE ,				_SCREAMING_SNAKE_CASE = None	):


      '''simple docstring'''

      __lowerCamelCase    		=					[self.sep_token_id]
      __lowerCamelCase    		=					[self.cls_token_id]
      if token_ids_a is None:
         return cls + token_ids_a + sep
      return cls + token_ids_a + sep + token_ids_a + sep







   def    _A				(	self ,				_SCREAMING_SNAKE_CASE ,				_SCREAMING_SNAKE_CASE = None ,				_SCREAMING_SNAKE_CASE = False	):


      '''simple docstring'''

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

      if token_ids_a is not None:
         return [1] + ([0] * len(__UpperCamelCase	)) + [1] + ([0] * len(__UpperCamelCase	)) + [1]
      return [1] + ([0] * len(__UpperCamelCase	)) + [1]







   def    _A				(	self ,				_SCREAMING_SNAKE_CASE ,				_SCREAMING_SNAKE_CASE = None	):


      '''simple docstring'''

      __lowerCamelCase    		=					[self.sep_token_id]
      __lowerCamelCase    		=					[self.cls_token_id]

      if token_ids_a is None:
         return len(cls + token_ids_a + sep	) * [0]
      return len(cls + token_ids_a + sep	) * [0] + len(token_ids_a + sep	) * [1]







   def    _A				(	self ,				_SCREAMING_SNAKE_CASE ,				_SCREAMING_SNAKE_CASE = None	):


      '''simple docstring'''

      if not os.path.isdir(__UpperCamelCase	):
         logger.error(F'''Vocabulary path ({save_directory}) should be a directory'''	)
         return
      __lowerCamelCase    		=					os.path.join(
          __UpperCamelCase ,				(filename_prefix + '-' if filename_prefix else '') + VOCAB_FILES_NAMES['vocab_file']	)

      if os.path.abspath(self.vocab_file	) != os.path.abspath(__UpperCamelCase	) and os.path.isfile(self.vocab_file	):
         copyfile(self.vocab_file ,				__UpperCamelCase	)
      elif not os.path.isfile(self.vocab_file	):
         with open(__UpperCamelCase ,				'wb'	) as fi:
            __lowerCamelCase    		=					self.sp_model.serialized_model_proto()
            fi.write(__UpperCamelCase	)

      return (out_vocab_file,)







import os
import unittest

from transformers import RealmTokenizerFast
from transformers.models.bert.tokenization_bert import (
    VOCAB_FILES_NAMES,
    BasicTokenizer,
    WordpieceTokenizer,
    _is_control,
    _is_punctuation,
    _is_whitespace,
)
from transformers.models.realm.tokenization_realm import RealmTokenizer
from transformers.testing_utils import require_tokenizers, slow

from ...test_tokenization_common import TokenizerTesterMixin, filter_non_english





@require_tokenizers
class 					__snake_case    (     _lowerCamelCase       ,unittest.TestCase      ):
					__lowerCamelCase			   =  RealmTokenizer
					__lowerCamelCase			   =  RealmTokenizerFast
					__lowerCamelCase			   =  True
					__lowerCamelCase			   =  True
					__lowerCamelCase			   =  filter_non_english




					def      __a     (  self						)	->    Optional[Any]:



									'''simple docstring'''







									super().setUp()

									snake_case__   :      Any   				= [
									    '[UNK]',
									    '[CLS]',
									    '[SEP]',
									    '[PAD]',
									    '[MASK]',
									    'want',
									    '##want',
									    '##ed',
									    'wa',
									    'un',
									    'runn',
									    '##ing',
									    ',',
									    'low',
									    'lowest',
									]
									snake_case__   :      int   				= os.path.join(self.tmpdirname       ,			VOCAB_FILES_NAMES['vocab_file']						)
									with open(self.vocab_file       ,			'w'       ,			encoding='utf-8'						) as vocab_writer:
													vocab_writer.write(''.join([x + '\n' for x in vocab_tokens]						)						)




					def      __a     (  self       ,			__UpperCamelCase						)	->    Optional[Any]:



									'''simple docstring'''







									snake_case__   :      Optional[int]   				= 'UNwant\u00E9d,running'
									snake_case__   :      Optional[Any]   				= 'unwanted, running'
									return input_text, output_text




					def      __a     (  self						)	->    Union[str, Any]:



									'''simple docstring'''







									snake_case__   :      Optional[Any]   				= self.tokenizer_class(self.vocab_file						)

									snake_case__   :      Any   				= tokenizer.tokenize('UNwant\u00E9d,running'						)
									self.assertListEqual(__UpperCamelCase       ,			['un', '##want', '##ed', ',', 'runn', '##ing']						)
									self.assertListEqual(tokenizer.convert_tokens_to_ids(__UpperCamelCase						)       ,			[9, 6, 7, 12, 10, 11]						)




					def      __a     (  self						)	->    Union[str, Any]:



									'''simple docstring'''







									if not self.test_rust_tokenizer:
													return

									snake_case__   :      Any   				= self.get_tokenizer()
									snake_case__   :      Tuple   				= self.get_rust_tokenizer()

									snake_case__   :      Tuple   				= 'UNwant\u00E9d,running'

									snake_case__   :      Optional[int]   				= tokenizer.tokenize(__UpperCamelCase						)
									snake_case__   :      Dict   				= rust_tokenizer.tokenize(__UpperCamelCase						)
									self.assertListEqual(__UpperCamelCase       ,			__UpperCamelCase						)

									snake_case__   :      Optional[int]   				= tokenizer.encode(__UpperCamelCase       ,			add_special_tokens=__UpperCamelCase						)
									snake_case__   :      int   				= rust_tokenizer.encode(__UpperCamelCase       ,			add_special_tokens=__UpperCamelCase						)
									self.assertListEqual(__UpperCamelCase       ,			__UpperCamelCase						)

									snake_case__   :      Optional[int]   				= self.get_rust_tokenizer()
									snake_case__   :      Optional[Any]   				= tokenizer.encode(__UpperCamelCase						)
									snake_case__   :      Union[str, Any]   				= rust_tokenizer.encode(__UpperCamelCase						)
									self.assertListEqual(__UpperCamelCase       ,			__UpperCamelCase						)

									# With lower casing
									snake_case__   :      Union[str, Any]   				= self.get_tokenizer(do_lower_case=__UpperCamelCase						)
									snake_case__   :      Union[str, Any]   				= self.get_rust_tokenizer(do_lower_case=__UpperCamelCase						)

									snake_case__   :      str   				= 'UNwant\u00E9d,running'

									snake_case__   :      List[Any]   				= tokenizer.tokenize(__UpperCamelCase						)
									snake_case__   :      str   				= rust_tokenizer.tokenize(__UpperCamelCase						)
									self.assertListEqual(__UpperCamelCase       ,			__UpperCamelCase						)

									snake_case__   :      Union[str, Any]   				= tokenizer.encode(__UpperCamelCase       ,			add_special_tokens=__UpperCamelCase						)
									snake_case__   :      str   				= rust_tokenizer.encode(__UpperCamelCase       ,			add_special_tokens=__UpperCamelCase						)
									self.assertListEqual(__UpperCamelCase       ,			__UpperCamelCase						)

									snake_case__   :      Any   				= self.get_rust_tokenizer()
									snake_case__   :      int   				= tokenizer.encode(__UpperCamelCase						)
									snake_case__   :      List[str]   				= rust_tokenizer.encode(__UpperCamelCase						)
									self.assertListEqual(__UpperCamelCase       ,			__UpperCamelCase						)




					def      __a     (  self						)	->    Optional[int]:



									'''simple docstring'''







									snake_case__   :      Optional[int]   				= BasicTokenizer()

									self.assertListEqual(tokenizer.tokenize('ah\u535A\u63A8zz'						)       ,			['ah', '\u535A', '\u63A8', 'zz']						)




					def      __a     (  self						)	->    str:



									'''simple docstring'''







									snake_case__   :      Any   				= BasicTokenizer(do_lower_case=__UpperCamelCase						)

									self.assertListEqual(
									    tokenizer.tokenize(' \tHeLLo!how  \n Are yoU?  '						)       ,			['hello', '!', 'how', 'are', 'you', '?']						)
									self.assertListEqual(tokenizer.tokenize('H\u00E9llo'						)       ,			['hello']						)




					def      __a     (  self						)	->    Union[str, Any]:



									'''simple docstring'''







									snake_case__   :      Optional[Any]   				= BasicTokenizer(do_lower_case=__UpperCamelCase       ,			strip_accents=__UpperCamelCase						)

									self.assertListEqual(
									    tokenizer.tokenize(' \tHäLLo!how  \n Are yoU?  '						)       ,			['hällo', '!', 'how', 'are', 'you', '?']						)
									self.assertListEqual(tokenizer.tokenize('H\u00E9llo'						)       ,			['h\u00E9llo']						)




					def      __a     (  self						)	->    Dict:



									'''simple docstring'''







									snake_case__   :      int   				= BasicTokenizer(do_lower_case=__UpperCamelCase       ,			strip_accents=__UpperCamelCase						)

									self.assertListEqual(
									    tokenizer.tokenize(' \tHäLLo!how  \n Are yoU?  '						)       ,			['hallo', '!', 'how', 'are', 'you', '?']						)
									self.assertListEqual(tokenizer.tokenize('H\u00E9llo'						)       ,			['hello']						)




					def      __a     (  self						)	->    Dict:



									'''simple docstring'''







									snake_case__   :      Any   				= BasicTokenizer(do_lower_case=__UpperCamelCase						)

									self.assertListEqual(
									    tokenizer.tokenize(' \tHäLLo!how  \n Are yoU?  '						)       ,			['hallo', '!', 'how', 'are', 'you', '?']						)
									self.assertListEqual(tokenizer.tokenize('H\u00E9llo'						)       ,			['hello']						)




					def      __a     (  self						)	->    List[Any]:



									'''simple docstring'''







									snake_case__   :      List[str]   				= BasicTokenizer(do_lower_case=__UpperCamelCase						)

									self.assertListEqual(
									    tokenizer.tokenize(' \tHeLLo!how  \n Are yoU?  '						)       ,			['HeLLo', '!', 'how', 'Are', 'yoU', '?']						)




					def      __a     (  self						)	->    int:



									'''simple docstring'''







									snake_case__   :      Optional[Any]   				= BasicTokenizer(do_lower_case=__UpperCamelCase       ,			strip_accents=__UpperCamelCase						)

									self.assertListEqual(
									    tokenizer.tokenize(' \tHäLLo!how  \n Are yoU?  '						)       ,			['HäLLo', '!', 'how', 'Are', 'yoU', '?']						)




					def      __a     (  self						)	->    Optional[int]:



									'''simple docstring'''







									snake_case__   :      Dict   				= BasicTokenizer(do_lower_case=__UpperCamelCase       ,			strip_accents=__UpperCamelCase						)

									self.assertListEqual(
									    tokenizer.tokenize(' \tHäLLo!how  \n Are yoU?  '						)       ,			['HaLLo', '!', 'how', 'Are', 'yoU', '?']						)




					def      __a     (  self						)	->    str:



									'''simple docstring'''







									snake_case__   :      Union[str, Any]   				= BasicTokenizer(do_lower_case=__UpperCamelCase       ,			never_split=['[UNK]']						)

									self.assertListEqual(
									    tokenizer.tokenize(' \tHeLLo!how  \n Are yoU? [UNK]'						)       ,			['HeLLo', '!', 'how', 'Are', 'yoU', '?', '[UNK]']						)




					def      __a     (  self						)	->    Tuple:



									'''simple docstring'''







									snake_case__   :      List[str]   				= ['[UNK]', '[CLS]', '[SEP]', 'want', '##want', '##ed', 'wa', 'un', 'runn', '##ing']

									snake_case__   :      List[str]   				= {}
									for i, token in enumerate(__UpperCamelCase						):
													snake_case__   :      Union[str, Any]   				= i
									snake_case__   :      List[Any]   				= WordpieceTokenizer(vocab=__UpperCamelCase       ,			unk_token='[UNK]'						)

									self.assertListEqual(tokenizer.tokenize(''						)       ,			[]						)

									self.assertListEqual(tokenizer.tokenize('unwanted running'						)       ,			['un', '##want', '##ed', 'runn', '##ing']						)

									self.assertListEqual(tokenizer.tokenize('unwantedX running'						)       ,			['[UNK]', 'runn', '##ing']						)




					def      __a     (  self						)	->    int:



									'''simple docstring'''







									self.assertTrue(_is_whitespace(' '						)						)
									self.assertTrue(_is_whitespace('\t'						)						)
									self.assertTrue(_is_whitespace('\r'						)						)
									self.assertTrue(_is_whitespace('\n'						)						)
									self.assertTrue(_is_whitespace('\u00A0'						)						)

									self.assertFalse(_is_whitespace('A'						)						)
									self.assertFalse(_is_whitespace('-'						)						)




					def      __a     (  self						)	->    List[Any]:



									'''simple docstring'''







									self.assertTrue(_is_control('\u0005'						)						)

									self.assertFalse(_is_control('A'						)						)
									self.assertFalse(_is_control(' '						)						)
									self.assertFalse(_is_control('\t'						)						)
									self.assertFalse(_is_control('\r'						)						)




					def      __a     (  self						)	->    Optional[Any]:



									'''simple docstring'''







									self.assertTrue(_is_punctuation('-'						)						)
									self.assertTrue(_is_punctuation('$'						)						)
									self.assertTrue(_is_punctuation('`'						)						)
									self.assertTrue(_is_punctuation('.'						)						)

									self.assertFalse(_is_punctuation('A'						)						)
									self.assertFalse(_is_punctuation(' '						)						)




					def      __a     (  self						)	->    Optional[int]:



									'''simple docstring'''







									snake_case__   :      List[str]   				= self.get_tokenizer()

									# Example taken from the issue https://github.com/huggingface/tokenizers/issues/340
									self.assertListEqual([tokenizer.tokenize(__UpperCamelCase						) for t in ['Test', '\xad', 'test']]       ,			[['[UNK]'], [], ['[UNK]']]						)

									if self.test_rust_tokenizer:
													snake_case__   :      int   				= self.get_rust_tokenizer()
													self.assertListEqual(
													    [rust_tokenizer.tokenize(__UpperCamelCase						) for t in ['Test', '\xad', 'test']]       ,			[['[UNK]'], [], ['[UNK]']]						)




					@slow
					def      __a     (  self						)	->    Tuple:



									'''simple docstring'''







									snake_case__   :      Any   				= self.tokenizer_class.from_pretrained('bert-base-uncased'						)

									snake_case__   :      Optional[int]   				= tokenizer.encode('sequence builders'       ,			add_special_tokens=__UpperCamelCase						)
									snake_case__   :      Optional[int]   				= tokenizer.encode('multi-sequence build'       ,			add_special_tokens=__UpperCamelCase						)

									snake_case__   :      str   				= tokenizer.build_inputs_with_special_tokens(__UpperCamelCase						)
									snake_case__   :      Tuple   				= tokenizer.build_inputs_with_special_tokens(__UpperCamelCase       ,			__UpperCamelCase						)

									assert encoded_sentence == [101] + text + [102]
									assert encoded_pair == [101] + text + [102] + text_a + [102]




					def      __a     (  self						)	->    Dict:



									'''simple docstring'''







									for tokenizer, pretrained_name, kwargs in self.tokenizers_list:
													with self.subTest(F"""{tokenizer.__class__.__name__} ({pretrained_name})"""						):
																	snake_case__   :      Union[str, Any]   				= self.rust_tokenizer_class.from_pretrained(__UpperCamelCase       ,			**__UpperCamelCase						)

																	snake_case__   :      int   				= F"""A, naïve {tokenizer_r.mask_token} AllenNLP sentence."""
																	snake_case__   :      Optional[Any]   				= tokenizer_r.encode_plus(
																	    __UpperCamelCase       ,			return_attention_mask=__UpperCamelCase       ,			return_token_type_ids=__UpperCamelCase       ,			return_offsets_mapping=__UpperCamelCase       ,			add_special_tokens=__UpperCamelCase       ,			)

																	snake_case__   :      List[str]   				= tokenizer_r.do_lower_case if hasattr(__UpperCamelCase       ,			'do_lower_case'						) else False
																	snake_case__   :      Union[str, Any]   				= (
																	    [
																	        ((0, 0), tokenizer_r.cls_token),
																	        ((0, 1), 'A'),
																	        ((1, 2), ','),
																	        ((3, 5), 'na'),
																	        ((5, 6), '##ï'),
																	        ((6, 8), '##ve'),
																	        ((9, 15), tokenizer_r.mask_token),
																	        ((16, 21), 'Allen'),
																	        ((21, 23), '##NL'),
																	        ((23, 24), '##P'),
																	        ((25, 33), 'sentence'),
																	        ((33, 34), '.'),
																	        ((0, 0), tokenizer_r.sep_token),
																	    ]
																	    if not do_lower_case
																	    else [
																	        ((0, 0), tokenizer_r.cls_token),
																	        ((0, 1), 'a'),
																	        ((1, 2), ','),
																	        ((3, 8), 'naive'),
																	        ((9, 15), tokenizer_r.mask_token),
																	        ((16, 21), 'allen'),
																	        ((21, 23), '##nl'),
																	        ((23, 24), '##p'),
																	        ((25, 33), 'sentence'),
																	        ((33, 34), '.'),
																	        ((0, 0), tokenizer_r.sep_token),
																	    ]
																	)

																	self.assertEqual(
																	    [e[1] for e in expected_results]       ,			tokenizer_r.convert_ids_to_tokens(tokens['input_ids']						)						)
																	self.assertEqual([e[0] for e in expected_results]       ,			tokens['offset_mapping']						)




					@slow
					def      __a     (  self						)	->    Tuple:



									'''simple docstring'''







									for tokenizer, pretrained_name, kwargs in self.tokenizers_list:
													with self.subTest(F"""{tokenizer.__class__.__name__} ({pretrained_name})"""						):
																	snake_case__   :      Dict   				= self.rust_tokenizer_class.from_pretrained(__UpperCamelCase       ,			**__UpperCamelCase						)
																	snake_case__   :      Optional[Any]   				= self.tokenizer_class.from_pretrained(__UpperCamelCase       ,			**__UpperCamelCase						)
																	snake_case__   :      int   				= [['Hello world!', 'Nice to meet you!'], ['The cute cat.', 'The adorable dog.']]

																	snake_case__   :      Optional[int]   				= tokenizer_r.batch_encode_candidates(__UpperCamelCase       ,			max_length=10       ,			return_tensors='np'						)
																	snake_case__   :      Tuple   				= tokenizer_p.batch_encode_candidates(__UpperCamelCase       ,			max_length=10       ,			return_tensors='np'						)

																	snake_case__   :      Optional[int]   				= (2, 2, 10)

																	self.assertEqual(encoded_sentence_r['input_ids'].shape       ,			__UpperCamelCase						)
																	self.assertEqual(encoded_sentence_r['attention_mask'].shape       ,			__UpperCamelCase						)
																	self.assertEqual(encoded_sentence_r['token_type_ids'].shape       ,			__UpperCamelCase						)

																	self.assertEqual(encoded_sentence_p['input_ids'].shape       ,			__UpperCamelCase						)
																	self.assertEqual(encoded_sentence_p['attention_mask'].shape       ,			__UpperCamelCase						)
																	self.assertEqual(encoded_sentence_p['token_type_ids'].shape       ,			__UpperCamelCase						)


