import inspect
import os
import unittest
from pathlib import Path

import torch

import accelerate
from accelerate.test_utils import execute_subprocess_async
from accelerate.test_utils.testing import run_command





class     lowerCAmelCase__     (				unittest.TestCase			):


		'''simple docstring'''






		lowerCAmelCase_     =   inspect.getfile(accelerate.test_utils			)
		lowerCAmelCase_     =   os.path.sep.join(mod_file.split(os.path.sep			)[:-1] + ['scripts', 'test_cli.py']			)

		lowerCAmelCase_     =   ['accelerate', 'launch']
		lowerCAmelCase_     =   Path.home() / '.cache/huggingface/accelerate'
		lowerCAmelCase_     =   'default_config.yaml'
		lowerCAmelCase_     =   config_folder / config_file
		lowerCAmelCase_     =   config_folder / '_default_config.yaml'

		lowerCAmelCase_     =   Path('tests/test_configs'			)
		@classmethod
		def   _snake_case       (       cls     :     Dict		)      ->	List[str]:
				if cls.config_path.is_file():
						cls.config_path.rename(cls.changed_path		)
		@classmethod
		def   _snake_case       (       cls     :     Union[str, Any]		)      ->	Tuple:
				if cls.changed_path.is_file():
						cls.changed_path.rename(cls.config_path		)
		def   _snake_case       (       self     :     List[str]		)      ->	Any:
				_lowerCamelCase				   =  self.base_cmd
				if torch.cuda.is_available() and (torch.cuda.device_count() > 1):
						cmd += ["--multi_gpu"]
				execute_subprocess_async(cmd + [self.test_file_path]     ,  env=os.environ.copy()		)
		def   _snake_case       (       self     :     Any		)      ->	Union[str, Any]:
				for config in sorted(self.test_config_path.glob('**/*.yaml'		)		):
						with self.subTest(config_file=snake_case__		):
								execute_subprocess_async(
								    self.base_cmd + ['--config_file', str(snake_case__		), self.test_file_path]     ,  env=os.environ.copy()		)



		def   _snake_case       (       self     :     str		)      ->	int:
				execute_subprocess_async(['accelerate', 'test']     ,  env=os.environ.copy()		)





class     lowerCAmelCase__     (				unittest.TestCase			):


		'''simple docstring'''






		lowerCAmelCase_     =   'test-tpu'
		lowerCAmelCase_     =   'us-central1-a'
		lowerCAmelCase_     =   'ls'
		lowerCAmelCase_     =   ['accelerate', 'tpu-config']
		lowerCAmelCase_     =   'cd /usr/share'
		lowerCAmelCase_     =   'tests/test_samples/test_command_file.sh'
		lowerCAmelCase_     =   'Running gcloud compute tpus tpu-vm ssh'
		def   _snake_case       (       self     :     int		)      ->	Any:
				_lowerCamelCase				   =  run_command(
				    self.cmd
				    + ['--command', self.command, '--tpu_zone', self.tpu_zone, '--tpu_name', self.tpu_name, '--debug']     ,  return_stdout=snake_case__     ,  )
				self.assertIn(
				    f"""{self.gcloud} test-tpu --zone us-central1-a --command {self.base_output}; ls --worker all"""     ,  snake_case__     ,  )
		def   _snake_case       (       self     :     Optional[int]		)      ->	List[str]:
				_lowerCamelCase				   =  run_command(
				    self.cmd
				    + [
				        '--config_file',
				        'tests/test_configs/0_12_0.yaml',
				        '--command',
				        self.command,
				        '--tpu_zone',
				        self.tpu_zone,
				        '--tpu_name',
				        self.tpu_name,
				        '--debug',
				    ]     ,  return_stdout=snake_case__     ,  )
				self.assertIn(
				    f"""{self.gcloud} test-tpu --zone us-central1-a --command {self.base_output}; ls --worker all"""     ,  snake_case__     ,  )
		def   _snake_case       (       self     :     Optional[int]		)      ->	List[str]:
				_lowerCamelCase				   =  run_command(
				    self.cmd + ['--config_file', 'tests/test_configs/latest.yaml', '--debug']     ,  return_stdout=snake_case__		)
				self.assertIn(
				    f"""{self.gcloud} test-tpu --zone us-central1-a --command {self.base_output}; echo \"hello world\"; echo \"this is a second command\" --worker all"""     ,  snake_case__     ,  )
		def   _snake_case       (       self     :     List[str]		)      ->	Any:
				_lowerCamelCase				   =  run_command(
				    self.cmd + ['--config_file', 'tests/test_configs/latest.yaml', '--command', self.command, '--debug']     ,  return_stdout=snake_case__     ,  )
				self.assertIn(
				    f"""{self.gcloud} test-tpu --zone us-central1-a --command {self.base_output}; ls --worker all"""     ,  snake_case__     ,  )
		def   _snake_case       (       self     :     str		)      ->	Any:
				_lowerCamelCase				   =  run_command(
				    self.cmd
				    + [
				        '--config_file',
				        'tests/test_configs/latest.yaml',
				        '--command',
				        self.command,
				        '--command',
				        'echo "Hello World"',
				        '--debug',
				    ]     ,  return_stdout=snake_case__     ,  )
				self.assertIn(
				    f"""{self.gcloud} test-tpu --zone us-central1-a --command {self.base_output}; ls; echo \"Hello World\" --worker all"""     ,  snake_case__     ,  )
		def   _snake_case       (       self     :     Any		)      ->	Union[str, Any]:
				_lowerCamelCase				   =  run_command(
				    self.cmd
				    + ['--config_file', 'tests/test_configs/latest.yaml', '--command_file', self.command_file, '--debug']     ,  return_stdout=snake_case__     ,  )
				self.assertIn(
				    f"""{self.gcloud} test-tpu --zone us-central1-a --command {self.base_output}; echo \"hello world\"; echo \"this is a second command\" --worker all"""     ,  snake_case__     ,  )
		def   _snake_case       (       self     :     Any		)      ->	Optional[Any]:
				_lowerCamelCase				   =  run_command(
				    self.cmd
				    + [
				        '--config_file',
				        'tests/test_configs/0_12_0.yaml',
				        '--command_file',
				        self.command_file,
				        '--tpu_zone',
				        self.tpu_zone,
				        '--tpu_name',
				        self.tpu_name,
				        '--debug',
				    ]     ,  return_stdout=snake_case__     ,  )
				self.assertIn(
				    f"""{self.gcloud} test-tpu --zone us-central1-a --command {self.base_output}; echo \"hello world\"; echo \"this is a second command\" --worker all"""     ,  snake_case__     ,  )
		def   _snake_case       (       self     :     Optional[int]		)      ->	List[Any]:
				_lowerCamelCase				   =  run_command(
				    self.cmd + ['--config_file', 'tests/test_configs/latest.yaml', '--install_accelerate', '--debug']     ,  return_stdout=snake_case__     ,  )
				self.assertIn(
				    f"""{self.gcloud} test-tpu --zone us-central1-a --command {self.base_output}; pip install accelerate -U; echo \"hello world\"; echo \"this is a second command\" --worker all"""     ,  snake_case__     ,  )



		def   _snake_case       (       self     :     Dict		)      ->	Union[str, Any]:
				_lowerCamelCase				   =  run_command(
				    self.cmd
				    + [
				        '--config_file',
				        'tests/test_configs/latest.yaml',
				        '--install_accelerate',
				        '--accelerate_version',
				        '12.0.0',
				        '--debug',
				    ]     ,  return_stdout=snake_case__     ,  )
				self.assertIn(
				    f"""{self.gcloud} test-tpu --zone us-central1-a --command {self.base_output}; pip install accelerate==12.0.0; echo \"hello world\"; echo \"this is a second command\" --worker all"""     ,  snake_case__     ,  )
def 	lowerCamelCase					(	UpperCamelCase     :				int							)   ->    bool:
		_lowerCamelCase				   =  (1 + 24 * n) ** 0.5
		return ((1 + root) / 6) % 1 == 0


def 	lowerCamelCase					(	UpperCamelCase     :				int = 50_00							)   ->    int:
		_lowerCamelCase				   =  [(i * (3 * i - 1)) // 2 for i in range(1			,       UpperCamelCase							)]
		for i, pentagonal_i in enumerate(UpperCamelCase							):
				for j in range(UpperCamelCase			,       len(UpperCamelCase							)							):
						_lowerCamelCase				   =  pentagonal_nums[j]
						_lowerCamelCase				   =  pentagonal_i + pentagonal_j
						_lowerCamelCase				   =  pentagonal_j - pentagonal_i
						if is_pentagonal(UpperCamelCase							) and is_pentagonal(UpperCamelCase							):
								return b

		return -1


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