



"""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):
			"""simple docstring"""



			def        lowercase__  (						self   :			Any      )->List[Any]:
							_UpperCAmelCase							=			'''hf-internal-testing/tiny-random-t5'''
							_UpperCAmelCase							=			AutoTokenizer.from_pretrained(__UpperCAmelCase      )
							_UpperCAmelCase							=			AutoModelForSeqaSeqLM.from_pretrained(__UpperCAmelCase      )

							_UpperCAmelCase							=			tokenizer('''This is me''' ,      return_tensors='''pt'''      )

							_UpperCAmelCase							=			model.to_bettertransformer()

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

							_UpperCAmelCase							=			model.generate(**__UpperCAmelCase      )

							_UpperCAmelCase							=			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      )

											_UpperCAmelCase							=			AutoModelForSeqaSeqLM.from_pretrained(__UpperCAmelCase      )

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

											_UpperCAmelCase							=			model_reloaded.generate(**__UpperCAmelCase      )
											self.assertTrue(torch.allclose(__UpperCAmelCase ,      __UpperCAmelCase      )      )



			def        lowercase__  (						self   :			List[Any]      )->List[Any]:
							_UpperCAmelCase							=			'''hf-internal-testing/tiny-random-t5'''
							_UpperCAmelCase							=			AutoModelForSeqaSeqLM.from_pretrained(__UpperCAmelCase      )

							_UpperCAmelCase							=			model.to_bettertransformer()

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

											_UpperCAmelCase							=			model.reverse_bettertransformer()
											model.save_pretrained(__UpperCAmelCase      )











def 						_a    (      a :int )							->			bool:
 a		  =      n ** (1 / 3)
 return (val * val * val) == n


if __name__ == "__main__":
     print(perfect_cube(27))
     print(perfect_cube(4))


