



import argparse
from typing import Dict

import tensorflow as tf
import torch
from tqdm import tqdm

from transformers import BigBirdPegasusConfig, BigBirdPegasusForConditionalGeneration


A__								=						[
    # tf -> hf
    ('''/''', '''.'''),
    ('''layer_''', '''layers.'''),
    ('''kernel''', '''weight'''),
    ('''beta''', '''bias'''),
    ('''gamma''', '''weight'''),
    ('''pegasus''', '''model'''),
]
A__								=						[
    ('''.output.dense''', '''.fc2'''),
    ('''intermediate.LayerNorm''', '''final_layer_norm'''),
    ('''intermediate.dense''', '''fc1'''),
]

A__								=						(
    INIT_COMMON
    + [
        ('''attention.self.LayerNorm''', '''self_attn_layer_norm'''),
        ('''attention.output.dense''', '''self_attn.out_proj'''),
        ('''attention.self''', '''self_attn'''),
        ('''attention.encdec.LayerNorm''', '''encoder_attn_layer_norm'''),
        ('''attention.encdec_output.dense''', '''encoder_attn.out_proj'''),
        ('''attention.encdec''', '''encoder_attn'''),
        ('''key''', '''k_proj'''),
        ('''value''', '''v_proj'''),
        ('''query''', '''q_proj'''),
        ('''decoder.LayerNorm''', '''decoder.layernorm_embedding'''),
    ]
    + END_COMMON
)

A__								=						(
    INIT_COMMON
    + [
        ('''embeddings.word_embeddings''', '''shared.weight'''),
        ('''embeddings.position_embeddings''', '''embed_positions.weight'''),
        ('''attention.self.LayerNorm''', '''self_attn_layer_norm'''),
        ('''attention.output.dense''', '''self_attn.output'''),
        ('''attention.self''', '''self_attn.self'''),
        ('''encoder.LayerNorm''', '''encoder.layernorm_embedding'''),
    ]
    + END_COMMON
)

A__								=						[
    '''encdec/key/bias''',
    '''encdec/query/bias''',
    '''encdec/value/bias''',
    '''self/key/bias''',
    '''self/query/bias''',
    '''self/value/bias''',
    '''encdec_output/dense/bias''',
    '''attention/output/dense/bias''',
]



def 			_lowerCAmelCase       (					__lowerCAmelCase  ,  __lowerCAmelCase      )   ->					str:


				"""simple docstring"""

				for tf_name, hf_name in patterns:
								snake_case__	:      List[Any]     		=	k.replace(__lowerCAmelCase  ,  __lowerCAmelCase      )
				return k



def 			_lowerCAmelCase       (					__lowerCAmelCase  ,  __lowerCAmelCase      )   ->					BigBirdPegasusForConditionalGeneration:


				"""simple docstring"""

				snake_case__	:      Optional[Any]     		=	BigBirdPegasusConfig(**__lowerCAmelCase      )
				snake_case__	:      int     		=	BigBirdPegasusForConditionalGeneration(__lowerCAmelCase      )
				snake_case__	:      Any     		=	torch_model.state_dict()
				snake_case__	:      int     		=	{}

				# separating decoder weights
				snake_case__	:      Optional[int]     		=	{k: tf_weights[k] for k in tf_weights if k.startswith('''pegasus/decoder'''      )}
				snake_case__	:      List[str]     		=	{k: tf_weights[k] for k in tf_weights if not k.startswith('''pegasus/decoder'''      )}

				for k, v in tqdm(decoder_weights.items()  ,  '''tf -> hf conversion'''      ):
								snake_case__	:      Optional[Any]     		=	[k.endswith(__lowerCAmelCase      ) for ending in KEYS_TO_IGNORE]
								if any(__lowerCAmelCase      ):
												continue
								snake_case__	:      Optional[Any]     		=	DECODER_PATTERNS
								snake_case__	:      Optional[int]     		=	rename_state_dict_key(__lowerCAmelCase  ,  __lowerCAmelCase      )
								if new_k not in state_dict:
												raise ValueError(f"""could not find new key {new_k} in state dict. (converted from {k})"""      )
								if any(True if i in k else False for i in ['''dense''', '''query''', '''key''', '''value''']      ):
												snake_case__	:      Dict     		=	v.T
								snake_case__	:      Tuple     		=	torch.from_numpy(__lowerCAmelCase      )
								assert v.shape == state_dict[new_k].shape, f"""{new_k}, {k}, {v.shape}, {state_dict[new_k].shape}"""

				for k, v in tqdm(remaining_weights.items()  ,  '''tf -> hf conversion'''      ):
								snake_case__	:      Tuple     		=	[k.endswith(__lowerCAmelCase      ) for ending in KEYS_TO_IGNORE]
								if any(__lowerCAmelCase      ):
												continue
								snake_case__	:      Any     		=	REMAINING_PATTERNS
								snake_case__	:      List[str]     		=	rename_state_dict_key(__lowerCAmelCase  ,  __lowerCAmelCase      )
								if new_k not in state_dict and k != "pegasus/embeddings/position_embeddings":
												raise ValueError(f"""could not find new key {new_k} in state dict. (converted from {k})"""      )
								if any(True if i in k else False for i in ['''dense''', '''query''', '''key''', '''value''']      ):
												snake_case__	:      Dict     		=	v.T
								snake_case__	:      str     		=	torch.from_numpy(__lowerCAmelCase      )
								if k != "pegasus/embeddings/position_embeddings":
												assert v.shape == state_dict[new_k].shape, f"""{new_k}, {k}, {v.shape}, {state_dict[new_k].shape}"""

				snake_case__	:      Dict     		=	mapping['''model.embed_positions.weight''']
				snake_case__	:      Optional[int]     		=	mapping.pop('''model.embed_positions.weight'''      )
				snake_case__		, snake_case__	:      List[Any]     		=	torch_model.load_state_dict(__lowerCAmelCase  ,  strict=__lowerCAmelCase      )
				snake_case__	:      Tuple     		=	[
				    k
				    for k in missing
				    if k
				    not in [
				        '''final_logits_bias''',
				        '''model.encoder.embed_tokens.weight''',
				        '''model.decoder.embed_tokens.weight''',
				        '''lm_head.weight''',
				    ]
				]
				assert unexpected_missing == [], f"""no matches found for the following torch keys {unexpected_missing}"""
				assert extra == [], f"""no matches found for the following tf keys {extra}"""
				return torch_model



def 			_lowerCAmelCase       (					__lowerCAmelCase      )   ->					Dict:


				"""simple docstring"""

				snake_case__	:      List[Any]     		=	tf.train.list_variables(__lowerCAmelCase      )
				snake_case__	:      Any     		=	{}
				snake_case__	:      int     		=	['''global_step''']
				for name, shape in tqdm(__lowerCAmelCase  ,  desc='''converting tf checkpoint to dict'''      ):
								snake_case__	:      str     		=	any(pat in name for pat in ignore_name      )
								if skip_key:
												continue
								snake_case__	:      Optional[int]     		=	tf.train.load_variable(__lowerCAmelCase  ,  __lowerCAmelCase      )
								snake_case__	:      Dict     		=	array
				return tf_weights



def 			_lowerCAmelCase       (					__lowerCAmelCase  ,  __lowerCAmelCase  ,  __lowerCAmelCase      )   ->					Any:


				"""simple docstring"""

				snake_case__	:      Union[str, Any]     		=	get_tf_weights_as_numpy(__lowerCAmelCase      )
				snake_case__	:      List[str]     		=	convert_bigbird_pegasus(__lowerCAmelCase  ,  __lowerCAmelCase      )
				torch_model.save_pretrained(__lowerCAmelCase      )


if __name__ == "__main__":
				A__								=						argparse.ArgumentParser()
				parser.add_argument('''--tf_ckpt_path''', type=str, help='''passed to tf.train.list_variables''')
				parser.add_argument('''--save_dir''', default=None, type=str, help='''Path to the output PyTorch model.''')
				A__								=						parser.parse_args()
				A__								=						{}
				convert_bigbird_pegasus_ckpt_to_pytorch(args.tf_ckpt_path, args.save_dir, config_update=config_update)






import os
import unittest

from transformers import BertTokenizerFast
from transformers.models.bert.tokenization_bert import (
    VOCAB_FILES_NAMES,
    BasicTokenizer,
    BertTokenizer,
    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       a							(			__lowerCamelCase  ,							unittest.TestCase				):
		__lowerCAmelCase	:    int											=					BertTokenizer
		__lowerCAmelCase	:    int											=					BertTokenizerFast
		__lowerCAmelCase	:    int											=					True
		__lowerCAmelCase	:    List[Any]											=					True
		__lowerCAmelCase	:    Any											=					filter_non_english



		def 	__lowerCamelCase			(     self     :str  ):
						super().setUp()

						snake_case__	:      str     		=	[
						    '''[UNK]''',
						    '''[CLS]''',
						    '''[SEP]''',
						    '''[PAD]''',
						    '''[MASK]''',
						    '''want''',
						    '''##want''',
						    '''##ed''',
						    '''wa''',
						    '''un''',
						    '''runn''',
						    '''##ing''',
						    ''',''',
						    '''low''',
						    '''lowest''',
						]
						snake_case__	:      str     		=	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 	__lowerCamelCase			(     self     :List[str]   ,__lowercase     :str  ):
						snake_case__	:      List[Any]     		=	'''UNwant\u00E9d,running'''
						snake_case__	:      str     		=	'''unwanted, running'''
						return input_text, output_text



		def 	__lowerCamelCase			(     self     :Optional[int]  ):
						snake_case__	:      str     		=	self.tokenizer_class(self.vocab_file  )

						snake_case__	:      str     		=	tokenizer.tokenize('''UNwant\u00E9d,running'''  )
						self.assertListEqual(__lowercase   ,['''un''', '''##want''', '''##ed''', ''',''', '''runn''', '''##ing''']  )
						self.assertListEqual(tokenizer.convert_tokens_to_ids(__lowercase  )   ,[9, 6, 7, 1_2, 1_0, 1_1]  )



		def 	__lowerCamelCase			(     self     :List[str]  ):
						if not self.test_rust_tokenizer:
										return

						snake_case__	:      str     		=	self.get_tokenizer()
						snake_case__	:      Dict     		=	self.get_rust_tokenizer()

						snake_case__	:      List[Any]     		=	'''UNwant\u00E9d,running'''

						snake_case__	:      Dict     		=	tokenizer.tokenize(__lowercase  )
						snake_case__	:      int     		=	rust_tokenizer.tokenize(__lowercase  )
						self.assertListEqual(__lowercase   ,__lowercase  )

						snake_case__	:      List[str]     		=	tokenizer.encode(__lowercase   ,add_special_tokens=__lowercase  )
						snake_case__	:      List[str]     		=	rust_tokenizer.encode(__lowercase   ,add_special_tokens=__lowercase  )
						self.assertListEqual(__lowercase   ,__lowercase  )

						snake_case__	:      Optional[Any]     		=	self.get_rust_tokenizer()
						snake_case__	:      List[Any]     		=	tokenizer.encode(__lowercase  )
						snake_case__	:      Dict     		=	rust_tokenizer.encode(__lowercase  )
						self.assertListEqual(__lowercase   ,__lowercase  )

						# With lower casing
						snake_case__	:      List[Any]     		=	self.get_tokenizer(do_lower_case=__lowercase  )
						snake_case__	:      Optional[int]     		=	self.get_rust_tokenizer(do_lower_case=__lowercase  )

						snake_case__	:      int     		=	'''UNwant\u00E9d,running'''

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

						snake_case__	:      int     		=	tokenizer.encode(__lowercase   ,add_special_tokens=__lowercase  )
						snake_case__	:      List[str]     		=	rust_tokenizer.encode(__lowercase   ,add_special_tokens=__lowercase  )
						self.assertListEqual(__lowercase   ,__lowercase  )

						snake_case__	:      Tuple     		=	self.get_rust_tokenizer()
						snake_case__	:      int     		=	tokenizer.encode(__lowercase  )
						snake_case__	:      Dict     		=	rust_tokenizer.encode(__lowercase  )
						self.assertListEqual(__lowercase   ,__lowercase  )



		def 	__lowerCamelCase			(     self     :Tuple  ):
						snake_case__	:      Optional[Any]     		=	BasicTokenizer()

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



		def 	__lowerCamelCase			(     self     :Any  ):
						snake_case__	:      Dict     		=	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 	__lowerCamelCase			(     self     :List[str]  ):
						snake_case__	:      Optional[int]     		=	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 	__lowerCamelCase			(     self     :str  ):
						snake_case__	:      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''', '''?''']  )
						self.assertListEqual(tokenizer.tokenize('''H\u00E9llo'''  )   ,['''hello''']  )



		def 	__lowerCamelCase			(     self     :Optional[Any]  ):
						snake_case__	:      Union[str, Any]     		=	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 	__lowerCamelCase			(     self     :Optional[Any]  ):
						snake_case__	:      str     		=	BasicTokenizer(do_lower_case=__lowercase  )

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



		def 	__lowerCamelCase			(     self     :Tuple  ):
						snake_case__	:      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 	__lowerCamelCase			(     self     :int  ):
						snake_case__	:      str     		=	BasicTokenizer(do_lower_case=__lowercase   ,strip_accents=__lowercase  )

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



		def 	__lowerCamelCase			(     self     :Tuple  ):
						snake_case__	:      List[Any]     		=	BasicTokenizer(do_lower_case=__lowercase   ,never_split=['''[UNK]''']  )

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



		def 	__lowerCamelCase			(     self     :Dict  ):
						snake_case__	:      List[str]     		=	BasicTokenizer()
						snake_case__	:      Any     		=	'''a\n\'ll !!to?\'d of, can\'t.'''
						snake_case__	:      Optional[int]     		=	['''a''', '''\'''', '''ll''', '''!''', '''!''', '''to''', '''?''', '''\'''', '''d''', '''of''', ''',''', '''can''', '''\'''', '''t''', '''.''']
						self.assertListEqual(tokenizer.tokenize(__lowercase  )   ,__lowercase  )



		def 	__lowerCamelCase			(     self     :List[str]  ):
						snake_case__	:      Any     		=	['''[UNK]''', '''[CLS]''', '''[SEP]''', '''want''', '''##want''', '''##ed''', '''wa''', '''un''', '''runn''', '''##ing''']

						snake_case__	:      Optional[Any]     		=	{}
						for i, token in enumerate(__lowercase  ):
										snake_case__	:      Dict     		=	i
						snake_case__	:      int     		=	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 	__lowerCamelCase			(     self     :List[Any]  ):
						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 	__lowerCamelCase			(     self     :Union[str, Any]  ):
						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 	__lowerCamelCase			(     self     :str  ):
						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 	__lowerCamelCase			(     self     :List[str]  ):
						snake_case__	:      str     		=	self.get_tokenizer()
						snake_case__	:      List[str]     		=	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 	__lowerCamelCase			(     self     :List[str]  ):
						snake_case__	:      List[str]     		=	self.tokenizer_class.from_pretrained('''bert-base-uncased'''  )

						snake_case__	:      Union[str, Any]     		=	tokenizer.encode('''sequence builders'''   ,add_special_tokens=__lowercase  )
						snake_case__	:      str     		=	tokenizer.encode('''multi-sequence build'''   ,add_special_tokens=__lowercase  )

						snake_case__	:      Tuple     		=	tokenizer.build_inputs_with_special_tokens(__lowercase  )
						snake_case__	:      int     		=	tokenizer.build_inputs_with_special_tokens(__lowercase   ,__lowercase  )

						assert encoded_sentence == [1_0_1] + text + [1_0_2]
						assert encoded_pair == [1_0_1] + text + [1_0_2] + text_a + [1_0_2]



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

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

														snake_case__	:      List[str]     		=	tokenizer_r.do_lower_case if hasattr(__lowercase   ,'''do_lower_case'''  ) else False
														snake_case__	:      Optional[int]     		=	(
														    [
														        ((0, 0), tokenizer_r.cls_token),
														        ((0, 1), '''A'''),
														        ((1, 2), ''','''),
														        ((3, 5), '''na'''),
														        ((5, 6), '''##ï'''),
														        ((6, 8), '''##ve'''),
														        ((9, 1_5), tokenizer_r.mask_token),
														        ((1_6, 2_1), '''Allen'''),
														        ((2_1, 2_3), '''##NL'''),
														        ((2_3, 2_4), '''##P'''),
														        ((2_5, 3_3), '''sentence'''),
														        ((3_3, 3_4), '''.'''),
														        ((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, 1_5), tokenizer_r.mask_token),
														        ((1_6, 2_1), '''allen'''),
														        ((2_1, 2_3), '''##nl'''),
														        ((2_3, 2_4), '''##p'''),
														        ((2_5, 3_3), '''sentence'''),
														        ((3_3, 3_4), '''.'''),
														        ((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 	__lowerCamelCase			(     self     :List[str]  ):
						snake_case__	:      str     		=	['''的''', '''人''', '''有''']
						snake_case__	:      Optional[int]     		=	''''''.join(__lowercase  )
						for tokenizer, pretrained_name, kwargs in self.tokenizers_list:
										with self.subTest(F"""{tokenizer.__class__.__name__} ({pretrained_name})"""  ):
														snake_case__	:      Optional[Any]     		=	True
														snake_case__	:      int     		=	self.tokenizer_class.from_pretrained(__lowercase   ,**__lowercase  )
														snake_case__	:      Tuple     		=	self.rust_tokenizer_class.from_pretrained(__lowercase   ,**__lowercase  )

														snake_case__	:      Union[str, Any]     		=	tokenizer_p.encode(__lowercase   ,add_special_tokens=__lowercase  )
														snake_case__	:      List[str]     		=	tokenizer_r.encode(__lowercase   ,add_special_tokens=__lowercase  )

														snake_case__	:      List[str]     		=	tokenizer_r.convert_ids_to_tokens(__lowercase  )
														snake_case__	:      Optional[Any]     		=	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  )

														snake_case__	:      str     		=	False
														snake_case__	:      Dict     		=	self.rust_tokenizer_class.from_pretrained(__lowercase   ,**__lowercase  )
														snake_case__	:      int     		=	self.tokenizer_class.from_pretrained(__lowercase   ,**__lowercase  )

														snake_case__	:      int     		=	tokenizer_r.encode(__lowercase   ,add_special_tokens=__lowercase  )
														snake_case__	:      Tuple     		=	tokenizer_p.encode(__lowercase   ,add_special_tokens=__lowercase  )

														snake_case__	:      List[Any]     		=	tokenizer_r.convert_ids_to_tokens(__lowercase  )
														snake_case__	:      Union[str, Any]     		=	tokenizer_p.convert_ids_to_tokens(__lowercase  )

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

