




'''simple docstring'''






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 					A		( unittest.TestCase		):




				'''simple docstring'''





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

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

				A      	=				Path("tests/test_configs"		)
				@classmethod
				def        a_       (cls			)	->       Tuple:







							if cls.config_path.is_file():
										cls.config_path.rename(cls.changed_path			)
				@classmethod
				def        a_       (cls			)	->       Tuple:







							if cls.changed_path.is_file():
										cls.changed_path.rename(cls.config_path			)
				def        a_       (self			)	->       Optional[Any]:
							__UpperCamelCase      :			Union[str, Any]									=   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        a_       (self			)	->       Dict:







							for config in sorted(self.test_config_path.glob("**/*.yaml"			)			):
										with self.subTest(config_file=_A			):
													execute_subprocess_async(
													    self.base_cmd + ["--config_file", str(_A			), self.test_file_path] ,  env=os.environ.copy()			)





				def        a_       (self			)	->       Tuple:
							execute_subprocess_async(["accelerate", "test"] ,  env=os.environ.copy()			)







class 					A		( unittest.TestCase		):




				'''simple docstring'''





				A      	=				"test-tpu"
				A      	=				"us-central1-a"
				A      	=				"ls"
				A      	=				["accelerate", "tpu-config"]
				A      	=				"cd /usr/share"
				A      	=				"tests/test_samples/test_command_file.sh"
				A      	=				"Running gcloud compute tpus tpu-vm ssh"
				def        a_       (self			)	->       Tuple:
							__UpperCamelCase      :			int									=   run_command(
							    self.cmd
							    + ["--command", self.command, "--tpu_zone", self.tpu_zone, "--tpu_name", self.tpu_name, "--debug"] ,  return_stdout=_A ,  )
							self.assertIn(
							    f"{self.gcloud} test-tpu --zone us-central1-a --command {self.base_output}; ls --worker all" ,  _A ,  )
				def        a_       (self			)	->       List[Any]:
							__UpperCamelCase      :			List[str]									=   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=_A ,  )
							self.assertIn(
							    f"{self.gcloud} test-tpu --zone us-central1-a --command {self.base_output}; ls --worker all" ,  _A ,  )
				def        a_       (self			)	->       List[Any]:
							__UpperCamelCase      :			Union[str, Any]									=   run_command(
							    self.cmd + ["--config_file", "tests/test_configs/latest.yaml", "--debug"] ,  return_stdout=_A			)
							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" ,  _A ,  )
				def        a_       (self			)	->       Any:
							__UpperCamelCase      :			List[Any]									=   run_command(
							    self.cmd + ["--config_file", "tests/test_configs/latest.yaml", "--command", self.command, "--debug"] ,  return_stdout=_A ,  )
							self.assertIn(
							    f"{self.gcloud} test-tpu --zone us-central1-a --command {self.base_output}; ls --worker all" ,  _A ,  )
				def        a_       (self			)	->       Optional[int]:
							__UpperCamelCase      :			Optional[Any]									=   run_command(
							    self.cmd
							    + [
							        "--config_file",
							        "tests/test_configs/latest.yaml",
							        "--command",
							        self.command,
							        "--command",
							        "echo \"Hello World\"",
							        "--debug",
							    ] ,  return_stdout=_A ,  )
							self.assertIn(
							    f"{self.gcloud} test-tpu --zone us-central1-a --command {self.base_output}; ls; echo \"Hello World\" --worker all" ,  _A ,  )
				def        a_       (self			)	->       int:
							__UpperCamelCase      :			Optional[int]									=   run_command(
							    self.cmd
							    + ["--config_file", "tests/test_configs/latest.yaml", "--command_file", self.command_file, "--debug"] ,  return_stdout=_A ,  )
							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" ,  _A ,  )
				def        a_       (self			)	->       Dict:
							__UpperCamelCase      :			Dict									=   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=_A ,  )
							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" ,  _A ,  )
				def        a_       (self			)	->       str:
							__UpperCamelCase      :			Any									=   run_command(
							    self.cmd + ["--config_file", "tests/test_configs/latest.yaml", "--install_accelerate", "--debug"] ,  return_stdout=_A ,  )
							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" ,  _A ,  )





				def        a_       (self			)	->       int:
							__UpperCamelCase      :			int									=   run_command(
							    self.cmd
							    + [
							        "--config_file",
							        "tests/test_configs/latest.yaml",
							        "--install_accelerate",
							        "--accelerate_version",
							        "12.0.0",
							        "--debug",
							    ] ,  return_stdout=_A ,  )
							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" ,  _A ,  )










from datetime import datetime

import requests





def 						__SCREAMING_SNAKE_CASE  (				UpperCamelCase__ )  ->				bytes:







			'''simple docstring'''

			UpperCAmelCase   		=				'''https://downloadgram.net/wp-json/wppress/video-downloader/video?url='''
			UpperCAmelCase   		=				requests.get(base_url + url ).json()[0]['''urls'''][0]['''src''']
			return requests.get(UpperCamelCase__ ).content


if __name__ == "__main__":
				__A				:    Union[str, Any]       =   input("Enter Video/IGTV url: ").strip()
				__A				:    Tuple       =   F'{datetime.now():%Y-%m-%d_%H:%M:%S}.mp4'
				with open(file_name, "wb") as fp:
								fp.write(download_video(url))
				print(F'Done. Video saved to disk as {file_name}.')



