'''simple docstring'''

import copy
import tempfile
import unittest

from transformers import MaMaaaConfig, is_torch_available
from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow, torch_device
from transformers.utils import cached_property

from ...generation.test_utils import GenerationTesterMixin
from ...test_configuration_common import ConfigTester
from ...test_modeling_common import ModelTesterMixin, ids_tensor
from ...test_pipeline_mixin import PipelineTesterMixin


if is_torch_available():
  import torch

  from transformers import MaMaaaForConditionalGeneration, MaMaaaModel, MaMaaaTokenizer
  from transformers.models.mam_aaa.modeling_mam_aaa import MaMaaaDecoder, MaMaaaEncoder
def       __UpperCamelCase	(       UpperCAmelCase		,					UpperCAmelCase		,					UpperCAmelCase		,					UpperCAmelCase=None		,					UpperCAmelCase=None		,					UpperCAmelCase=None		,					UpperCAmelCase=None		,					UpperCAmelCase=None		,					):
 if attention_mask is None:
  lowercase__    :   Union[str, Any]						= input_ids.ne(config.pad_token_id					)
 if decoder_attention_mask is None:
  lowercase__    :   Optional[Any]						= decoder_input_ids.ne(config.pad_token_id					)
 if head_mask is None:
  lowercase__    :   Tuple						= torch.ones(config.encoder_layers		,					config.encoder_attention_heads		,					device=UpperCAmelCase					)
 if decoder_head_mask is None:
  lowercase__    :   Union[str, Any]						= torch.ones(config.decoder_layers		,					config.decoder_attention_heads		,					device=UpperCAmelCase					)
 if cross_attn_head_mask is None:
  lowercase__    :   Tuple						= torch.ones(config.decoder_layers		,					config.decoder_attention_heads		,					device=UpperCAmelCase					)
 return {
     "input_ids": input_ids,
     "decoder_input_ids": decoder_input_ids,
     "attention_mask": attention_mask,
     "decoder_attention_mask": attention_mask,
     "head_mask": head_mask,
     "decoder_head_mask": decoder_head_mask,
     "cross_attn_head_mask": cross_attn_head_mask,
 }



class       UpperCAmelCase  :





       '''simple docstring'''



       def __init__(						self     ,       __lowerCAmelCase     ,       __lowerCAmelCase=13     ,       __lowerCAmelCase=7     ,       __lowerCAmelCase=True     ,       __lowerCAmelCase=False     ,       __lowerCAmelCase=99     ,       __lowerCAmelCase=16     ,       __lowerCAmelCase=2     ,       __lowerCAmelCase=4     ,       __lowerCAmelCase=4     ,       __lowerCAmelCase="relu"     ,       __lowerCAmelCase=0.1     ,       __lowerCAmelCase=0.1     ,       __lowerCAmelCase=0.0     ,       __lowerCAmelCase=0.0     ,       __lowerCAmelCase=20     ,       __lowerCAmelCase=2     ,       __lowerCAmelCase=1     ,       __lowerCAmelCase=0     ,       )  ->  Union[str, Any]:
        lowercase__    :   Tuple						= parent
        lowercase__    :   List[str]						= batch_size
        lowercase__    :   List[Any]						= seq_length
        lowercase__    :   Dict						= is_training
        lowercase__    :   Dict						= use_labels
        lowercase__    :   Dict						= vocab_size
        lowercase__    :   Optional[Any]						= hidden_size
        lowercase__    :   int						= num_hidden_layers
        lowercase__    :   Optional[Any]						= num_attention_heads
        lowercase__    :   int						= intermediate_size
        lowercase__    :   List[Any]						= hidden_act
        lowercase__    :   Dict						= hidden_dropout_prob
        lowercase__    :   Dict						= attention_probs_dropout_prob
        lowercase__    :   Optional[Any]						= encoder_layerdrop
        lowercase__    :   List[str]						= decoder_layerdrop
        lowercase__    :   Dict						= max_position_embeddings
        lowercase__    :   List[Any]						= eos_token_id
        lowercase__    :   List[str]						= pad_token_id
        lowercase__    :   int						= bos_token_id

       def _lowerCAmelCase(						self			)  ->  Any:
        lowercase__    :   int						= ids_tensor([self.batch_size, self.seq_length]     ,       self.vocab_size			)
        lowercase__    :   str						= self.eos_token_id  # Eos Token
        lowercase__    :   str						= ids_tensor([self.batch_size, self.seq_length]     ,       self.vocab_size			)

        # we need to clamp the input ids here to avoid having pad token in between
        # this is because for M2M100 the position_ids are prepared such that
        # all pad tokens have pos id = 2 and rest are between 2..seq_length
        # and the seq_length here is seq_length - num_pad_tokens
        # but when using past, there is no way of knowing if the past input ids had
        # pad tokens in them, which results in incorrect seq_lenth and which in turn results in
        # position_ids being off by num_pad_tokens in past input
        lowercase__    :   List[Any]						= input_ids.clamp(self.pad_token_id + 1			)
        lowercase__    :   Dict						= decoder_input_ids.clamp(self.pad_token_id + 1			)

        lowercase__    :   Dict						= self.get_config()
        lowercase__    :   int						= prepare_mam_aaa_inputs_dict(__lowerCAmelCase     ,       __lowerCAmelCase     ,       __lowerCAmelCase			)
        return config, inputs_dict

       def _lowerCAmelCase(						self			)  ->  List[str]:
        return MaMaaaConfig(
            vocab_size=self.vocab_size     ,       d_model=self.hidden_size     ,       encoder_layers=self.num_hidden_layers     ,       decoder_layers=self.num_hidden_layers     ,       encoder_attention_heads=self.num_attention_heads     ,       decoder_attention_heads=self.num_attention_heads     ,       encoder_ffn_dim=self.intermediate_size     ,       decoder_ffn_dim=self.intermediate_size     ,       dropout=self.hidden_dropout_prob     ,       attention_dropout=self.attention_probs_dropout_prob     ,       encoder_layerdrop=self.encoder_layerdrop     ,       decoder_layerdrop=self.decoder_layerdrop     ,       max_position_embeddings=self.max_position_embeddings     ,       eos_token_id=self.eos_token_id     ,       bos_token_id=self.bos_token_id     ,       pad_token_id=self.pad_token_id     ,       )

       def _lowerCAmelCase(						self			)  ->  str:
        lowercase__			,							lowercase__    :   List[Any]						= self.prepare_config_and_inputs()
        return config, inputs_dict

       def _lowerCAmelCase(						self     ,       __lowerCAmelCase     ,       __lowerCAmelCase			)  ->  Optional[Any]:
        lowercase__    :   Optional[int]						= MaMaaaModel(config=__lowerCAmelCase			).get_decoder().to(__lowerCAmelCase			).eval()
        lowercase__    :   str						= inputs_dict['''input_ids''']
        lowercase__    :   Optional[int]						= inputs_dict['''attention_mask''']
        lowercase__    :   Tuple						= inputs_dict['''head_mask''']

        # first forward pass
        lowercase__    :   Dict						= model(__lowerCAmelCase     ,       attention_mask=__lowerCAmelCase     ,       head_mask=__lowerCAmelCase     ,       use_cache=__lowerCAmelCase			)

        lowercase__			,							lowercase__    :   Union[str, Any]						= outputs.to_tuple()

        # create hypothetical multiple next token and extent to next_input_ids
        lowercase__    :   Dict						= ids_tensor((self.batch_size, 3)     ,       config.vocab_size			)
        lowercase__    :   Optional[Any]						= ids_tensor((self.batch_size, 3)     ,       2			)

        # append to next input_ids and
        lowercase__    :   Any						= torch.cat([input_ids, next_tokens]     ,       dim=-1			)
        lowercase__    :   int						= torch.cat([attention_mask, next_attn_mask]     ,       dim=-1			)

        lowercase__    :   List[Any]						= model(__lowerCAmelCase     ,       attention_mask=__lowerCAmelCase			)['''last_hidden_state''']
        lowercase__    :   List[Any]						= model(__lowerCAmelCase     ,       attention_mask=__lowerCAmelCase     ,       past_key_values=__lowerCAmelCase			)[
            '''last_hidden_state'''
        ]

        # select random slice
        lowercase__    :   Union[str, Any]						= ids_tensor((1,)     ,       output_from_past.shape[-1]			).item()
        lowercase__    :   Optional[int]						= output_from_no_past[:, -3:, random_slice_idx].detach()
        lowercase__    :   Union[str, Any]						= output_from_past[:, :, random_slice_idx].detach()

        self.parent.assertTrue(output_from_past_slice.shape[1] == next_tokens.shape[1]			)

        # test that outputs are equal for slice
        self.parent.assertTrue(torch.allclose(__lowerCAmelCase     ,       __lowerCAmelCase     ,       atol=1E-2			)			)


       def _lowerCAmelCase(						self     ,       __lowerCAmelCase     ,       __lowerCAmelCase			)  ->  Tuple:
        lowercase__    :   Optional[int]						= MaMaaaModel(config=__lowerCAmelCase			).to(__lowerCAmelCase			).eval()
        lowercase__    :   List[Any]						= model(**__lowerCAmelCase			)

        lowercase__    :   str						= outputs.encoder_last_hidden_state
        lowercase__    :   List[str]						= outputs.last_hidden_state

        with tempfile.TemporaryDirectory() as tmpdirname:
         lowercase__    :   Dict						= model.get_encoder()
         encoder.save_pretrained(__lowerCAmelCase			)
         lowercase__    :   Tuple						= MaMaaaEncoder.from_pretrained(__lowerCAmelCase			).to(__lowerCAmelCase			)

        lowercase__    :   Optional[Any]						= encoder(inputs_dict['''input_ids''']     ,       attention_mask=inputs_dict['''attention_mask''']			)[
            0
        ]

        self.parent.assertTrue((encoder_last_hidden_state_a - encoder_last_hidden_state).abs().max().item() < 1E-3			)

        with tempfile.TemporaryDirectory() as tmpdirname:
         lowercase__    :   Dict						= model.get_decoder()
         decoder.save_pretrained(__lowerCAmelCase			)
         lowercase__    :   List[Any]						= MaMaaaDecoder.from_pretrained(__lowerCAmelCase			).to(__lowerCAmelCase			)

        lowercase__    :   int						= decoder(
            input_ids=inputs_dict['''decoder_input_ids''']     ,       attention_mask=inputs_dict['''decoder_attention_mask''']     ,       encoder_hidden_states=__lowerCAmelCase     ,       encoder_attention_mask=inputs_dict['''attention_mask''']     ,       )[0]

        self.parent.assertTrue((last_hidden_state_a - last_hidden_state).abs().max().item() < 1E-3			)



@require_torch
class       UpperCAmelCase  (						a__   ,						a__   ,						a__   ,						unittest.TestCase ):





       '''simple docstring'''



       SCREAMING_SNAKE_CASE 		=   (
           (
               MaMaaaModel,
               MaMaaaForConditionalGeneration,
           )
           if is_torch_available()
           else ()
       )
       SCREAMING_SNAKE_CASE 		=   (MaMaaaForConditionalGeneration,) if is_torch_available() else ()
       SCREAMING_SNAKE_CASE 		=   (
           {
               "conversational": MaMaaaForConditionalGeneration,
               "feature-extraction": MaMaaaModel,
               "summarization": MaMaaaForConditionalGeneration,
               "text2text-generation": MaMaaaForConditionalGeneration,
               "translation": MaMaaaForConditionalGeneration,
           }
           if is_torch_available()
           else {}
       )
       SCREAMING_SNAKE_CASE 		=   True
       SCREAMING_SNAKE_CASE 		=   True
       SCREAMING_SNAKE_CASE 		=   False
       SCREAMING_SNAKE_CASE 		=   False

       def _lowerCAmelCase(						self     ,       __lowerCAmelCase     ,       __lowerCAmelCase     ,       __lowerCAmelCase     ,       __lowerCAmelCase     ,       __lowerCAmelCase			)  ->  List[str]:
        if pipeline_test_casse_name == "TranslationPipelineTests":
         # Get `ValueError: Translation requires a `src_lang` and a `tgt_lang` for this model`.
         # `M2M100Config` was never used in pipeline tests: cannot create a simple tokenizer.
         return True

        return False

       def _lowerCAmelCase(						self			)  ->  Union[str, Any]:
        lowercase__    :   Tuple						= MaMaaaModelTester(self			)
        lowercase__    :   int						= ConfigTester(self     ,       config_class=__lowerCAmelCase			)

       def _lowerCAmelCase(						self			)  ->  List[Any]:
        self.config_tester.run_common_tests()

       def _lowerCAmelCase(						self			)  ->  Dict:
        lowercase__			,							lowercase__    :   str						= self.model_tester.prepare_config_and_inputs()
        for model_class in self.all_model_classes:
         lowercase__    :   Tuple						= model_class(__lowerCAmelCase			)

         with tempfile.TemporaryDirectory() as tmpdirname:
          model.save_pretrained(__lowerCAmelCase			)
          lowercase__			,							lowercase__    :   Dict						= model_class.from_pretrained(__lowerCAmelCase     ,       output_loading_info=__lowerCAmelCase			)
         self.assertEqual(info['''missing_keys''']     ,       []			)

       def _lowerCAmelCase(						self			)  ->  str:
        lowercase__    :   Union[str, Any]						= self.model_tester.prepare_config_and_inputs()
        self.model_tester.create_and_check_decoder_model_past_large_inputs(*__lowerCAmelCase			)

       def _lowerCAmelCase(						self			)  ->  Union[str, Any]:
        lowercase__    :   Any						= self.model_tester.prepare_config_and_inputs_for_common()
        self.model_tester.check_encoder_decoder_model_standalone(*__lowerCAmelCase			)

       def _lowerCAmelCase(						self			)  ->  int:
        lowercase__			,							lowercase__    :   Dict						= self.model_tester.prepare_config_and_inputs_for_common()

        for model_class in (MaMaaaModel, MaMaaaForConditionalGeneration):
         lowercase__    :   str						= model_class(__lowerCAmelCase			)
         model.to(__lowerCAmelCase			)
         model.eval()

         lowercase__    :   Optional[int]						= copy.deepcopy(self._prepare_for_class(__lowerCAmelCase     ,       __lowerCAmelCase			)			)

         if not self.is_encoder_decoder:
          lowercase__    :   Tuple						= inputs['''input_ids''']
          del inputs["input_ids"]
         else:
          lowercase__    :   List[Any]						= inputs['''input_ids''']
          lowercase__    :   str						= inputs.get('''decoder_input_ids'''     ,       __lowerCAmelCase			)
          del inputs["input_ids"]
          inputs.pop('''decoder_input_ids'''     ,       __lowerCAmelCase			)

         lowercase__    :   Tuple						= model.get_input_embeddings()
         if not self.is_encoder_decoder:
          lowercase__    :   int						= wte(__lowerCAmelCase			)
         else:
          lowercase__    :   Tuple						= wte(__lowerCAmelCase			)
          lowercase__    :   Optional[int]						= wte(__lowerCAmelCase			)

         with torch.no_grad():
          model(**__lowerCAmelCase			)[0]


       def _lowerCAmelCase(						self			)  ->  str:
        lowercase__			,							lowercase__    :   Dict						= self.model_tester.prepare_config_and_inputs()
        lowercase__    :   Optional[int]						= input_dict['''input_ids''']
        lowercase__    :   Union[str, Any]						= input_ids.ne(1			).to(__lowerCAmelCase			)
        lowercase__    :   Optional[int]						= MaMaaaForConditionalGeneration(__lowerCAmelCase			).eval().to(__lowerCAmelCase			)
        if torch_device == "cuda":
         model.half()
        model.generate(__lowerCAmelCase     ,       attention_mask=__lowerCAmelCase			)
        model.generate(num_beams=4     ,       do_sample=__lowerCAmelCase     ,       early_stopping=__lowerCAmelCase     ,       num_return_sequences=3			)


def       __UpperCamelCase	(       UpperCAmelCase					):
 return torch.tensor(UpperCAmelCase		,					dtype=torch.long		,					device=UpperCAmelCase					)


__a:			Optional[Any]	       =       1E-4





@require_torch
@require_sentencepiece
@require_tokenizers
@slow
class       UpperCAmelCase  (						unittest.TestCase ):





       '''simple docstring'''



       @cached_property
       def _lowerCAmelCase(						self			)  ->  List[str]:
        return MaMaaaTokenizer.from_pretrained('''facebook/m2m100_418M'''			)

       def _lowerCAmelCase(						self			)  ->  Optional[int]:
        lowercase__    :   Optional[int]						= MaMaaaModel.from_pretrained('''facebook/m2m100_418M'''			).to(__lowerCAmelCase			)
        lowercase__    :   Any						= _long_tensor([[128028, 98, 12, 30527, 2732, 159, 7755, 61904, 39144, 38, 2]]			)
        lowercase__    :   Optional[int]						= _long_tensor([[2, 128028, 98, 12, 30527, 2732, 159, 7755, 61904, 39144, 38]]			)
        lowercase__    :   Dict						= prepare_mam_aaa_inputs_dict(model.config     ,       __lowerCAmelCase     ,       __lowerCAmelCase			)
        with torch.no_grad():
         lowercase__    :   List[Any]						= model(**__lowerCAmelCase			)[0]
        lowercase__    :   str						= torch.Size((1, 11, 1024)			)
        self.assertEqual(output.shape     ,       __lowerCAmelCase			)
        # change to expected output here
        lowercase__    :   Tuple						= torch.tensor(
            [[-0.7_7_8_0, -0.1_6_7_6, 0.1_0_3_8], [-6.7_5_5_6, -1.3_9_9_2, 0.0_5_6_7], [-7.5_3_8_3, -0.5_9_2_0, -0.2_7_7_9]]     ,       device=__lowerCAmelCase			)
        self.assertTrue(torch.allclose(output[:, :3, :3]     ,       __lowerCAmelCase     ,       atol=__lowerCAmelCase			)			)

       def _lowerCAmelCase(						self			)  ->  Any:
        lowercase__    :   List[str]						= MaMaaaForConditionalGeneration.from_pretrained('''facebook/m2m100_418M'''			).to(__lowerCAmelCase			)

        # change to intended input
        lowercase__    :   str						= _long_tensor([[128028, 98, 12, 30527, 2732, 159, 7755, 61904, 39144, 38, 2]]			)
        lowercase__    :   int						= _long_tensor([[2, 128028, 98, 12, 30527, 2732, 159, 7755, 61904, 39144, 38]]			)
        lowercase__    :   Dict						= prepare_mam_aaa_inputs_dict(model.config     ,       __lowerCAmelCase     ,       __lowerCAmelCase			)
        with torch.no_grad():
         lowercase__    :   Any						= model(**__lowerCAmelCase			)[0]
        lowercase__    :   Optional[Any]						= torch.Size((1, 11, model.config.vocab_size)			)
        self.assertEqual(output.shape     ,       __lowerCAmelCase			)
        # change to expected output here
        lowercase__    :   Union[str, Any]						= torch.tensor(
            [[-1.0_4_4_8, -1.0_4_1_1, 3.7_9_9_2], [-3.2_1_9_1, -3.2_3_8_6, -1.3_4_5_1], [-3.6_2_1_0, -3.5_9_9_3, 0.4_9_2_5]]     ,       device=__lowerCAmelCase			)
        self.assertTrue(torch.allclose(output[:, :3, :3]     ,       __lowerCAmelCase     ,       atol=__lowerCAmelCase			)			)


       def _lowerCAmelCase(						self			)  ->  Optional[Any]:
        lowercase__    :   Dict						= MaMaaaForConditionalGeneration.from_pretrained('''facebook/m2m100_418M'''			).to(__lowerCAmelCase			)
        lowercase__    :   List[str]						= MaMaaaTokenizer.from_pretrained('''facebook/m2m100_418M'''     ,       src_lang='''fr'''     ,       tgt_lang='''en'''			)

        lowercase__    :   int						= [
            '''L\'affaire NSA souligne l\'absence totale de débat sur le renseignement''',
            '''Selon moi, il y a deux niveaux de réponse de la part du gouvernement français.''',
            '''Lorsque François Hollande téléphone à Barack Obama ou quand le ministre des affaires étrangères Laurent'''
            ''' Fabius convoque l\'ambassadeur des Etats-Unis, ils réagissent à une vraie découverte, qui est celle de'''
            ''' l\'ampleur de la surveillance américaine sur l\'ensemble des communications en France.''',
        ]

        # The below article tests that we don't add any hypotheses outside of the top n_beams
        lowercase__    :   int						= tokenizer(__lowerCAmelCase     ,       padding=__lowerCAmelCase     ,       return_tensors='''pt'''			)

        lowercase__    :   str						= model.generate(
            input_ids=dct['''input_ids'''].to(__lowerCAmelCase			)     ,       attention_mask=dct['''attention_mask'''].to(__lowerCAmelCase			)     ,       num_beams=5     ,       forced_bos_token_id=tokenizer.get_lang_id('''en'''			)     ,       )

        lowercase__    :   Optional[int]						= [
            '''The NSA case highlights the total absence of intelligence debate''',
            '''I think there are two levels of response from the French government.''',
            '''When François Hollande calls Barack Obama or when Foreign Minister Laurent Fabius calls the U.S.'''
            ''' Ambassador, they respond to a real discovery, which is that of the scale of U.S. surveillance on all'''
            ''' communications in France.''',
        ]

        lowercase__    :   str						= tokenizer.batch_decode(
            hypotheses_batch.tolist()     ,       clean_up_tokenization_spaces=__lowerCAmelCase     ,       skip_special_tokens=__lowerCAmelCase			)
        assert generated == expected_en


'''simple docstring'''

import json
import os
import unittest

from transformers import OpenAIGPTTokenizer, OpenAIGPTTokenizerFast
from transformers.models.openai.tokenization_openai import VOCAB_FILES_NAMES
from transformers.testing_utils import require_ftfy, require_spacy, require_tokenizers

from ...test_tokenization_common import TokenizerTesterMixin



@require_tokenizers
class       UpperCAmelCase  (						a__   ,						unittest.TestCase ):





       '''simple docstring'''



       SCREAMING_SNAKE_CASE 		=   OpenAIGPTTokenizer
       SCREAMING_SNAKE_CASE 		=   OpenAIGPTTokenizerFast
       SCREAMING_SNAKE_CASE 		=   True
       SCREAMING_SNAKE_CASE 		=   False

       def _lowerCAmelCase(						self			)  ->  Optional[int]:
        super().setUp()

        # Adapted from Sennrich et al. 2015 and https://github.com/rsennrich/subword-nmt
        lowercase__    :   Optional[Any]						= [
            '''l''',
            '''o''',
            '''w''',
            '''e''',
            '''r''',
            '''s''',
            '''t''',
            '''i''',
            '''d''',
            '''n''',
            '''w</w>''',
            '''r</w>''',
            '''t</w>''',
            '''lo''',
            '''low''',
            '''er</w>''',
            '''low</w>''',
            '''lowest</w>''',
            '''newer</w>''',
            '''wider</w>''',
            '''<unk>''',
        ]
        lowercase__    :   Optional[int]						= dict(zip(__lowerCAmelCase     ,       range(len(__lowerCAmelCase			)			)			)			)
        lowercase__    :   Union[str, Any]						= ['''#version: 0.2''', '''l o''', '''lo w''', '''e r</w>''', '''''']

        lowercase__    :   Optional[int]						= os.path.join(self.tmpdirname     ,       VOCAB_FILES_NAMES['''vocab_file''']			)
        lowercase__    :   Optional[int]						= os.path.join(self.tmpdirname     ,       VOCAB_FILES_NAMES['''merges_file''']			)
        with open(self.vocab_file     ,       '''w'''			) as fp:
         fp.write(json.dumps(__lowerCAmelCase			)			)
        with open(self.merges_file     ,       '''w'''			) as fp:
         fp.write('''\n'''.join(__lowerCAmelCase			)			)

       def _lowerCAmelCase(						self     ,       __lowerCAmelCase			)  ->  Dict:
        return "lower newer", "lower newer"

       def _lowerCAmelCase(						self			)  ->  List[Any]:
        lowercase__    :   int						= OpenAIGPTTokenizer(self.vocab_file     ,       self.merges_file			)

        lowercase__    :   List[Any]						= '''lower'''
        lowercase__    :   Any						= ['''low''', '''er</w>''']
        lowercase__    :   Union[str, Any]						= tokenizer.tokenize(__lowerCAmelCase			)
        self.assertListEqual(__lowerCAmelCase     ,       __lowerCAmelCase			)

        lowercase__    :   Tuple						= tokens + ['''<unk>''']
        lowercase__    :   Optional[Any]						= [14, 15, 20]
        self.assertListEqual(tokenizer.convert_tokens_to_ids(__lowerCAmelCase			)     ,       __lowerCAmelCase			)

       def _lowerCAmelCase(						self     ,       __lowerCAmelCase=15			)  ->  Optional[int]:
        for tokenizer, pretrained_name, kwargs in self.tokenizers_list:
         with self.subTest(F"""{tokenizer.__class__.__name__} ({pretrained_name})"""			):
          lowercase__    :   List[str]						= self.rust_tokenizer_class.from_pretrained(__lowerCAmelCase     ,       **__lowerCAmelCase			)

          # Simple input
          lowercase__    :   List[str]						= '''This is a simple input'''
          lowercase__    :   Any						= ['''This is a simple input 1''', '''This is a simple input 2''']
          lowercase__    :   str						= ('''This is a simple input''', '''This is a pair''')
          lowercase__    :   str						= [
              ('''This is a simple input 1''', '''This is a simple input 2'''),
              ('''This is a simple pair 1''', '''This is a simple pair 2'''),
          ]

          # Simple input tests
          self.assertRaises(__lowerCAmelCase     ,       tokenizer_r.encode     ,       __lowerCAmelCase     ,       max_length=__lowerCAmelCase     ,       padding='''max_length'''			)

          # Simple input
          self.assertRaises(__lowerCAmelCase     ,       tokenizer_r.encode_plus     ,       __lowerCAmelCase     ,       max_length=__lowerCAmelCase     ,       padding='''max_length'''			)

          # Simple input
          self.assertRaises(
              __lowerCAmelCase     ,       tokenizer_r.batch_encode_plus     ,       __lowerCAmelCase     ,       max_length=__lowerCAmelCase     ,       padding='''max_length'''     ,       )

          # Pair input
          self.assertRaises(__lowerCAmelCase     ,       tokenizer_r.encode     ,       __lowerCAmelCase     ,       max_length=__lowerCAmelCase     ,       padding='''max_length'''			)

          # Pair input
          self.assertRaises(__lowerCAmelCase     ,       tokenizer_r.encode_plus     ,       __lowerCAmelCase     ,       max_length=__lowerCAmelCase     ,       padding='''max_length'''			)

          # Pair input
          self.assertRaises(
              __lowerCAmelCase     ,       tokenizer_r.batch_encode_plus     ,       __lowerCAmelCase     ,       max_length=__lowerCAmelCase     ,       padding='''max_length'''     ,       )


       def _lowerCAmelCase(						self			)  ->  Tuple:
        pass



@require_ftfy
@require_spacy
@require_tokenizers
class       UpperCAmelCase  (						a__ ):





       '''simple docstring'''



       pass

