




import os
import tempfile
import unittest
from pathlib import Path

from transformers import AutoConfig, is_tf_available
from transformers.testing_utils import require_tf


if is_tf_available():
     import tensorflow as tf

     from transformers import TensorFlowBenchmark, TensorFlowBenchmarkArguments




@require_tf
class       __lowerCAmelCase				(							unittest.TestCase):






       def     SCREAMING_SNAKE_CASE			(      self:    Any				,    _lowerCAmelCase:    Tuple ):
         for model_result in results.values():
           for batch_size, sequence_length in zip(model_result["bs"]				,    model_result["ss"] ):
             lowercase			:List[str]							=  model_result["result"][batch_size][sequence_length]
             self.assertIsNotNone(_lowerCAmelCase )






       def     SCREAMING_SNAKE_CASE			(      self:    Tuple ):
         lowercase			:Tuple							=  "sshleifer/tiny-gpt2"
         lowercase			:List[str]							=  TensorFlowBenchmarkArguments(
             models=[MODEL_ID]				,    training=_lowerCAmelCase				,    inference=_lowerCAmelCase				,    sequence_lengths=[8]				,    batch_sizes=[1]				,    eager_mode=_lowerCAmelCase				,    multi_process=_lowerCAmelCase				,    )
         lowercase			:Tuple							=  TensorFlowBenchmark(_lowerCAmelCase )
         lowercase			:Union[str, Any]							=  benchmark.run()
         self.check_results_dict_not_empty(results.time_inference_result )
         self.check_results_dict_not_empty(results.memory_inference_result )






       def     SCREAMING_SNAKE_CASE			(      self:    Any ):
         lowercase			:List[str]							=  "sgugger/tiny-distilbert-classification"
         lowercase			:Union[str, Any]							=  TensorFlowBenchmarkArguments(
             models=[MODEL_ID]				,    training=_lowerCAmelCase				,    inference=_lowerCAmelCase				,    sequence_lengths=[8]				,    batch_sizes=[1]				,    multi_process=_lowerCAmelCase				,    only_pretrain_model=_lowerCAmelCase				,    )
         lowercase			:Union[str, Any]							=  TensorFlowBenchmark(_lowerCAmelCase )
         lowercase			:Union[str, Any]							=  benchmark.run()
         self.check_results_dict_not_empty(results.time_inference_result )
         self.check_results_dict_not_empty(results.memory_inference_result )






       def     SCREAMING_SNAKE_CASE			(      self:    Union[str, Any] ):
         lowercase			:Optional[Any]							=  "sshleifer/tiny-gpt2"
         lowercase			:Tuple							=  TensorFlowBenchmarkArguments(
             models=[MODEL_ID]				,    training=_lowerCAmelCase				,    inference=_lowerCAmelCase				,    sequence_lengths=[8]				,    batch_sizes=[1]				,    multi_process=_lowerCAmelCase				,    )
         lowercase			:Union[str, Any]							=  TensorFlowBenchmark(_lowerCAmelCase )
         lowercase			:Tuple							=  benchmark.run()
         self.check_results_dict_not_empty(results.time_inference_result )
         self.check_results_dict_not_empty(results.memory_inference_result )






       def     SCREAMING_SNAKE_CASE			(      self:    List[str] ):
         lowercase			:List[str]							=  "sshleifer/tiny-gpt2"
         lowercase			:Any							=  AutoConfig.from_pretrained(_lowerCAmelCase )
         lowercase			:str							=  TensorFlowBenchmarkArguments(
             models=[MODEL_ID]				,    training=_lowerCAmelCase				,    inference=_lowerCAmelCase				,    sequence_lengths=[8]				,    batch_sizes=[1]				,    eager_mode=_lowerCAmelCase				,    multi_process=_lowerCAmelCase				,    )
         lowercase			:List[str]							=  TensorFlowBenchmark(_lowerCAmelCase				,    [config] )
         lowercase			:Any							=  benchmark.run()
         self.check_results_dict_not_empty(results.time_inference_result )
         self.check_results_dict_not_empty(results.memory_inference_result )






       def     SCREAMING_SNAKE_CASE			(      self:    int ):
         lowercase			:Dict							=  "sshleifer/tiny-gpt2"
         lowercase			:Union[str, Any]							=  AutoConfig.from_pretrained(_lowerCAmelCase )
         lowercase			:List[Any]							=  TensorFlowBenchmarkArguments(
             models=[MODEL_ID]				,    training=_lowerCAmelCase				,    inference=_lowerCAmelCase				,    sequence_lengths=[8]				,    batch_sizes=[1]				,    multi_process=_lowerCAmelCase				,    )
         lowercase			:int							=  TensorFlowBenchmark(_lowerCAmelCase				,    [config] )
         lowercase			:Any							=  benchmark.run()
         self.check_results_dict_not_empty(results.time_inference_result )
         self.check_results_dict_not_empty(results.memory_inference_result )






       def     SCREAMING_SNAKE_CASE			(      self:    List[str] ):
         lowercase			:Union[str, Any]							=  "sshleifer/tiny-gpt2"
         lowercase			:Tuple							=  TensorFlowBenchmarkArguments(
             models=[MODEL_ID]				,    training=_lowerCAmelCase				,    inference=_lowerCAmelCase				,    sequence_lengths=[8]				,    batch_sizes=[1]				,    multi_process=_lowerCAmelCase				,    )
         lowercase			:Any							=  TensorFlowBenchmark(_lowerCAmelCase )
         lowercase			:int							=  benchmark.run()
         self.check_results_dict_not_empty(results.time_train_result )
         self.check_results_dict_not_empty(results.memory_train_result )






       def     SCREAMING_SNAKE_CASE			(      self:    Optional[Any] ):
         lowercase			:Optional[Any]							=  "sshleifer/tiny-gpt2"
         lowercase			:Tuple							=  AutoConfig.from_pretrained(_lowerCAmelCase )
         lowercase			:List[str]							=  TensorFlowBenchmarkArguments(
             models=[MODEL_ID]				,    training=_lowerCAmelCase				,    inference=_lowerCAmelCase				,    sequence_lengths=[8]				,    batch_sizes=[1]				,    multi_process=_lowerCAmelCase				,    )
         lowercase			:List[Any]							=  TensorFlowBenchmark(_lowerCAmelCase				,    [config] )
         lowercase			:Dict							=  benchmark.run()
         self.check_results_dict_not_empty(results.time_train_result )
         self.check_results_dict_not_empty(results.memory_train_result )






       def     SCREAMING_SNAKE_CASE			(      self:    Dict ):
         lowercase			:Union[str, Any]							=  "patrickvonplaten/t5-tiny-random"
         lowercase			:Optional[Any]							=  AutoConfig.from_pretrained(_lowerCAmelCase )
         lowercase			:List[Any]							=  TensorFlowBenchmarkArguments(
             models=[MODEL_ID]				,    training=_lowerCAmelCase				,    inference=_lowerCAmelCase				,    sequence_lengths=[8]				,    batch_sizes=[1]				,    multi_process=_lowerCAmelCase				,    )
         lowercase			:Dict							=  TensorFlowBenchmark(_lowerCAmelCase				,    configs=[config] )
         lowercase			:Union[str, Any]							=  benchmark.run()
         self.check_results_dict_not_empty(results.time_inference_result )
         self.check_results_dict_not_empty(results.memory_inference_result )






       @unittest.skipIf(is_tf_available() and len(tf.config.list_physical_devices("GPU" ) ) == 0				,    "Cannot do xla on CPU." )
       def     SCREAMING_SNAKE_CASE			(      self:    Dict ):
         lowercase			:int							=  "sshleifer/tiny-gpt2"
         lowercase			:Union[str, Any]							=  TensorFlowBenchmarkArguments(
             models=[MODEL_ID]				,    training=_lowerCAmelCase				,    inference=_lowerCAmelCase				,    sequence_lengths=[8]				,    batch_sizes=[1]				,    use_xla=_lowerCAmelCase				,    multi_process=_lowerCAmelCase				,    )
         lowercase			:List[str]							=  TensorFlowBenchmark(_lowerCAmelCase )
         lowercase			:str							=  benchmark.run()
         self.check_results_dict_not_empty(results.time_inference_result )
         self.check_results_dict_not_empty(results.memory_inference_result )






       def     SCREAMING_SNAKE_CASE			(      self:    Optional[int] ):
         lowercase			:Dict							=  "sshleifer/tiny-gpt2"
         with tempfile.TemporaryDirectory() as tmp_dir:
           lowercase			:List[Any]							=  TensorFlowBenchmarkArguments(
               models=[MODEL_ID]				,    inference=_lowerCAmelCase				,    save_to_csv=_lowerCAmelCase				,    sequence_lengths=[8]				,    batch_sizes=[1]				,    inference_time_csv_file=os.path.join(_lowerCAmelCase				,    "inf_time.csv" )				,    inference_memory_csv_file=os.path.join(_lowerCAmelCase				,    "inf_mem.csv" )				,    env_info_csv_file=os.path.join(_lowerCAmelCase				,    "env.csv" )				,    multi_process=_lowerCAmelCase				,    )
           lowercase			:Optional[int]							=  TensorFlowBenchmark(_lowerCAmelCase )
           benchmark.run()
           self.assertTrue(Path(os.path.join(_lowerCAmelCase				,    "inf_time.csv" ) ).exists() )
           self.assertTrue(Path(os.path.join(_lowerCAmelCase				,    "inf_mem.csv" ) ).exists() )
           self.assertTrue(Path(os.path.join(_lowerCAmelCase				,    "env.csv" ) ).exists() )






       def     SCREAMING_SNAKE_CASE			(      self:    Tuple ):
         lowercase			:Dict							=  "sshleifer/tiny-gpt2"

         def _check_summary_is_not_empty(_lowerCAmelCase:    Optional[Any] ):
           self.assertTrue(hasattr(_lowerCAmelCase				,    "sequential" ) )
           self.assertTrue(hasattr(_lowerCAmelCase				,    "cumulative" ) )
           self.assertTrue(hasattr(_lowerCAmelCase				,    "current" ) )
           self.assertTrue(hasattr(_lowerCAmelCase				,    "total" ) )

         with tempfile.TemporaryDirectory() as tmp_dir:
           lowercase			:List[str]							=  TensorFlowBenchmarkArguments(
               models=[MODEL_ID]				,    inference=_lowerCAmelCase				,    sequence_lengths=[8]				,    batch_sizes=[1]				,    log_filename=os.path.join(_lowerCAmelCase				,    "log.txt" )				,    log_print=_lowerCAmelCase				,    trace_memory_line_by_line=_lowerCAmelCase				,    eager_mode=_lowerCAmelCase				,    multi_process=_lowerCAmelCase				,    )
           lowercase			:Dict							=  TensorFlowBenchmark(_lowerCAmelCase )
           lowercase			:Optional[Any]							=  benchmark.run()
           _check_summary_is_not_empty(result.inference_summary )
           self.assertTrue(Path(os.path.join(_lowerCAmelCase				,    "log.txt" ) ).exists() )




def    a__       (						__UpperCamelCase = 1_0_0_0 ):
      SCREAMING_SNAKE_CASE_      =     -1
      SCREAMING_SNAKE_CASE_      =     0
      for a in range(1   ,					n // 3 ):
            # Solving the two equations a**2+b**2=c**2 and a+b+c=N eliminating c
            SCREAMING_SNAKE_CASE_      =     (n * n - 2 * a * n) // (2 * n - 2 * a)
            SCREAMING_SNAKE_CASE_      =     n - a - b
            if c * c == (a * a + b * b):
                  SCREAMING_SNAKE_CASE_      =     a * b * c
                  if candidate >= product:
                        SCREAMING_SNAKE_CASE_      =     candidate
      return product


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


