




'''simple docstring'''







import json
import os
import unittest

from transformers import BatchEncoding, LEDTokenizer, LEDTokenizerFast
from transformers.models.led.tokenization_led 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

@require_tokenizers
class 	_snake_case(			UpperCAmelCase       , unittest.TestCase      ):
 __snake_case:							Optional[Any]						=					LEDTokenizer
 __snake_case:							List[str]						=					LEDTokenizerFast
 __snake_case:							Tuple						=					True






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






    """simple docstring"""


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

    A__       =     os.path.join(self.tmpdirname    ,		VOCAB_FILES_NAMES['vocab_file']    )
    A__       =     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(a    ) + '\n'    )
    with open(self.merges_file    ,		'w'    ,		encoding='utf-8'    ) as fp:
       fp.write('\n'.join(a    )    )






 def 						_UpperCamelCase (self       :  Union[str, Any]    ,		**a       :  Tuple    )       ->   List[Any]:






    """simple docstring"""


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






 def 						_UpperCamelCase (self       :  List[str]    ,		**a       :  str    )       ->   Optional[int]:






    """simple docstring"""


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






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






    """simple docstring"""


    return "lower newer", "lower newer"






 @cached_property
 def 						_UpperCamelCase (self       :  str    )       ->   Any:






    """simple docstring"""


    return LEDTokenizer.from_pretrained('allenai/led-base-16384'    )






 @cached_property
 def 						_UpperCamelCase (self       :  Union[str, Any]    )       ->   int:






    """simple docstring"""


    return LEDTokenizerFast.from_pretrained('allenai/led-base-16384'    )






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






    """simple docstring"""


    A__       =     ['A long paragraph for summarization.', 'Another paragraph for summarization.']
    A__       =     [0, 2_50, 2_51, 1_78_18, 13, 3_91_86, 19_38, 4, 2]

    for tokenizer in [self.default_tokenizer, self.default_tokenizer_fast]:
       A__       =     tokenizer(a    ,		max_length=len(a    )    ,		padding=a    ,		return_tensors='pt'    )
       self.assertIsInstance(a    ,		a    )

       self.assertEqual((2, 9)    ,		batch.input_ids.shape    )
       self.assertEqual((2, 9)    ,		batch.attention_mask.shape    )
       A__       =     batch.input_ids.tolist()[0]
       self.assertListEqual(a    ,		a    )






 @require_torch
 def 						_UpperCamelCase (self       :  Tuple    )       ->   Optional[Any]:






    """simple docstring"""


    A__       =     ['A long paragraph for summarization.', 'Another paragraph for summarization.']
    for tokenizer in [self.default_tokenizer, self.default_tokenizer_fast]:
       A__       =     tokenizer(a    ,		padding=a    ,		return_tensors='pt'    )
       self.assertIn('input_ids'    ,		a    )
       self.assertIn('attention_mask'    ,		a    )
       self.assertNotIn('labels'    ,		a    )
       self.assertNotIn('decoder_attention_mask'    ,		a    )






 @require_torch
 def 						_UpperCamelCase (self       :  Optional[Any]    )       ->   int:






    """simple docstring"""


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






 @require_torch
 def 						_UpperCamelCase (self       :  Tuple    )       ->   Dict:






    """simple docstring"""


    for tokenizer in [self.default_tokenizer, self.default_tokenizer_fast]:
       A__       =     tokenizer(
           ['I am a small frog' * 10_24, 'I am a small frog']    ,		padding=a    ,		truncation=a    ,		return_tensors='pt'    )
       self.assertIsInstance(a    ,		a    )
       self.assertEqual(batch.input_ids.shape    ,		(2, 51_22)    )






 @require_torch
 def 						_UpperCamelCase (self       :  Optional[Any]    )       ->   Optional[int]:






    """simple docstring"""


    A__       =     ['A long paragraph for summarization.']
    A__       =     [
        'Summary of the text.',
    ]
    for tokenizer in [self.default_tokenizer, self.default_tokenizer_fast]:
       A__       =     tokenizer(a    ,		return_tensors='pt'    )
       A__       =     tokenizer(text_target=a    ,		return_tensors='pt'    )
       A__       =     inputs['input_ids']
       A__       =     targets['input_ids']
       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()    )






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






    """simple docstring"""


    for tokenizer in [self.default_tokenizer, self.default_tokenizer_fast]:
       A__       =     ['Summary of the text.', 'Another summary.']
       A__       =     [[0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, -1, -1]]

       A__       =     tokenizer(a    ,		padding=a    )
       A__       =     [[0] * len(a    ) for x in encoded_output['input_ids']]
       A__       =     tokenizer.pad(a    )
       self.assertSequenceEqual(outputs['global_attention_mask']    ,		a    )






 def 						_UpperCamelCase (self       :  Tuple    )       ->   Optional[Any]:






    """simple docstring"""


    pass






 def 						_UpperCamelCase (self       :  int    )       ->   List[Any]:






    """simple docstring"""


    for tokenizer, pretrained_name, kwargs in self.tokenizers_list:
       with self.subTest(f"""{tokenizer.__class__.__name__} ({pretrained_name})"""    ):
          A__       =     self.rust_tokenizer_class.from_pretrained(a    ,		**a    )
          A__       =     self.tokenizer_class.from_pretrained(a    ,		**a    )
          A__       =     'A, <mask> AllenNLP sentence.'
          A__       =     tokenizer_r.encode_plus(a    ,		add_special_tokens=a    ,		return_token_type_ids=a    )
          A__       =     tokenizer_p.encode_plus(a    ,		add_special_tokens=a    ,		return_token_type_ids=a    )
          self.assertEqual(sum(tokens_r['token_type_ids']    )    ,		sum(tokens_p['token_type_ids']    )    )
          self.assertEqual(
              sum(tokens_r['attention_mask']    ) / len(tokens_r['attention_mask']    )    ,		sum(tokens_p['attention_mask']    ) / len(tokens_p['attention_mask']    )    ,		)

          A__       =     tokenizer_r.convert_ids_to_tokens(tokens_r['input_ids']    )
          A__       =     tokenizer_p.convert_ids_to_tokens(tokens_p['input_ids']    )
          self.assertSequenceEqual(tokens_p['input_ids']    ,		[0, 2_50, 6, 5_02_64, 38_23, 4_87, 2_19_92, 36_45, 4, 2]    )
          self.assertSequenceEqual(tokens_r['input_ids']    ,		[0, 2_50, 6, 5_02_64, 38_23, 4_87, 2_19_92, 36_45, 4, 2]    )

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








'''simple docstring'''







def 						_A      ( UpperCAmelCase						):






   '''simple docstring'''







   A__       =     0
   while num > 0:
      digit_sum += num % 10
      num //= 10
   return digit_sum







def 						_A      ( UpperCAmelCase = 100						):






   '''simple docstring'''







   A__       =     1
   A__       =     2

   for i in range(2      ,max_n + 1						):
      A__       =     pre_numerator
      A__       =     2 * i // 3 if i % 3 == 0 else 1
      A__       =     cur_numerator
      A__       =     e_cont * pre_numerator + temp

   return sum_digits(UpperCAmelCase						)


if __name__ == "__main__":
    print(f'''{solution() = }''')


