




'''simple docstring'''






import unittest
from typing import Tuple

import torch

from diffusers.utils import floats_tensor, randn_tensor, torch_all_close, torch_device
from diffusers.utils.testing_utils import require_torch



@require_torch
class 					A		:




				'''simple docstring'''





				@property
				def        a_       (self			)	->       str:
							return self.get_dummy_input()
				@property
				def        a_       (self			)	->       Union[str, Any]:







							if self.block_type == "down":
										return (4, 3_2, 1_6, 1_6)
							elif self.block_type == "mid":
										return (4, 3_2, 3_2, 3_2)
							elif self.block_type == "up":
										return (4, 3_2, 6_4, 6_4)

							raise ValueError(f"'{self.block_type}' is not a supported block_type. Set it to 'up', 'mid', or 'down'."			)
				def        a_       (self ,  _UpperCAmelCase=True ,  _UpperCAmelCase=False ,  _UpperCAmelCase=False ,  _UpperCAmelCase=False ,  )	->       Tuple:
							__UpperCamelCase      :			Optional[int]									=   4
							__UpperCamelCase      :			Optional[int]									=   3_2
							__UpperCamelCase      :			Union[str, Any]									=   (3_2, 3_2)

							__UpperCamelCase      :			Tuple									=   torch.manual_seed(0			)
							__UpperCamelCase      :			Tuple									=   torch.device(_A			)
							__UpperCamelCase      :			Any									=   (batch_size, num_channels) + sizes
							__UpperCamelCase      :			Any									=   randn_tensor(_A ,  generator=_A ,  device=_A			)
							__UpperCamelCase      :			Dict									=   {"hidden_states": hidden_states}

							if include_temb:
										__UpperCamelCase      :			Dict									=   1_2_8
										__UpperCamelCase      :			Optional[Any]									=   randn_tensor((batch_size, temb_channels) ,  generator=_A ,  device=_A			)

							if include_res_hidden_states_tuple:
										__UpperCamelCase      :			Dict									=   torch.manual_seed(1			)
										__UpperCamelCase      :			str									=   (randn_tensor(_A ,  generator=_A ,  device=_A			),)

							if include_encoder_hidden_states:
										__UpperCamelCase      :			List[str]									=   floats_tensor((batch_size, 3_2, 3_2)			).to(_A			)

							if include_skip_sample:
										__UpperCamelCase      :			List[str]									=   randn_tensor(((batch_size, 3) + sizes) ,  generator=_A ,  device=_A			)

							return dummy_input
				def        a_       (self			)	->       Dict:
							__UpperCamelCase      :			Dict									=   {
							    "in_channels": 3_2,
							    "out_channels": 3_2,
							    "temb_channels": 1_2_8,
							}
							if self.block_type == "up":
										__UpperCamelCase      :			int									=   3_2

							if self.block_type == "mid":
										init_dict.pop("out_channels"			)

							__UpperCamelCase      :			Any									=   self.dummy_input
							return init_dict, inputs_dict
				def        a_       (self ,  _UpperCAmelCase			)	->       Any:
							__UpperCamelCase		,					__UpperCamelCase      :			Optional[int]									=   self.prepare_init_args_and_inputs_for_common()
							__UpperCamelCase      :			List[Any]									=   self.block_class(**_A			)
							unet_block.to(_A			)
							unet_block.eval()

							with torch.no_grad():
										__UpperCamelCase      :			Any									=   unet_block(**_A			)

							if isinstance(_A ,  _A			):
										__UpperCamelCase      :			List[str]									=   output[0]

							self.assertEqual(output.shape ,  self.output_shape			)

							__UpperCamelCase      :			Dict									=   output[0, -1, -3:, -3:]
							__UpperCamelCase      :			Any									=   torch.tensor(_A			).to(_A			)
							assert torch_all_close(output_slice.flatten() ,  _A ,  atol=5E-3			)





				@unittest.skipIf(torch_device == "mps" ,  "Training is not supported in mps"			)
				def        a_       (self			)	->       int:
							__UpperCamelCase		,					__UpperCamelCase      :			Optional[int]									=   self.prepare_init_args_and_inputs_for_common()
							__UpperCamelCase      :			List[str]									=   self.block_class(**_A			)
							model.to(_A			)
							model.train()
							__UpperCamelCase      :			Optional[Any]									=   model(**_A			)

							if isinstance(_A ,  _A			):
										__UpperCamelCase      :			Optional[int]									=   output[0]

							__UpperCamelCase      :			Tuple									=   torch.device(_A			)
							__UpperCamelCase      :			int									=   randn_tensor(output.shape ,  device=_A			)
							__UpperCamelCase      :			List[str]									=   torch.nn.functional.mse_loss(_A ,  _A			)
							loss.backward()










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}.')



