




"""simple docstring"""






import os
from shutil import copyfile
from typing import List, Optional, Tuple

from tokenizers import processors

from ...tokenization_utils import AddedToken, BatchEncoding
from ...tokenization_utils_fast import PreTrainedTokenizerFast
from ...utils import is_sentencepiece_available, logging


if is_sentencepiece_available():
			from .tokenization_nllb import NllbTokenizer
else:
			lowercase__			=		None


lowercase__			=		logging.get_logger(__name__)


lowercase__			=		{"""vocab_file""": """sentencepiece.bpe.model""", """tokenizer_file""": """tokenizer.json"""}

lowercase__			=		{
    """vocab_file""": {
        """facebook/nllb-200-distilled-600M""": (
            """https://huggingface.co/facebook/nllb-200-distilled-600M/resolve/main/sentencepiece.bpe.model"""
        ),
    },
    """tokenizer_file""": {
        """facebook/nllb-200-distilled-600M""": (
            """https://huggingface.co/facebook/nllb-200-distilled-600M/resolve/main/tokenizer.json"""
        ),
    },
}

lowercase__			=		{
    """facebook/nllb-large-en-ro""": 1024,
    """facebook/nllb-200-distilled-600M""": 1024,
}

# fmt: off
lowercase__			=		["""ace_Arab""", """ace_Latn""", """acm_Arab""", """acq_Arab""", """aeb_Arab""", """afr_Latn""", """ajp_Arab""", """aka_Latn""", """amh_Ethi""", """apc_Arab""", """arb_Arab""", """ars_Arab""", """ary_Arab""", """arz_Arab""", """asm_Beng""", """ast_Latn""", """awa_Deva""", """ayr_Latn""", """azb_Arab""", """azj_Latn""", """bak_Cyrl""", """bam_Latn""", """ban_Latn""", """bel_Cyrl""", """bem_Latn""", """ben_Beng""", """bho_Deva""", """bjn_Arab""", """bjn_Latn""", """bod_Tibt""", """bos_Latn""", """bug_Latn""", """bul_Cyrl""", """cat_Latn""", """ceb_Latn""", """ces_Latn""", """cjk_Latn""", """ckb_Arab""", """crh_Latn""", """cym_Latn""", """dan_Latn""", """deu_Latn""", """dik_Latn""", """dyu_Latn""", """dzo_Tibt""", """ell_Grek""", """eng_Latn""", """epo_Latn""", """est_Latn""", """eus_Latn""", """ewe_Latn""", """fao_Latn""", """pes_Arab""", """fij_Latn""", """fin_Latn""", """fon_Latn""", """fra_Latn""", """fur_Latn""", """fuv_Latn""", """gla_Latn""", """gle_Latn""", """glg_Latn""", """grn_Latn""", """guj_Gujr""", """hat_Latn""", """hau_Latn""", """heb_Hebr""", """hin_Deva""", """hne_Deva""", """hrv_Latn""", """hun_Latn""", """hye_Armn""", """ibo_Latn""", """ilo_Latn""", """ind_Latn""", """isl_Latn""", """ita_Latn""", """jav_Latn""", """jpn_Jpan""", """kab_Latn""", """kac_Latn""", """kam_Latn""", """kan_Knda""", """kas_Arab""", """kas_Deva""", """kat_Geor""", """knc_Arab""", """knc_Latn""", """kaz_Cyrl""", """kbp_Latn""", """kea_Latn""", """khm_Khmr""", """kik_Latn""", """kin_Latn""", """kir_Cyrl""", """kmb_Latn""", """kon_Latn""", """kor_Hang""", """kmr_Latn""", """lao_Laoo""", """lvs_Latn""", """lij_Latn""", """lim_Latn""", """lin_Latn""", """lit_Latn""", """lmo_Latn""", """ltg_Latn""", """ltz_Latn""", """lua_Latn""", """lug_Latn""", """luo_Latn""", """lus_Latn""", """mag_Deva""", """mai_Deva""", """mal_Mlym""", """mar_Deva""", """min_Latn""", """mkd_Cyrl""", """plt_Latn""", """mlt_Latn""", """mni_Beng""", """khk_Cyrl""", """mos_Latn""", """mri_Latn""", """zsm_Latn""", """mya_Mymr""", """nld_Latn""", """nno_Latn""", """nob_Latn""", """npi_Deva""", """nso_Latn""", """nus_Latn""", """nya_Latn""", """oci_Latn""", """gaz_Latn""", """ory_Orya""", """pag_Latn""", """pan_Guru""", """pap_Latn""", """pol_Latn""", """por_Latn""", """prs_Arab""", """pbt_Arab""", """quy_Latn""", """ron_Latn""", """run_Latn""", """rus_Cyrl""", """sag_Latn""", """san_Deva""", """sat_Beng""", """scn_Latn""", """shn_Mymr""", """sin_Sinh""", """slk_Latn""", """slv_Latn""", """smo_Latn""", """sna_Latn""", """snd_Arab""", """som_Latn""", """sot_Latn""", """spa_Latn""", """als_Latn""", """srd_Latn""", """srp_Cyrl""", """ssw_Latn""", """sun_Latn""", """swe_Latn""", """swh_Latn""", """szl_Latn""", """tam_Taml""", """tat_Cyrl""", """tel_Telu""", """tgk_Cyrl""", """tgl_Latn""", """tha_Thai""", """tir_Ethi""", """taq_Latn""", """taq_Tfng""", """tpi_Latn""", """tsn_Latn""", """tso_Latn""", """tuk_Latn""", """tum_Latn""", """tur_Latn""", """twi_Latn""", """tzm_Tfng""", """uig_Arab""", """ukr_Cyrl""", """umb_Latn""", """urd_Arab""", """uzn_Latn""", """vec_Latn""", """vie_Latn""", """war_Latn""", """wol_Latn""", """xho_Latn""", """ydd_Hebr""", """yor_Latn""", """yue_Hant""", """zho_Hans""", """zho_Hant""", """zul_Latn"""]






class lowerCAmelCase__      (	lowercase		):






			'''simple docstring'''



			lowerCamelCase__ =     VOCAB_FILES_NAMES
			lowerCamelCase__ =     PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES
			lowerCamelCase__ =     PRETRAINED_VOCAB_FILES_MAP
			lowerCamelCase__ =     ["""input_ids""", """attention_mask"""]
			lowerCamelCase__ =     NllbTokenizer

			lowerCamelCase__ =     []
			lowerCamelCase__ =     []
			def __init__(    self    , lowercase=None    , lowercase=None    , lowercase="<s>"    , lowercase="</s>"    , lowercase="</s>"    , lowercase="<s>"    , lowercase="<unk>"    , lowercase="<pad>"    , lowercase="<mask>"    , lowercase=None    , lowercase=None    , lowercase=None    , lowercase=False    , **lowercase    , ):
							# Mask token behave like a normal word, i.e. include the space before it
							_lowerCamelCase	:     Optional[int]       =       AddedToken(lowercase    , lstrip=lowercase    , rstrip=lowercase    ) if isinstance(lowercase    , lowercase    ) else mask_token
							_lowerCamelCase	:     List[Any]       =       legacy_behaviour
							super().__init__(
							    vocab_file=lowercase    , tokenizer_file=lowercase    , bos_token=lowercase    , eos_token=lowercase    , sep_token=lowercase    , cls_token=lowercase    , unk_token=lowercase    , pad_token=lowercase    , mask_token=lowercase    , src_lang=lowercase    , tgt_lang=lowercase    , additional_special_tokens=lowercase    , legacy_behaviour=lowercase    , **lowercase    , )

							_lowerCamelCase	:     List[str]       =       vocab_file
							_lowerCamelCase	:     Any       =       False if not self.vocab_file else True

							_lowerCamelCase	:     int       =       FAIRSEQ_LANGUAGE_CODES.copy()

							if additional_special_tokens is not None:
											# Only add those special tokens if they are not already there.
											_additional_special_tokens.extend(
											    [t for t in additional_special_tokens if t not in _additional_special_tokens]    )

							self.add_special_tokens({'additional_special_tokens': _additional_special_tokens}    )
							_lowerCamelCase	:     Any       =       {
							    lang_code: self.convert_tokens_to_ids(lowercase    ) for lang_code in FAIRSEQ_LANGUAGE_CODES
							}

							_lowerCamelCase	:     Any       =       src_lang if src_lang is not None else 'eng_Latn'
							_lowerCamelCase	:     Union[str, Any]       =       self.convert_tokens_to_ids(self._src_lang    )
							_lowerCamelCase	:     Optional[Any]       =       tgt_lang
							self.set_src_lang_special_tokens(self._src_lang    )
			@property
			def    A_       (    self    ):
							return self._src_lang
			@src_lang.setter
			def    A_       (    self    , lowercase    ):
							_lowerCamelCase	:     Tuple       =       new_src_lang
							self.set_src_lang_special_tokens(self._src_lang    )
			def    A_       (    self    , lowercase    , lowercase = None    ):
							if token_ids_a is None:
											return self.prefix_tokens + token_ids_a + self.suffix_tokens
							# We don't expect to process pairs, but leave the pair logic for API consistency
							return self.prefix_tokens + token_ids_a + token_ids_a + self.suffix_tokens
			def    A_       (    self    , lowercase    , lowercase = None    ):
							_lowerCamelCase	:     Optional[Any]       =       [self.sep_token_id]
							_lowerCamelCase	:     Any       =       [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 + sep + token_ids_a + sep    ) * [0]
			def    A_       (    self    , lowercase    , lowercase    , lowercase    , lowercase    , **lowercase    ):
							if src_lang is None or tgt_lang is None:
											raise ValueError('Translation requires a `src_lang` and a `tgt_lang` for this model'    )
							_lowerCamelCase	:     Optional[Any]       =       src_lang
							_lowerCamelCase	:     str       =       self(lowercase    , add_special_tokens=lowercase    , return_tensors=lowercase    , **lowercase    )
							_lowerCamelCase	:     str       =       self.convert_tokens_to_ids(lowercase    )
							_lowerCamelCase	:     Any       =       tgt_lang_id
							return inputs
			def    A_       (    self    , lowercase    , lowercase = "eng_Latn"    , lowercase = None    , lowercase = "fra_Latn"    , **lowercase    , ):
							_lowerCamelCase	:     int       =       src_lang
							_lowerCamelCase	:     Union[str, Any]       =       tgt_lang
							return super().prepare_seqaseq_batch(lowercase    , lowercase    , **lowercase    )
			def    A_       (    self    ):
							return self.set_src_lang_special_tokens(self.src_lang    )
			def    A_       (    self    ):
							return self.set_tgt_lang_special_tokens(self.tgt_lang    )
			def    A_       (    self    , lowercase    ):
							_lowerCamelCase	:     str       =       self.convert_tokens_to_ids(lowercase    )

							if self.legacy_behaviour:
											_lowerCamelCase	:     int       =       []
											_lowerCamelCase	:     Dict       =       [self.eos_token_id, self.cur_lang_code]
							else:
											_lowerCamelCase	:     Tuple       =       [self.cur_lang_code]
											_lowerCamelCase	:     Any       =       [self.eos_token_id]

							_lowerCamelCase	:     Union[str, Any]       =       self.convert_ids_to_tokens(self.prefix_tokens    )
							_lowerCamelCase	:     Any       =       self.convert_ids_to_tokens(self.suffix_tokens    )

							_lowerCamelCase	:     int       =       processors.TemplateProcessing(
							    single=prefix_tokens_str + ['$A'] + suffix_tokens_str    , pair=prefix_tokens_str + ['$A', '$B'] + suffix_tokens_str    , special_tokens=list(zip(prefix_tokens_str + suffix_tokens_str    , self.prefix_tokens + self.suffix_tokens    )    )    , )
			def    A_       (    self    , lowercase    ):
							_lowerCamelCase	:     str       =       self.convert_tokens_to_ids(lowercase    )
							if self.legacy_behaviour:
											_lowerCamelCase	:     Optional[int]       =       []
											_lowerCamelCase	:     Tuple       =       [self.eos_token_id, self.cur_lang_code]
							else:
											_lowerCamelCase	:     Tuple       =       [self.cur_lang_code]
											_lowerCamelCase	:     List[str]       =       [self.eos_token_id]

							_lowerCamelCase	:     Any       =       self.convert_ids_to_tokens(self.prefix_tokens    )
							_lowerCamelCase	:     int       =       self.convert_ids_to_tokens(self.suffix_tokens    )

							_lowerCamelCase	:     Optional[int]       =       processors.TemplateProcessing(
							    single=prefix_tokens_str + ['$A'] + suffix_tokens_str    , pair=prefix_tokens_str + ['$A', '$B'] + suffix_tokens_str    , special_tokens=list(zip(prefix_tokens_str + suffix_tokens_str    , self.prefix_tokens + self.suffix_tokens    )    )    , )






			def    A_       (    self    , lowercase    , lowercase = None    ):
							if not self.can_save_slow_tokenizer:
											raise ValueError(
											    'Your fast tokenizer does not have the necessary information to save the vocabulary for a slow '
											    'tokenizer.'    )

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

							if os.path.abspath(self.vocab_file    ) != os.path.abspath(lowercase    ):
											copyfile(self.vocab_file    , lowercase    )

							return (out_vocab_file,)





"""simple docstring"""






import os
import unittest

from transformers import MobileBertTokenizer, MobileBertTokenizerFast
from transformers.models.bert.tokenization_bert import (
    VOCAB_FILES_NAMES,
    BasicTokenizer,
    WordpieceTokenizer,
    _is_control,
    _is_punctuation,
    _is_whitespace,
)
from transformers.testing_utils import require_tokenizers, slow

from ...test_tokenization_common import TokenizerTesterMixin, filter_non_english






@require_tokenizers
class lowerCAmelCase__      (	lowercase,      unittest.TestCase		):






			'''simple docstring'''



			lowerCamelCase__ =     MobileBertTokenizer
			lowerCamelCase__ =     MobileBertTokenizerFast
			lowerCamelCase__ =     True
			lowerCamelCase__ =     True
			lowerCamelCase__ =     filter_non_english
			lowerCamelCase__ =     """google/mobilebert-uncased"""
			def    A_       (    self    ):
							super().setUp()

							_lowerCamelCase	:     Optional[int]       =       [
							    '[UNK]',
							    '[CLS]',
							    '[SEP]',
							    '[PAD]',
							    '[MASK]',
							    'want',
							    '##want',
							    '##ed',
							    'wa',
							    'un',
							    'runn',
							    '##ing',
							    ',',
							    'low',
							    'lowest',
							]
							_lowerCamelCase	:     Union[str, Any]       =       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]    )    )

							_lowerCamelCase	:     Any       =       [
							    (tokenizer_def[0], self.pre_trained_model_path, tokenizer_def[2])  # else the 'google/' prefix is stripped
							    for tokenizer_def in self.tokenizers_list
							]
			def    A_       (    self    , lowercase    ):
							_lowerCamelCase	:     Union[str, Any]       =       'UNwant\u00E9d,running'
							_lowerCamelCase	:     List[Any]       =       'unwanted, running'
							return input_text, output_text
			def    A_       (    self    ):
							_lowerCamelCase	:     Dict       =       self.tokenizer_class(self.vocab_file    )

							_lowerCamelCase	:     Union[str, Any]       =       tokenizer.tokenize('UNwant\u00E9d,running'    )
							self.assertListEqual(lowercase    , ['un', '##want', '##ed', ',', 'runn', '##ing']    )
							self.assertListEqual(tokenizer.convert_tokens_to_ids(lowercase    )    , [9, 6, 7, 12, 10, 11]    )
			def    A_       (    self    ):
							if not self.test_rust_tokenizer:
											return

							_lowerCamelCase	:     Any       =       self.get_tokenizer()
							_lowerCamelCase	:     Any       =       self.get_rust_tokenizer()

							_lowerCamelCase	:     int       =       'UNwant\u00E9d,running'

							_lowerCamelCase	:     Union[str, Any]       =       tokenizer.tokenize(lowercase    )
							_lowerCamelCase	:     List[Any]       =       rust_tokenizer.tokenize(lowercase    )
							self.assertListEqual(lowercase    , lowercase    )

							_lowerCamelCase	:     Dict       =       tokenizer.encode(lowercase    , add_special_tokens=lowercase    )
							_lowerCamelCase	:     Dict       =       rust_tokenizer.encode(lowercase    , add_special_tokens=lowercase    )
							self.assertListEqual(lowercase    , lowercase    )

							_lowerCamelCase	:     Optional[Any]       =       self.get_rust_tokenizer()
							_lowerCamelCase	:     Optional[int]       =       tokenizer.encode(lowercase    )
							_lowerCamelCase	:     List[str]       =       rust_tokenizer.encode(lowercase    )
							self.assertListEqual(lowercase    , lowercase    )

							# With lower casing
							_lowerCamelCase	:     List[Any]       =       self.get_tokenizer(do_lower_case=lowercase    )
							_lowerCamelCase	:     int       =       self.get_rust_tokenizer(do_lower_case=lowercase    )

							_lowerCamelCase	:     Optional[Any]       =       'UNwant\u00E9d,running'

							_lowerCamelCase	:     Dict       =       tokenizer.tokenize(lowercase    )
							_lowerCamelCase	:     int       =       rust_tokenizer.tokenize(lowercase    )
							self.assertListEqual(lowercase    , lowercase    )

							_lowerCamelCase	:     Dict       =       tokenizer.encode(lowercase    , add_special_tokens=lowercase    )
							_lowerCamelCase	:     Dict       =       rust_tokenizer.encode(lowercase    , add_special_tokens=lowercase    )
							self.assertListEqual(lowercase    , lowercase    )

							_lowerCamelCase	:     Any       =       self.get_rust_tokenizer()
							_lowerCamelCase	:     Union[str, Any]       =       tokenizer.encode(lowercase    )
							_lowerCamelCase	:     Dict       =       rust_tokenizer.encode(lowercase    )
							self.assertListEqual(lowercase    , lowercase    )
			def    A_       (    self    ):
							_lowerCamelCase	:     Dict       =       BasicTokenizer()

							self.assertListEqual(tokenizer.tokenize('ah\u535A\u63A8zz'    )    , ['ah', '\u535A', '\u63A8', 'zz']    )
			def    A_       (    self    ):
							_lowerCamelCase	:     Optional[Any]       =       BasicTokenizer(do_lower_case=lowercase    )

							self.assertListEqual(
							    tokenizer.tokenize(' \tHeLLo!how  \n Are yoU?  '    )    , ['hello', '!', 'how', 'are', 'you', '?']    )
							self.assertListEqual(tokenizer.tokenize('H\u00E9llo'    )    , ['hello']    )
			def    A_       (    self    ):
							_lowerCamelCase	:     List[str]       =       BasicTokenizer(do_lower_case=lowercase    , strip_accents=lowercase    )

							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    ):
							_lowerCamelCase	:     List[Any]       =       BasicTokenizer(do_lower_case=lowercase    , strip_accents=lowercase    )

							self.assertListEqual(
							    tokenizer.tokenize(' \tHäLLo!how  \n Are yoU?  '    )    , ['hallo', '!', 'how', 'are', 'you', '?']    )
							self.assertListEqual(tokenizer.tokenize('H\u00E9llo'    )    , ['hello']    )
			def    A_       (    self    ):
							_lowerCamelCase	:     int       =       BasicTokenizer(do_lower_case=lowercase    )

							self.assertListEqual(
							    tokenizer.tokenize(' \tHäLLo!how  \n Are yoU?  '    )    , ['hallo', '!', 'how', 'are', 'you', '?']    )
							self.assertListEqual(tokenizer.tokenize('H\u00E9llo'    )    , ['hello']    )
			def    A_       (    self    ):
							_lowerCamelCase	:     List[str]       =       BasicTokenizer(do_lower_case=lowercase    )

							self.assertListEqual(
							    tokenizer.tokenize(' \tHeLLo!how  \n Are yoU?  '    )    , ['HeLLo', '!', 'how', 'Are', 'yoU', '?']    )
			def    A_       (    self    ):
							_lowerCamelCase	:     Union[str, Any]       =       BasicTokenizer(do_lower_case=lowercase    , strip_accents=lowercase    )

							self.assertListEqual(
							    tokenizer.tokenize(' \tHäLLo!how  \n Are yoU?  '    )    , ['HäLLo', '!', 'how', 'Are', 'yoU', '?']    )
			def    A_       (    self    ):
							_lowerCamelCase	:     Union[str, Any]       =       BasicTokenizer(do_lower_case=lowercase    , strip_accents=lowercase    )

							self.assertListEqual(
							    tokenizer.tokenize(' \tHäLLo!how  \n Are yoU?  '    )    , ['HaLLo', '!', 'how', 'Are', 'yoU', '?']    )
			def    A_       (    self    ):
							_lowerCamelCase	:     int       =       BasicTokenizer(do_lower_case=lowercase    , never_split=['[UNK]']    )

							self.assertListEqual(
							    tokenizer.tokenize(' \tHeLLo!how  \n Are yoU? [UNK]'    )    , ['HeLLo', '!', 'how', 'Are', 'yoU', '?', '[UNK]']    )
			def    A_       (    self    ):
							_lowerCamelCase	:     Union[str, Any]       =       ['[UNK]', '[CLS]', '[SEP]', 'want', '##want', '##ed', 'wa', 'un', 'runn', '##ing']

							_lowerCamelCase	:     Tuple       =       {}
							for i, token in enumerate(lowercase    ):
											_lowerCamelCase	:     Union[str, Any]       =       i
							_lowerCamelCase	:     str       =       WordpieceTokenizer(vocab=lowercase    , 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    ):
							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    ):
							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    ):
							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    ):
							_lowerCamelCase	:     List[Any]       =       self.get_tokenizer()
							_lowerCamelCase	:     Union[str, Any]       =       self.get_rust_tokenizer()

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

							self.assertListEqual(
							    [rust_tokenizer.tokenize(lowercase    ) for t in ['Test', '\xad', 'test']]    , [['[UNK]'], [], ['[UNK]']]    )
			@slow
			def    A_       (    self    ):
							_lowerCamelCase	:     Optional[Any]       =       self.tokenizer_class.from_pretrained('google/mobilebert-uncased'    )

							_lowerCamelCase	:     List[str]       =       tokenizer.encode('sequence builders'    , add_special_tokens=lowercase    )
							_lowerCamelCase	:     Dict       =       tokenizer.encode('multi-sequence build'    , add_special_tokens=lowercase    )

							_lowerCamelCase	:     Optional[int]       =       tokenizer.build_inputs_with_special_tokens(lowercase    )
							_lowerCamelCase	:     List[Any]       =       tokenizer.build_inputs_with_special_tokens(lowercase    , lowercase    )

							assert encoded_sentence == [101] + text + [102]
							assert encoded_pair == [101] + text + [102] + text_a + [102]
			def    A_       (    self    ):
							for tokenizer, pretrained_name, kwargs in self.tokenizers_list:
											with self.subTest(F'''{tokenizer.__class__.__name__} ({pretrained_name})'''    ):
															_lowerCamelCase	:     int       =       self.rust_tokenizer_class.from_pretrained(lowercase    , **lowercase    )

															_lowerCamelCase	:     int       =       F'''A, naïve {tokenizer_r.mask_token} AllenNLP sentence.'''
															_lowerCamelCase	:     int       =       tokenizer_r.encode_plus(
															    lowercase    , return_attention_mask=lowercase    , return_token_type_ids=lowercase    , return_offsets_mapping=lowercase    , add_special_tokens=lowercase    , )

															_lowerCamelCase	:     Tuple       =       tokenizer_r.do_lower_case if hasattr(lowercase    , 'do_lower_case'    ) else False
															_lowerCamelCase	:     Dict       =       (
															    [
															        ((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']    )






			def    A_       (    self    ):
							_lowerCamelCase	:     Tuple       =       ['的', '人', '有']
							_lowerCamelCase	:     Optional[Any]       =       ''.join(lowercase    )
							for tokenizer, pretrained_name, kwargs in self.tokenizers_list:
											with self.subTest(F'''{tokenizer.__class__.__name__} ({pretrained_name})'''    ):
															_lowerCamelCase	:     int       =       True
															_lowerCamelCase	:     Any       =       self.tokenizer_class.from_pretrained(lowercase    , **lowercase    )
															_lowerCamelCase	:     Dict       =       self.rust_tokenizer_class.from_pretrained(lowercase    , **lowercase    )

															_lowerCamelCase	:     List[str]       =       tokenizer_p.encode(lowercase    , add_special_tokens=lowercase    )
															_lowerCamelCase	:     List[Any]       =       tokenizer_r.encode(lowercase    , add_special_tokens=lowercase    )

															_lowerCamelCase	:     Any       =       tokenizer_r.convert_ids_to_tokens(lowercase    )
															_lowerCamelCase	:     Dict       =       tokenizer_p.convert_ids_to_tokens(lowercase    )

															# it is expected that each Chinese character is not preceded by "##"
															self.assertListEqual(lowercase    , lowercase    )
															self.assertListEqual(lowercase    , lowercase    )

															_lowerCamelCase	:     Optional[Any]       =       False
															_lowerCamelCase	:     Dict       =       self.rust_tokenizer_class.from_pretrained(lowercase    , **lowercase    )
															_lowerCamelCase	:     Optional[int]       =       self.tokenizer_class.from_pretrained(lowercase    , **lowercase    )

															_lowerCamelCase	:     Optional[Any]       =       tokenizer_r.encode(lowercase    , add_special_tokens=lowercase    )
															_lowerCamelCase	:     str       =       tokenizer_p.encode(lowercase    , add_special_tokens=lowercase    )

															_lowerCamelCase	:     List[Any]       =       tokenizer_r.convert_ids_to_tokens(lowercase    )
															_lowerCamelCase	:     Dict       =       tokenizer_p.convert_ids_to_tokens(lowercase    )

															# it is expected that only the first Chinese character is not preceded by "##".
															_lowerCamelCase	:     List[str]       =       [
															    F'''##{token}''' if idx != 0 else token for idx, token in enumerate(lowercase    )
															]
															self.assertListEqual(lowercase    , lowercase    )
															self.assertListEqual(lowercase    , lowercase    )