
"""simple docstring"""


import unittest

import numpy as np
from datasets import load_dataset

from transformers.testing_utils import require_torch, require_vision
from transformers.utils import is_torch_available, is_vision_available

from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs


if is_torch_available():
		import torch

if is_vision_available():
		from PIL import Image

		from transformers import BeitImageProcessor







class 					lowerCAmelCase_					(   unittest.TestCase     ):



						'''simple docstring'''


						def __init__(			self  :   List[str]	,A_  :   Dict	,A_  :   Any=7	,A_  :   str=3	,A_  :   List[str]=18	,A_  :   Union[str, Any]=30	,A_  :   Optional[Any]=400	,A_  :   Any=True	,A_  :   Optional[int]=None	,A_  :   Tuple=True	,A_  :   List[Any]=None	,A_  :   Union[str, Any]=True	,A_  :   str=[0.5, 0.5, 0.5]	,A_  :   int=[0.5, 0.5, 0.5]	,A_  :   Optional[int]=False	,)  -> str:
							A     = size if size is not None else {'height': 20, 'width': 20}
							A     = crop_size if crop_size is not None else {'height': 18, 'width': 18}
							A     = parent
							A     = batch_size
							A     = num_channels
							A     = image_size
							A     = min_resolution
							A     = max_resolution
							A     = do_resize
							A     = size
							A     = do_center_crop
							A     = crop_size
							A     = do_normalize
							A     = image_mean
							A     = image_std
							A     = do_reduce_labels




						def     _SCREAMING_SNAKE_CASE   (			self  :   Optional[int]   )  -> List[str]:
							return {
							    "do_resize": self.do_resize,
							    "size": self.size,
							    "do_center_crop": self.do_center_crop,
							    "crop_size": self.crop_size,
							    "do_normalize": self.do_normalize,
							    "image_mean": self.image_mean,
							    "image_std": self.image_std,
							    "do_reduce_labels": self.do_reduce_labels,
							}






def    _snake_case					(		):
	A     = load_dataset('hf-internal-testing/fixtures_ade20k'						,   split='test'  )

	A     = Image.open(dataset[0]['file']  )
	A     = Image.open(dataset[1]['file']  )

	return image, map






def    _snake_case					(		):
	A     = load_dataset('hf-internal-testing/fixtures_ade20k'						,   split='test'  )

	A     = Image.open(ds[0]['file']  )
	A     = Image.open(ds[1]['file']  )
	A     = Image.open(ds[2]['file']  )
	A     = Image.open(ds[3]['file']  )

	return [imagea, imagea], [mapa, mapa]







@require_torch
@require_vision
class 					lowerCAmelCase_					(   SCREAMING_SNAKE_CASE_		,       unittest.TestCase     ):



						'''simple docstring'''


						_lowerCamelCase:     Union[str, Any]   =     BeitImageProcessor if is_vision_available() else None


						def     _SCREAMING_SNAKE_CASE   (			self  :   int   )  -> int:
							A     = BeitImageProcessingTester(self   )


						@property
						def     _SCREAMING_SNAKE_CASE   (			self  :   Union[str, Any]   )  -> List[str]:
							return self.image_processor_tester.prepare_image_processor_dict()


						def     _SCREAMING_SNAKE_CASE   (			self  :   Union[str, Any]   )  -> Optional[Any]:
							A     = self.image_processing_class(**self.image_processor_dict   )
							self.assertTrue(hasattr(A_	,'do_resize'   )   )
							self.assertTrue(hasattr(A_	,'size'   )   )
							self.assertTrue(hasattr(A_	,'do_center_crop'   )   )
							self.assertTrue(hasattr(A_	,'center_crop'   )   )
							self.assertTrue(hasattr(A_	,'do_normalize'   )   )
							self.assertTrue(hasattr(A_	,'image_mean'   )   )
							self.assertTrue(hasattr(A_	,'image_std'   )   )


						def     _SCREAMING_SNAKE_CASE   (			self  :   List[Any]   )  -> Tuple:
							A     = self.image_processing_class.from_dict(self.image_processor_dict   )
							self.assertEqual(image_processor.size	,{'height': 20, 'width': 20}   )
							self.assertEqual(image_processor.crop_size	,{'height': 18, 'width': 18}   )
							self.assertEqual(image_processor.do_reduce_labels	,A_   )

							A     = self.image_processing_class.from_dict(
							    self.image_processor_dict	,size=42	,crop_size=84	,reduce_labels=A_   )
							self.assertEqual(image_processor.size	,{'height': 42, 'width': 42}   )
							self.assertEqual(image_processor.crop_size	,{'height': 84, 'width': 84}   )
							self.assertEqual(image_processor.do_reduce_labels	,A_   )


						def     _SCREAMING_SNAKE_CASE   (			self  :   Optional[Any]   )  -> Optional[Any]:
							pass


						def     _SCREAMING_SNAKE_CASE   (			self  :   List[Any]   )  -> Optional[int]:
							A     = self.image_processing_class(**self.image_processor_dict   )
							# create random PIL images
							A     = prepare_image_inputs(self.image_processor_tester	,equal_resolution=A_   )
							for image in image_inputs:
								self.assertIsInstance(A_	,Image.Image   )

							# Test not batched input
							A     = image_processing(image_inputs[0]	,return_tensors='pt'   ).pixel_values
							self.assertEqual(
							    encoded_images.shape	,(
							        1,
							        self.image_processor_tester.num_channels,
							        self.image_processor_tester.crop_size['height'],
							        self.image_processor_tester.crop_size['width'],
							    )	,)

							# Test batched
							A     = image_processing(A_	,return_tensors='pt'   ).pixel_values
							self.assertEqual(
							    encoded_images.shape	,(
							        self.image_processor_tester.batch_size,
							        self.image_processor_tester.num_channels,
							        self.image_processor_tester.crop_size['height'],
							        self.image_processor_tester.crop_size['width'],
							    )	,)


						def     _SCREAMING_SNAKE_CASE   (			self  :   Optional[Any]   )  -> Dict:
							A     = self.image_processing_class(**self.image_processor_dict   )
							# create random numpy tensors
							A     = prepare_image_inputs(self.image_processor_tester	,equal_resolution=A_	,numpify=A_   )
							for image in image_inputs:
								self.assertIsInstance(A_	,np.ndarray   )

							# Test not batched input
							A     = image_processing(image_inputs[0]	,return_tensors='pt'   ).pixel_values
							self.assertEqual(
							    encoded_images.shape	,(
							        1,
							        self.image_processor_tester.num_channels,
							        self.image_processor_tester.crop_size['height'],
							        self.image_processor_tester.crop_size['width'],
							    )	,)

							# Test batched
							A     = image_processing(A_	,return_tensors='pt'   ).pixel_values
							self.assertEqual(
							    encoded_images.shape	,(
							        self.image_processor_tester.batch_size,
							        self.image_processor_tester.num_channels,
							        self.image_processor_tester.crop_size['height'],
							        self.image_processor_tester.crop_size['width'],
							    )	,)


						def     _SCREAMING_SNAKE_CASE   (			self  :   Union[str, Any]   )  -> List[str]:
							A     = self.image_processing_class(**self.image_processor_dict   )
							# create random PyTorch tensors
							A     = prepare_image_inputs(self.image_processor_tester	,equal_resolution=A_	,torchify=A_   )
							for image in image_inputs:
								self.assertIsInstance(A_	,torch.Tensor   )

							# Test not batched input
							A     = image_processing(image_inputs[0]	,return_tensors='pt'   ).pixel_values
							self.assertEqual(
							    encoded_images.shape	,(
							        1,
							        self.image_processor_tester.num_channels,
							        self.image_processor_tester.crop_size['height'],
							        self.image_processor_tester.crop_size['width'],
							    )	,)

							# Test batched
							A     = image_processing(A_	,return_tensors='pt'   ).pixel_values
							self.assertEqual(
							    encoded_images.shape	,(
							        self.image_processor_tester.batch_size,
							        self.image_processor_tester.num_channels,
							        self.image_processor_tester.crop_size['height'],
							        self.image_processor_tester.crop_size['width'],
							    )	,)


						def     _SCREAMING_SNAKE_CASE   (			self  :   Optional[Any]   )  -> int:
							A     = self.image_processing_class(**self.image_processor_dict   )
							# create random PyTorch tensors
							A     = prepare_image_inputs(self.image_processor_tester	,equal_resolution=A_	,torchify=A_   )
							A     = []
							for image in image_inputs:
								self.assertIsInstance(A_	,torch.Tensor   )
								maps.append(torch.zeros(image.shape[-2:]   ).long()   )

							# Test not batched input
							A     = image_processing(image_inputs[0]	,maps[0]	,return_tensors='pt'   )
							self.assertEqual(
							    encoding['pixel_values'].shape	,(
							        1,
							        self.image_processor_tester.num_channels,
							        self.image_processor_tester.crop_size['height'],
							        self.image_processor_tester.crop_size['width'],
							    )	,)
							self.assertEqual(
							    encoding['labels'].shape	,(
							        1,
							        self.image_processor_tester.crop_size['height'],
							        self.image_processor_tester.crop_size['width'],
							    )	,)
							self.assertEqual(encoding['labels'].dtype	,torch.long   )
							self.assertTrue(encoding['labels'].min().item() >= 0   )
							self.assertTrue(encoding['labels'].max().item() <= 255   )

							# Test batched
							A     = image_processing(A_	,A_	,return_tensors='pt'   )
							self.assertEqual(
							    encoding['pixel_values'].shape	,(
							        self.image_processor_tester.batch_size,
							        self.image_processor_tester.num_channels,
							        self.image_processor_tester.crop_size['height'],
							        self.image_processor_tester.crop_size['width'],
							    )	,)
							self.assertEqual(
							    encoding['labels'].shape	,(
							        self.image_processor_tester.batch_size,
							        self.image_processor_tester.crop_size['height'],
							        self.image_processor_tester.crop_size['width'],
							    )	,)
							self.assertEqual(encoding['labels'].dtype	,torch.long   )
							self.assertTrue(encoding['labels'].min().item() >= 0   )
							self.assertTrue(encoding['labels'].max().item() <= 255   )

							# Test not batched input (PIL images)
							A     = prepare_semantic_single_inputs()

							A     = image_processing(A_	,A_	,return_tensors='pt'   )
							self.assertEqual(
							    encoding['pixel_values'].shape	,(
							        1,
							        self.image_processor_tester.num_channels,
							        self.image_processor_tester.crop_size['height'],
							        self.image_processor_tester.crop_size['width'],
							    )	,)
							self.assertEqual(
							    encoding['labels'].shape	,(
							        1,
							        self.image_processor_tester.crop_size['height'],
							        self.image_processor_tester.crop_size['width'],
							    )	,)
							self.assertEqual(encoding['labels'].dtype	,torch.long   )
							self.assertTrue(encoding['labels'].min().item() >= 0   )
							self.assertTrue(encoding['labels'].max().item() <= 255   )

							# Test batched input (PIL images)
							A     = prepare_semantic_batch_inputs()

							A     = image_processing(A_	,A_	,return_tensors='pt'   )
							self.assertEqual(
							    encoding['pixel_values'].shape	,(
							        2,
							        self.image_processor_tester.num_channels,
							        self.image_processor_tester.crop_size['height'],
							        self.image_processor_tester.crop_size['width'],
							    )	,)
							self.assertEqual(
							    encoding['labels'].shape	,(
							        2,
							        self.image_processor_tester.crop_size['height'],
							        self.image_processor_tester.crop_size['width'],
							    )	,)
							self.assertEqual(encoding['labels'].dtype	,torch.long   )
							self.assertTrue(encoding['labels'].min().item() >= 0   )
							self.assertTrue(encoding['labels'].max().item() <= 255   )




						def     _SCREAMING_SNAKE_CASE   (			self  :   Any   )  -> Optional[Any]:
							A     = self.image_processing_class(**self.image_processor_dict   )

							# ADE20k has 150 classes, and the background is included, so labels should be between 0 and 150
							A     = prepare_semantic_single_inputs()
							A     = image_processing(A_	,A_	,return_tensors='pt'   )
							self.assertTrue(encoding['labels'].min().item() >= 0   )
							self.assertTrue(encoding['labels'].max().item() <= 150   )

							A     = True
							A     = image_processing(A_	,A_	,return_tensors='pt'   )
							self.assertTrue(encoding['labels'].min().item() >= 0   )
							self.assertTrue(encoding['labels'].max().item() <= 255   )




from datetime import datetime

import requests

def        __a			(   __lowerCAmelCase   )     ->     bytes:
					SCREAMING_SNAKE_CASE							:     int						=				'https://downloadgram.net/wp-json/wppress/video-downloader/video?url='
					SCREAMING_SNAKE_CASE							:     Any						=				requests.get(base_url + url   ).json()[0]['urls'][0]['src']
					return requests.get(__lowerCAmelCase   ).content


if __name__ == "__main__":
			_lowerCamelCase    :		List[Any]		      =    input("""Enter Video/IGTV url: """).strip()
			_lowerCamelCase    :		int		      =    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}.""")