

'''simple docstring'''







import tempfile
import unittest

from transformers import AutoModelForSeqaSeqLM, AutoTokenizer
from transformers.testing_utils import (
    is_torch_available,
    require_optimum,
    require_torch,
    slow,
)


if is_torch_available():
      import torch


@require_torch
@require_optimum
@slow
class    A__ ( unittest.TestCase     ):



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





           '''simple docstring'''
           A_		   = """hf-internal-testing/tiny-random-t5"""
           A_		   = AutoTokenizer.from_pretrained(UpperCamelCase__    )
           A_		   = AutoModelForSeqaSeqLM.from_pretrained(UpperCamelCase__    )

           A_		   = tokenizer("""This is me"""						,			return_tensors="""pt"""    )

           A_		   = model.to_bettertransformer()

           self.assertTrue(any("""BetterTransformer""" in mod.__class__.__name__ for _, mod in model.named_modules()    )    )

           A_		   = model.generate(**UpperCamelCase__    )

           A_		   = model.reverse_bettertransformer()

           self.assertFalse(any("""BetterTransformer""" in mod.__class__.__name__ for _, mod in model.named_modules()    )    )

           with tempfile.TemporaryDirectory() as tmpdirname:
                  model.save_pretrained(UpperCamelCase__    )

                  A_		   = AutoModelForSeqaSeqLM.from_pretrained(UpperCamelCase__    )

                  self.assertFalse(
                      any("""BetterTransformer""" in mod.__class__.__name__ for _, mod in model_reloaded.named_modules()    )    )

                  A_		   = model_reloaded.generate(**UpperCamelCase__    )
                  self.assertTrue(torch.allclose(UpperCamelCase__						,			UpperCamelCase__    )    )







    def    snake_case_     (   self    )  -> Dict:





           '''simple docstring'''
           A_		   = """hf-internal-testing/tiny-random-t5"""
           A_		   = AutoModelForSeqaSeqLM.from_pretrained(UpperCamelCase__    )

           A_		   = model.to_bettertransformer()

           with tempfile.TemporaryDirectory() as tmpdirname:
                  with self.assertRaises(UpperCamelCase__    ):
                         model.save_pretrained(UpperCamelCase__    )

                  A_		   = model.reverse_bettertransformer()
                  model.save_pretrained(UpperCamelCase__    )



'''simple docstring'''







def  UpperCAmelCase__      ( UpperCAmelCase__ = 10_00			)     ->     int:
       return sum(2 * a * ((a - 1) // 2) for a in range(3,    n + 1			)			)


if __name__ == "__main__":
      print(solution())
