





'''simple docstring'''

import os
import tempfile
import unittest
from pathlib import Path

from transformers import AutoConfig, is_torch_available
from transformers.testing_utils import require_torch, torch_device


if is_torch_available():
  from transformers import PyTorchBenchmark, PyTorchBenchmarkArguments






@require_torch
class   UpperCAmelCase      (			unittest.TestCase							):
 def 	UpperCAmelCase_				(							self :Tuple		,			lowercase_ :List[str]				)->				Tuple:






     for model_result in results.values():
         for batch_size, sequence_length in zip(model_result["bs"]		,			model_result["ss"]				):
             A__							=     model_result['''result'''][batch_size][sequence_length]
             self.assertIsNotNone(lowercase_				)
 def 	UpperCAmelCase_				(							self :Dict				)->				Optional[Any]:
     A__							=     '''sshleifer/tiny-gpt2'''
     A__							=     PyTorchBenchmarkArguments(
         models=[MODEL_ID]		,			training=lowercase_		,			inference=lowercase_		,			sequence_lengths=[8]		,			batch_sizes=[1]		,			multi_process=lowercase_		,			)
     A__							=     PyTorchBenchmark(lowercase_				)
     A__							=     benchmark.run()
     self.check_results_dict_not_empty(results.time_inference_result				)
     self.check_results_dict_not_empty(results.memory_inference_result				)
 def 	UpperCAmelCase_				(							self :Tuple				)->				int:
     A__							=     '''sgugger/tiny-distilbert-classification'''
     A__							=     PyTorchBenchmarkArguments(
         models=[MODEL_ID]		,			training=lowercase_		,			inference=lowercase_		,			sequence_lengths=[8]		,			batch_sizes=[1]		,			multi_process=lowercase_		,			only_pretrain_model=lowercase_		,			)
     A__							=     PyTorchBenchmark(lowercase_				)
     A__							=     benchmark.run()
     self.check_results_dict_not_empty(results.time_inference_result				)
     self.check_results_dict_not_empty(results.memory_inference_result				)
 def 	UpperCAmelCase_				(							self :Union[str, Any]				)->				List[str]:
     A__							=     '''sshleifer/tiny-gpt2'''
     A__							=     PyTorchBenchmarkArguments(
         models=[MODEL_ID]		,			training=lowercase_		,			inference=lowercase_		,			torchscript=lowercase_		,			sequence_lengths=[8]		,			batch_sizes=[1]		,			multi_process=lowercase_		,			)
     A__							=     PyTorchBenchmark(lowercase_				)
     A__							=     benchmark.run()
     self.check_results_dict_not_empty(results.time_inference_result				)
     self.check_results_dict_not_empty(results.memory_inference_result				)
 @unittest.skipIf(torch_device == "cpu"		,			"Cant do half precision"				)
 def 	UpperCAmelCase_				(							self :str				)->				Any:
     A__							=     '''sshleifer/tiny-gpt2'''
     A__							=     PyTorchBenchmarkArguments(
         models=[MODEL_ID]		,			training=lowercase_		,			inference=lowercase_		,			fpaa=lowercase_		,			sequence_lengths=[8]		,			batch_sizes=[1]		,			multi_process=lowercase_		,			)
     A__							=     PyTorchBenchmark(lowercase_				)
     A__							=     benchmark.run()
     self.check_results_dict_not_empty(results.time_inference_result				)
     self.check_results_dict_not_empty(results.memory_inference_result				)
 def 	UpperCAmelCase_				(							self :List[str]				)->				int:
     A__							=     '''sshleifer/tiny-gpt2'''
     A__							=     AutoConfig.from_pretrained(lowercase_				)
     # set architectures equal to `None`
     A__							=     None
     A__							=     PyTorchBenchmarkArguments(
         models=[MODEL_ID]		,			training=lowercase_		,			inference=lowercase_		,			sequence_lengths=[8]		,			batch_sizes=[1]		,			multi_process=lowercase_		,			)
     A__							=     PyTorchBenchmark(lowercase_		,			configs=[config]				)
     A__							=     benchmark.run()
     self.check_results_dict_not_empty(results.time_inference_result				)
     self.check_results_dict_not_empty(results.memory_inference_result				)
 def 	UpperCAmelCase_				(							self :Union[str, Any]				)->				List[str]:
     A__							=     '''sshleifer/tiny-gpt2'''
     A__							=     PyTorchBenchmarkArguments(
         models=[MODEL_ID]		,			training=lowercase_		,			inference=lowercase_		,			sequence_lengths=[8]		,			batch_sizes=[1]		,			multi_process=lowercase_		,			)
     A__							=     PyTorchBenchmark(lowercase_				)
     A__							=     benchmark.run()
     self.check_results_dict_not_empty(results.time_train_result				)
     self.check_results_dict_not_empty(results.memory_train_result				)
 @unittest.skipIf(torch_device == "cpu"		,			"Can\'t do half precision"				)
 def 	UpperCAmelCase_				(							self :Optional[Any]				)->				Tuple:
     A__							=     '''sshleifer/tiny-gpt2'''
     A__							=     PyTorchBenchmarkArguments(
         models=[MODEL_ID]		,			training=lowercase_		,			inference=lowercase_		,			sequence_lengths=[8]		,			batch_sizes=[1]		,			fpaa=lowercase_		,			multi_process=lowercase_		,			)
     A__							=     PyTorchBenchmark(lowercase_				)
     A__							=     benchmark.run()
     self.check_results_dict_not_empty(results.time_train_result				)
     self.check_results_dict_not_empty(results.memory_train_result				)
 def 	UpperCAmelCase_				(							self :Optional[int]				)->				Union[str, Any]:
     A__							=     '''sshleifer/tiny-gpt2'''
     A__							=     AutoConfig.from_pretrained(lowercase_				)
     A__							=     PyTorchBenchmarkArguments(
         models=[MODEL_ID]		,			training=lowercase_		,			inference=lowercase_		,			sequence_lengths=[8]		,			batch_sizes=[1]		,			multi_process=lowercase_		,			)
     A__							=     PyTorchBenchmark(lowercase_		,			configs=[config]				)
     A__							=     benchmark.run()
     self.check_results_dict_not_empty(results.time_inference_result				)
     self.check_results_dict_not_empty(results.memory_inference_result				)
 def 	UpperCAmelCase_				(							self :Optional[Any]				)->				Dict:
     A__							=     '''sshleifer/tinier_bart'''
     A__							=     AutoConfig.from_pretrained(lowercase_				)
     A__							=     PyTorchBenchmarkArguments(
         models=[MODEL_ID]		,			training=lowercase_		,			inference=lowercase_		,			sequence_lengths=[8]		,			batch_sizes=[1]		,			multi_process=lowercase_		,			)
     A__							=     PyTorchBenchmark(lowercase_		,			configs=[config]				)
     A__							=     benchmark.run()
     self.check_results_dict_not_empty(results.time_inference_result				)
     self.check_results_dict_not_empty(results.memory_inference_result				)
 def 	UpperCAmelCase_				(							self :int				)->				Optional[Any]:
     A__							=     '''sshleifer/tiny-gpt2'''
     A__							=     AutoConfig.from_pretrained(lowercase_				)
     A__							=     PyTorchBenchmarkArguments(
         models=[MODEL_ID]		,			training=lowercase_		,			inference=lowercase_		,			sequence_lengths=[8]		,			batch_sizes=[1]		,			multi_process=lowercase_		,			)
     A__							=     PyTorchBenchmark(lowercase_		,			configs=[config]				)
     A__							=     benchmark.run()
     self.check_results_dict_not_empty(results.time_train_result				)
     self.check_results_dict_not_empty(results.memory_train_result				)
 def 	UpperCAmelCase_				(							self :int				)->				Dict:
     A__							=     '''sshleifer/tinier_bart'''
     A__							=     AutoConfig.from_pretrained(lowercase_				)
     A__							=     PyTorchBenchmarkArguments(
         models=[MODEL_ID]		,			training=lowercase_		,			inference=lowercase_		,			sequence_lengths=[8]		,			batch_sizes=[1]		,			multi_process=lowercase_		,			)
     A__							=     PyTorchBenchmark(lowercase_		,			configs=[config]				)
     A__							=     benchmark.run()
     self.check_results_dict_not_empty(results.time_train_result				)
     self.check_results_dict_not_empty(results.memory_train_result				)
 def 	UpperCAmelCase_				(							self :int				)->				Union[str, Any]:
     A__							=     '''sshleifer/tiny-gpt2'''
     with tempfile.TemporaryDirectory() as tmp_dir:
         A__							=     PyTorchBenchmarkArguments(
             models=[MODEL_ID]		,			training=lowercase_		,			inference=lowercase_		,			save_to_csv=lowercase_		,			sequence_lengths=[8]		,			batch_sizes=[1]		,			inference_time_csv_file=os.path.join(lowercase_		,			"inf_time.csv"				)		,			train_memory_csv_file=os.path.join(lowercase_		,			"train_mem.csv"				)		,			inference_memory_csv_file=os.path.join(lowercase_		,			"inf_mem.csv"				)		,			train_time_csv_file=os.path.join(lowercase_		,			"train_time.csv"				)		,			env_info_csv_file=os.path.join(lowercase_		,			"env.csv"				)		,			multi_process=lowercase_		,			)
         A__							=     PyTorchBenchmark(lowercase_				)
         benchmark.run()
         self.assertTrue(Path(os.path.join(lowercase_		,			"inf_time.csv"				)				).exists()				)
         self.assertTrue(Path(os.path.join(lowercase_		,			"train_time.csv"				)				).exists()				)
         self.assertTrue(Path(os.path.join(lowercase_		,			"inf_mem.csv"				)				).exists()				)
         self.assertTrue(Path(os.path.join(lowercase_		,			"train_mem.csv"				)				).exists()				)
         self.assertTrue(Path(os.path.join(lowercase_		,			"env.csv"				)				).exists()				)



 def 	UpperCAmelCase_				(							self :List[Any]				)->				Any:
     A__							=     '''sshleifer/tiny-gpt2'''

     def _check_summary_is_not_empty(lowercase_ :str				):
         self.assertTrue(hasattr(lowercase_		,			"sequential"				)				)
         self.assertTrue(hasattr(lowercase_		,			"cumulative"				)				)
         self.assertTrue(hasattr(lowercase_		,			"current"				)				)
         self.assertTrue(hasattr(lowercase_		,			"total"				)				)

     with tempfile.TemporaryDirectory() as tmp_dir:
         A__							=     PyTorchBenchmarkArguments(
             models=[MODEL_ID]		,			training=lowercase_		,			inference=lowercase_		,			sequence_lengths=[8]		,			batch_sizes=[1]		,			log_filename=os.path.join(lowercase_		,			"log.txt"				)		,			log_print=lowercase_		,			trace_memory_line_by_line=lowercase_		,			multi_process=lowercase_		,			)
         A__							=     PyTorchBenchmark(lowercase_				)
         A__							=     benchmark.run()
         _check_summary_is_not_empty(result.inference_summary				)
         _check_summary_is_not_empty(result.train_summary				)
         self.assertTrue(Path(os.path.join(lowercase_		,			"log.txt"				)				).exists()				)





'''simple docstring'''




def 						lowerCAmelCase_							(  snake_case__		):




    '''simple docstring'''



    if len(snake_case__		) <= 1:
        return [tuple(snake_case__		)]

    A			:  int   =		[]

    def generate(snake_case__						,							snake_case__		):
        if k == 1:
            res.append(tuple(arr[:]		)		)
            return

        generate(k - 1						,							snake_case__		)

        for i in range(k - 1		):
            if k % 2 == 0:  # k is even
                A,    A			:  Any   =		arr[k - 1], arr[i]
            else:  # k is odd
                A,    A			:  List[str]   =		arr[k - 1], arr[0]
            generate(k - 1						,							snake_case__		)

    generate(len(snake_case__		)						,							snake_case__		)
    return res


if __name__ == "__main__":
      lowercase     :							int       						=     input('Enter numbers separated by a comma:\n').strip()
      lowercase     :							Dict       						=     [int(item) for item in user_input.split(',')]
      print(heaps(arr))




