





import argparse
import json
import os

import fairseq
import torch
from fairseq.data import Dictionary

from transformers import (
    WavaVecaConfig,
    WavaVecaCTCTokenizer,
    WavaVecaFeatureExtractor,
    WavaVecaForCTC,
    WavaVecaForPreTraining,
    WavaVecaProcessor,
    logging,
)
from transformers.models.wavaveca.modeling_wavaveca import WavaVecaForSequenceClassification


logging.set_verbosity_info()
A__:    Any  	=	logging.get_logger(__name__)

A__:    Any  	=	{
    '''post_extract_proj''': '''feature_projection.projection''',
    '''encoder.pos_conv.0''': '''encoder.pos_conv_embed.conv''',
    '''self_attn.k_proj''': '''encoder.layers.*.attention.k_proj''',
    '''self_attn.v_proj''': '''encoder.layers.*.attention.v_proj''',
    '''self_attn.q_proj''': '''encoder.layers.*.attention.q_proj''',
    '''self_attn.out_proj''': '''encoder.layers.*.attention.out_proj''',
    '''self_attn_layer_norm''': '''encoder.layers.*.layer_norm''',
    '''fc1''': '''encoder.layers.*.feed_forward.intermediate_dense''',
    '''fc2''': '''encoder.layers.*.feed_forward.output_dense''',
    '''final_layer_norm''': '''encoder.layers.*.final_layer_norm''',
    '''encoder.layer_norm''': '''encoder.layer_norm''',
    '''adapter_layer''': '''encoder.layers.*.adapter_layer''',
    '''w2v_model.layer_norm''': '''feature_projection.layer_norm''',
    '''quantizer.weight_proj''': '''quantizer.weight_proj''',
    '''quantizer.vars''': '''quantizer.codevectors''',
    '''project_q''': '''project_q''',
    '''final_proj''': '''project_hid''',
    '''w2v_encoder.proj''': '''lm_head''',
    '''mask_emb''': '''masked_spec_embed''',
    '''pooling_layer.linear''': '''projector''',
    '''pooling_layer.projection''': '''classifier''',
}
A__:    List[Any]  	=	[
    '''lm_head''',
    '''quantizer.weight_proj''',
    '''quantizer.codevectors''',
    '''project_q''',
    '''project_hid''',
    '''projector''',
    '''classifier''',
]



def 				lowerCAmelCase_ (							A_):
    UpperCamelCase__:	Optional[int]					=     {}
    with open(__A    ,"r") as file:
        for line_number, line in enumerate(__A):
            UpperCamelCase__:	List[Any]					=     line.strip()
            if line:
                UpperCamelCase__:	int					=     line.split()
                UpperCamelCase__:	int					=     line_number
                UpperCamelCase__:	str					=     words[0]
                UpperCamelCase__:	Dict					=     value
    return result



def 				lowerCAmelCase_ (							A_    ,A_    ,A_    ,A_    ,A_):




    for attribute in key.split("."):
        UpperCamelCase__:	Optional[Any]					=     getattr(__A    ,__A)

    UpperCamelCase__:	Dict					=     None
    for param_key in PARAM_MAPPING.keys():
        if full_name.endswith(__A):
            UpperCamelCase__:	Optional[int]					=     PARAM_MAPPING[full_name.split(".")[-1]]
            UpperCamelCase__:	int					=     '''param'''

    if weight_type is not None and weight_type != "param":
        UpperCamelCase__:	Union[str, Any]					=     getattr(__A    ,__A).shape
    elif weight_type is not None and weight_type == "param":
        UpperCamelCase__:	Dict					=     hf_pointer
        for attribute in hf_param_name.split("."):
            UpperCamelCase__:	Optional[int]					=     getattr(__A    ,__A)
        UpperCamelCase__:	List[str]					=     shape_pointer.shape

        # let's reduce dimension
        UpperCamelCase__:	Any					=     value[0]
    else:
        UpperCamelCase__:	int					=     hf_pointer.shape

    if hf_shape != value.shape:
        raise ValueError(
            F"Shape of hf {key + '.' + weight_type if weight_type is not None else ''} is {hf_shape}, but should be"
            F" {value.shape} for {full_name}")

    if weight_type == "weight":
        UpperCamelCase__:	int					=     value
    elif weight_type == "weight_g":
        UpperCamelCase__:	Optional[int]					=     value
    elif weight_type == "weight_v":
        UpperCamelCase__:	str					=     value
    elif weight_type == "bias":
        UpperCamelCase__:	str					=     value
    elif weight_type == "param":
        for attribute in hf_param_name.split("."):
            UpperCamelCase__:	Union[str, Any]					=     getattr(__A    ,__A)
        UpperCamelCase__:	List[Any]					=     value
    else:
        UpperCamelCase__:	List[str]					=     value

    logger.info(F"{key + '.' + weight_type if weight_type is not None else ''} was initialized from {full_name}.")



def 				lowerCAmelCase_ (							A_    ,A_    ,A_    ,A_    ,A_):
    UpperCamelCase__:	Optional[Any]					=     None
    for param_key in PARAM_MAPPING.keys():
        if full_name.endswith(__A):
            UpperCamelCase__:	Tuple					=     PARAM_MAPPING[full_name.split(".")[-1]]
            UpperCamelCase__:	List[str]					=     '''param'''

    if weight_type is not None and weight_type != "param":
        UpperCamelCase__:	List[str]					=     '''.'''.join([key, weight_type])
    elif weight_type is not None and weight_type == "param":
        UpperCamelCase__:	List[Any]					=     '''.'''.join([key, hf_param_name])
    else:
        UpperCamelCase__:	List[Any]					=     key

    UpperCamelCase__:	Any					=     value if '''lm_head''' in full_key else value[0]


A__:    Union[str, Any]  	=	{
    '''W_a''': '''linear_1.weight''',
    '''W_b''': '''linear_2.weight''',
    '''b_a''': '''linear_1.bias''',
    '''b_b''': '''linear_2.bias''',
    '''ln_W''': '''norm.weight''',
    '''ln_b''': '''norm.bias''',
}



def 				lowerCAmelCase_ (							A_    ,A_    ,A_=None    ,A_=None):
    UpperCamelCase__:	Any					=     False
    for key, mapped_key in MAPPING.items():
        UpperCamelCase__:	Union[str, Any]					=     '''wav2vec2.''' + mapped_key if mapped_key not in TOP_LEVEL_KEYS else mapped_key
        if key in name or key.split("w2v_model.")[-1] == name.split(".")[0]:
            UpperCamelCase__:	Dict					=     True
            if "*" in mapped_key:
                UpperCamelCase__:	Union[str, Any]					=     name.split(__A)[0].split(".")[-2]
                UpperCamelCase__:	Union[str, Any]					=     mapped_key.replace("*"    ,__A)
            if "weight_g" in name:
                UpperCamelCase__:	Optional[int]					=     '''weight_g'''
            elif "weight_v" in name:
                UpperCamelCase__:	Optional[Any]					=     '''weight_v'''
            elif "bias" in name:
                UpperCamelCase__:	Optional[int]					=     '''bias'''
            elif "weight" in name:
                # TODO: don't match quantizer.weight_proj
                UpperCamelCase__:	str					=     '''weight'''
            else:
                UpperCamelCase__:	str					=     None
            if hf_dict is not None:
                rename_dict(__A    ,__A    ,__A    ,__A    ,__A)
            else:
                set_recursively(__A    ,__A    ,__A    ,__A    ,__A)
            return is_used
    return is_used



def 				lowerCAmelCase_ (							A_    ,A_    ,A_):
    UpperCamelCase__:	Union[str, Any]					=     []
    UpperCamelCase__:	str					=     fairseq_model.state_dict()

    UpperCamelCase__:	Tuple					=     hf_model.wavaveca.feature_extractor

    for name, value in fairseq_dict.items():
        UpperCamelCase__:	List[str]					=     False
        if "conv_layers" in name:
            load_conv_layer(
                __A    ,__A    ,__A    ,__A    ,hf_model.config.feat_extract_norm == "group"    ,)
            UpperCamelCase__:	Tuple					=     True
        else:
            UpperCamelCase__:	Dict					=     load_wavaveca_layer(__A    ,__A    ,__A)
        if not is_used:
            unused_weights.append(__A)

    logger.warning(F"Unused weights: {unused_weights}")



def 				lowerCAmelCase_ (							A_    ,A_    ,A_    ,A_    ,A_):
    UpperCamelCase__:	List[str]					=     full_name.split("conv_layers.")[-1]
    UpperCamelCase__:	str					=     name.split(".")
    UpperCamelCase__:	Optional[int]					=     int(items[0])
    UpperCamelCase__:	Optional[int]					=     int(items[1])

    if type_id == 0:
        if "bias" in name:
            if value.shape != feature_extractor.conv_layers[layer_id].conv.bias.data.shape:
                raise ValueError(
                    F"{full_name} has size {value.shape}, but"
                    F" {feature_extractor.conv_layers[layer_id].conv.bias.data.shape} was found.")
            UpperCamelCase__:	List[Any]					=     value
            logger.info(F"Feat extract conv layer {layer_id} was initialized from {full_name}.")
        elif "weight" in name:
            if value.shape != feature_extractor.conv_layers[layer_id].conv.weight.data.shape:
                raise ValueError(
                    F"{full_name} has size {value.shape}, but"
                    F" {feature_extractor.conv_layers[layer_id].conv.weight.data.shape} was found.")
            UpperCamelCase__:	str					=     value
            logger.info(F"Feat extract conv layer {layer_id} was initialized from {full_name}.")
    elif (type_id == 2 and not use_group_norm) or (type_id == 2 and layer_id == 0 and use_group_norm):
        if "bias" in name:
            if value.shape != feature_extractor.conv_layers[layer_id].layer_norm.bias.data.shape:
                raise ValueError(
                    F"{full_name} has size {value.shape}, but"
                    F" {feature_extractor.conv_layers[layer_id].layer_norm.bias.data.shape} was found.")
            UpperCamelCase__:	Union[str, Any]					=     value
            logger.info(F"Feat extract layer norm weight of layer {layer_id} was initialized from {full_name}.")
        elif "weight" in name:
            if value.shape != feature_extractor.conv_layers[layer_id].layer_norm.weight.data.shape:
                raise ValueError(
                    F"{full_name} has size {value.shape}, but"
                    F" {feature_extractor.conv_layers[layer_id].layer_norm.weight.data.shape} was found.")
            UpperCamelCase__:	List[Any]					=     value
            logger.info(F"Feat extract layer norm weight of layer {layer_id} was initialized from {full_name}.")
    else:
        unused_weights.append(__A)



@torch.no_grad()
def 				lowerCAmelCase_ (							A_    ,A_    ,A_=None    ,A_=None    ,A_=True    ,A_=False):




    if config_path is not None:
        UpperCamelCase__:	Union[str, Any]					=     WavaVecaConfig.from_pretrained(__A)
    else:
        UpperCamelCase__:	Optional[Any]					=     WavaVecaConfig()

    if is_seq_class:
        UpperCamelCase__:	Optional[Any]					=     read_txt_into_dict(__A)
        UpperCamelCase__:	int					=     idalabel
        UpperCamelCase__:	Dict					=     WavaVecaForSequenceClassification(__A)
        UpperCamelCase__:	str					=     WavaVecaFeatureExtractor(
            feature_size=1    ,sampling_rate=1_60_00    ,padding_value=0    ,do_normalize=__A    ,return_attention_mask=__A    ,)
        feature_extractor.save_pretrained(__A)

    elif is_finetuned:
        if dict_path:
            UpperCamelCase__:	int					=     Dictionary.load(__A)

            # important change bos & pad token id since CTC symbol is <pad> and
            # not <s> as in fairseq
            UpperCamelCase__:	str					=     target_dict.pad_index
            UpperCamelCase__:	List[str]					=     target_dict.bos_index
            UpperCamelCase__:	int					=     target_dict.eos_index
            UpperCamelCase__:	int					=     len(target_dict.symbols)
            UpperCamelCase__:	Dict					=     os.path.join(__A    ,"vocab.json")
            if not os.path.isdir(__A):
                logger.error("--pytorch_dump_folder_path ({}) should be a directory".format(__A))
                return
            os.makedirs(__A    ,exist_ok=__A)
            UpperCamelCase__:	Dict					=     target_dict.indices

            # fairseq has the <pad> and <s> switched
            UpperCamelCase__:	int					=     0
            UpperCamelCase__:	Tuple					=     1
            with open(__A    ,"w"    ,encoding="utf-8") as vocab_handle:
                json.dump(__A    ,__A)
            UpperCamelCase__:	Any					=     WavaVecaCTCTokenizer(
                __A    ,unk_token=target_dict.unk_word    ,pad_token=target_dict.pad_word    ,bos_token=target_dict.bos_word    ,eos_token=target_dict.eos_word    ,word_delimiter_token="|"    ,do_lower_case=__A    ,)
            UpperCamelCase__:	List[str]					=     True if config.feat_extract_norm == '''layer''' else False
            UpperCamelCase__:	str					=     WavaVecaFeatureExtractor(
                feature_size=1    ,sampling_rate=1_60_00    ,padding_value=0    ,do_normalize=__A    ,return_attention_mask=__A    ,)
            UpperCamelCase__:	str					=     WavaVecaProcessor(feature_extractor=__A    ,tokenizer=__A)
            processor.save_pretrained(__A)

        UpperCamelCase__:	Optional[int]					=     WavaVecaForCTC(__A)
    else:
        UpperCamelCase__:	Tuple					=     WavaVecaForPreTraining(__A)

    if is_finetuned or is_seq_class:
        UpperCamelCase__:	Union[str, Any]					=     fairseq.checkpoint_utils.load_model_ensemble_and_task(
            [checkpoint_path]    ,arg_overrides={"data": "/".join(dict_path.split("/")[:-1])})
    else:
        UpperCamelCase__:	List[Any]					=     argparse.Namespace(task="audio_pretraining")
        UpperCamelCase__:	Any					=     fairseq.tasks.setup_task(__A)

        UpperCamelCase__:	Any					=     fairseq.checkpoint_utils.load_model_ensemble_and_task([checkpoint_path]    ,task=__A)

    UpperCamelCase__:	Any					=     model[0].eval()

    recursively_load_weights(__A    ,__A    ,not is_finetuned)

    hf_wavavec.save_pretrained(__A)


if __name__ == "__main__":
   A__:    List[str]  	=	argparse.ArgumentParser()
   parser.add_argument('''--pytorch_dump_folder_path''', default=None, type=str, help='''Path to the output PyTorch model.''')
   parser.add_argument('''--checkpoint_path''', default=None, type=str, help='''Path to fairseq checkpoint''')
   parser.add_argument('''--dict_path''', default=None, type=str, help='''Path to dict of fine-tuned model''')
   parser.add_argument('''--config_path''', default=None, type=str, help='''Path to hf config.json of model to convert''')
   parser.add_argument(
       '''--not_finetuned''', action='''store_true''', help='''Whether the model to convert is a fine-tuned model or not'''
   )
   parser.add_argument(
       '''--is_seq_class''',
       action='''store_true''',
       help='''Whether the model to convert is a fine-tuned sequence classification model or not''',
   )
   A__:    Optional[Any]  	=	parser.parse_args()

   A__:    Any  	=	not args.not_finetuned and not args.is_seq_class
   convert_wavaveca_checkpoint(
       args.checkpoint_path,
       args.pytorch_dump_folder_path,
       args.config_path,
       args.dict_path,
       is_finetuned,
       args.is_seq_class,
   )









'''simple docstring'''



import json
import os
import unittest

from transformers import BatchEncoding, MvpTokenizer, MvpTokenizerFast
from transformers.models.roberta.tokenization_roberta import VOCAB_FILES_NAMES
from transformers.testing_utils import require_tokenizers, require_torch
from transformers.utils import cached_property

from ...test_tokenization_common import TokenizerTesterMixin, filter_roberta_detectors
@require_tokenizers
class UpperCAmelCase_       (     __A					,							unittest.TestCase					):




      """simple docstring"""




      UpperCamelCase_             =      MvpTokenizer
      UpperCamelCase_             =      MvpTokenizerFast
      UpperCamelCase_             =      True
      UpperCamelCase_             =      filter_roberta_detectors






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


       '''simple docstring'''

       super().setUp()
       lowercase       : Dict						=[
           '''l''',
           '''o''',
           '''w''',
           '''e''',
           '''r''',
           '''s''',
           '''t''',
           '''i''',
           '''d''',
           '''n''',
           '''\u0120''',
           '''\u0120l''',
           '''\u0120n''',
           '''\u0120lo''',
           '''\u0120low''',
           '''er''',
           '''\u0120lowest''',
           '''\u0120newer''',
           '''\u0120wider''',
           '''<unk>''',
       ]
       lowercase       : Tuple						=dict(zip(UpperCAmelCase  ,   range(len(UpperCAmelCase		)		)		)		)
       lowercase       : Optional[Any]						=['''#version: 0.2''', '''\u0120 l''', '''\u0120l o''', '''\u0120lo w''', '''e r''', '''''']
       lowercase       : List[Any]						={'''unk_token''': '''<unk>'''}

       lowercase       : Dict						=os.path.join(self.tmpdirname  ,   VOCAB_FILES_NAMES['''vocab_file''']		)
       lowercase       : Dict						=os.path.join(self.tmpdirname  ,   VOCAB_FILES_NAMES['''merges_file''']		)
       with open(self.vocab_file  ,   '''w'''  ,   encoding='''utf-8'''		) as fp:
        fp.write(json.dumps(UpperCAmelCase		) + '''\n'''		)
       with open(self.merges_file  ,   '''w'''  ,   encoding='''utf-8'''		) as fp:
        fp.write('''\n'''.join(UpperCAmelCase		)		)






      def 					A__   (			self      :		Union[str, Any]  ,   **UpperCAmelCase      :		Dict		)	->	Tuple:


       '''simple docstring'''

       kwargs.update(self.special_tokens_map		)
       return self.tokenizer_class.from_pretrained(self.tmpdirname  ,   **UpperCAmelCase		)






      def 					A__   (			self      :		List[str]  ,   **UpperCAmelCase      :		Any		)	->	Tuple:


       '''simple docstring'''

       kwargs.update(self.special_tokens_map		)
       return self.rust_tokenizer_class.from_pretrained(self.tmpdirname  ,   **UpperCAmelCase		)






      def 					A__   (			self      :		Tuple  ,   UpperCAmelCase      :		Any		)	->	Union[str, Any]:


       '''simple docstring'''

       return "lower newer", "lower newer"






      @cached_property
      def 					A__   (			self      :		Tuple		)	->	List[Any]:


       '''simple docstring'''

       return MvpTokenizer.from_pretrained('''RUCAIBox/mvp'''		)






      @cached_property
      def 					A__   (			self      :		Any		)	->	int:


       '''simple docstring'''

       return MvpTokenizerFast.from_pretrained('''RUCAIBox/mvp'''		)






      @require_torch
      def 					A__   (			self      :		Union[str, Any]		)	->	Optional[int]:


       '''simple docstring'''

       lowercase       : Optional[int]						=['''A long paragraph for summarization.''', '''Another paragraph for summarization.''']
       lowercase       : List[str]						=[0, 250, 251, 1_7818, 13, 3_9186, 1938, 4, 2]

       for tokenizer in [self.default_tokenizer, self.default_tokenizer_fast]:
        lowercase       : Union[str, Any]						=tokenizer(UpperCAmelCase  ,   max_length=len(UpperCAmelCase		)  ,   padding=UpperCAmelCase  ,   return_tensors='''pt'''		)
        self.assertIsInstance(UpperCAmelCase  ,   UpperCAmelCase		)

        self.assertEqual((2, 9)  ,   batch.input_ids.shape		)
        self.assertEqual((2, 9)  ,   batch.attention_mask.shape		)
        lowercase       : Union[str, Any]						=batch.input_ids.tolist()[0]
        self.assertListEqual(UpperCAmelCase  ,   UpperCAmelCase		)
        # Test that special tokens are reset






      @require_torch
      def 					A__   (			self      :		Tuple		)	->	Any:


       '''simple docstring'''

       lowercase       : Any						=['''A long paragraph for summarization.''', '''Another paragraph for summarization.''']
       for tokenizer in [self.default_tokenizer, self.default_tokenizer_fast]:
        lowercase       : Dict						=tokenizer(UpperCAmelCase  ,   padding=UpperCAmelCase  ,   return_tensors='''pt'''		)
        # check if input_ids are returned and no labels
        self.assertIn('''input_ids'''  ,   UpperCAmelCase		)
        self.assertIn('''attention_mask'''  ,   UpperCAmelCase		)
        self.assertNotIn('''labels'''  ,   UpperCAmelCase		)
        self.assertNotIn('''decoder_attention_mask'''  ,   UpperCAmelCase		)






      @require_torch
      def 					A__   (			self      :		Dict		)	->	int:


       '''simple docstring'''

       lowercase       : int						=[
           '''Summary of the text.''',
           '''Another summary.''',
       ]
       for tokenizer in [self.default_tokenizer, self.default_tokenizer_fast]:
        lowercase       : Optional[Any]						=tokenizer(text_target=UpperCAmelCase  ,   max_length=32  ,   padding='''max_length'''  ,   return_tensors='''pt'''		)
        self.assertEqual(32  ,   targets['''input_ids'''].shape[1]		)






      @require_torch
      def 					A__   (			self      :		Union[str, Any]		)	->	Any:


       '''simple docstring'''

       for tokenizer in [self.default_tokenizer, self.default_tokenizer_fast]:
        lowercase       : Union[str, Any]						=tokenizer(
            ['''I am a small frog''' * 1024, '''I am a small frog''']  ,   padding=UpperCAmelCase  ,   truncation=UpperCAmelCase  ,   return_tensors='''pt'''		)
        self.assertIsInstance(UpperCAmelCase  ,   UpperCAmelCase		)
        self.assertEqual(batch.input_ids.shape  ,   (2, 1024)		)






      @require_torch
      def 					A__   (			self      :		str		)	->	List[Any]:


       '''simple docstring'''

       lowercase       : Optional[Any]						=['''A long paragraph for summarization.''']
       lowercase       : List[Any]						=[
           '''Summary of the text.''',
       ]
       for tokenizer in [self.default_tokenizer, self.default_tokenizer_fast]:
        lowercase       : List[str]						=tokenizer(UpperCAmelCase  ,   text_target=UpperCAmelCase  ,   return_tensors='''pt'''		)
        lowercase       : Optional[int]						=inputs['''input_ids''']
        lowercase       : Optional[Any]						=inputs['''labels''']
        self.assertTrue((input_ids[:, 0] == tokenizer.bos_token_id).all().item()		)
        self.assertTrue((labels[:, 0] == tokenizer.bos_token_id).all().item()		)
        self.assertTrue((input_ids[:, -1] == tokenizer.eos_token_id).all().item()		)
        self.assertTrue((labels[:, -1] == tokenizer.eos_token_id).all().item()		)






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


       '''simple docstring'''

       pass






      def 					A__   (			self      :		List[str]		)	->	Tuple:


       '''simple docstring'''

       for tokenizer, pretrained_name, kwargs in self.tokenizers_list:
        with self.subTest(f'{tokenizer.__class__.__name__} ({pretrained_name})'		):
         lowercase       : Union[str, Any]						=self.rust_tokenizer_class.from_pretrained(UpperCAmelCase  ,   **UpperCAmelCase		)
         lowercase       : Tuple						=self.tokenizer_class.from_pretrained(UpperCAmelCase  ,   **UpperCAmelCase		)
         lowercase       : Optional[Any]						='''A, <mask> AllenNLP sentence.'''
         lowercase       : int						=tokenizer_r.encode_plus(UpperCAmelCase  ,   add_special_tokens=UpperCAmelCase  ,   return_token_type_ids=UpperCAmelCase		)
         lowercase       : List[Any]						=tokenizer_p.encode_plus(UpperCAmelCase  ,   add_special_tokens=UpperCAmelCase  ,   return_token_type_ids=UpperCAmelCase		)

         # token_type_ids should put 0 everywhere
         self.assertEqual(sum(tokens_r['''token_type_ids''']		)  ,   sum(tokens_p['''token_type_ids''']		)		)

         # attention_mask should put 1 everywhere, so sum over length should be 1
         self.assertEqual(
             sum(tokens_r['''attention_mask''']		) / len(tokens_r['''attention_mask''']		)  ,   sum(tokens_p['''attention_mask''']		) / len(tokens_p['''attention_mask''']		)  ,   )

         lowercase       : Any						=tokenizer_r.convert_ids_to_tokens(tokens_r['''input_ids''']		)
         lowercase       : str						=tokenizer_p.convert_ids_to_tokens(tokens_p['''input_ids''']		)

         # Rust correctly handles the space before the mask while python doesnt
         self.assertSequenceEqual(tokens_p['''input_ids''']  ,   [0, 250, 6, 5_0264, 3823, 487, 2_1992, 3645, 4, 2]		)
         self.assertSequenceEqual(tokens_r['''input_ids''']  ,   [0, 250, 6, 5_0264, 3823, 487, 2_1992, 3645, 4, 2]		)

         self.assertSequenceEqual(
             UpperCAmelCase  ,   ['''<s>''', '''A''', ''',''', '''<mask>''', '''ĠAllen''', '''N''', '''LP''', '''Ġsentence''', '''.''', '''</s>''']		)
         self.assertSequenceEqual(
             UpperCAmelCase  ,   ['''<s>''', '''A''', ''',''', '''<mask>''', '''ĠAllen''', '''N''', '''LP''', '''Ġsentence''', '''.''', '''</s>''']		)



