




import unittest

import numpy as np

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 MobileViTImageProcessor







class __snake_case			(			unittest.TestCase		):







   def __init__(      self		:						List[str]					,						_snake_case		:						Optional[int]					,						_snake_case		:						Tuple=7					,						_snake_case		:						int=3					,						_snake_case		:						int=18					,						_snake_case		:						Tuple=30					,						_snake_case		:						str=400					,						_snake_case		:						Tuple=True					,						_snake_case		:						Optional[Any]=None					,						_snake_case		:						Optional[Any]=True					,						_snake_case		:						Dict=None					,						_snake_case		:						List[Any]=True					,						):

        """simple docstring"""


        UpperCAmelCase_          =							size if size is not None else {'''shortest_edge''': 20}
        UpperCAmelCase_          =							crop_size if crop_size is not None else {'''height''': 18, '''width''': 18}
        UpperCAmelCase_          =							parent
        UpperCAmelCase_          =							batch_size
        UpperCAmelCase_          =							num_channels
        UpperCAmelCase_          =							image_size
        UpperCAmelCase_          =							min_resolution
        UpperCAmelCase_          =							max_resolution
        UpperCAmelCase_          =							do_resize
        UpperCAmelCase_          =							size
        UpperCAmelCase_          =							do_center_crop
        UpperCAmelCase_          =							crop_size
        UpperCAmelCase_          =							do_flip_channel_order







   def lowerCamelCase						(      self		:						Optional[int]):

        """simple docstring"""


        return {
            "do_resize": self.do_resize,
            "size": self.size,
            "do_center_crop": self.do_center_crop,
            "crop_size": self.crop_size,
            "do_flip_channel_order": self.do_flip_channel_order,
        }







@require_torch
@require_vision
class __snake_case			(			a ,  unittest.TestCase		):
   UpperCAmelCase__  :    Tuple          =  MobileViTImageProcessor if is_vision_available() else None







   def lowerCamelCase						(      self		:						Union[str, Any]):

        """simple docstring"""


        UpperCAmelCase_          =							MobileViTImageProcessingTester(self)







   @property
   def lowerCamelCase						(      self		:						Optional[Any]):

        """simple docstring"""


        return self.image_processor_tester.prepare_image_processor_dict()







   def lowerCamelCase						(      self		:						int):

        """simple docstring"""


        UpperCAmelCase_          =							self.image_processing_class(**self.image_processor_dict)
        self.assertTrue(hasattr(_snake_case					,						'''do_resize'''))
        self.assertTrue(hasattr(_snake_case					,						'''size'''))
        self.assertTrue(hasattr(_snake_case					,						'''do_center_crop'''))
        self.assertTrue(hasattr(_snake_case					,						'''center_crop'''))
        self.assertTrue(hasattr(_snake_case					,						'''do_flip_channel_order'''))







   def lowerCamelCase						(      self		:						Union[str, Any]):

        """simple docstring"""


        UpperCAmelCase_          =							self.image_processing_class.from_dict(self.image_processor_dict)
        self.assertEqual(image_processor.size					,						{'''shortest_edge''': 20})
        self.assertEqual(image_processor.crop_size					,						{'''height''': 18, '''width''': 18})

        UpperCAmelCase_          =							self.image_processing_class.from_dict(self.image_processor_dict					,						size=42					,						crop_size=84)
        self.assertEqual(image_processor.size					,						{'''shortest_edge''': 42})
        self.assertEqual(image_processor.crop_size					,						{'''height''': 84, '''width''': 84})







   def lowerCamelCase						(      self		:						Dict):

        """simple docstring"""


        pass







   def lowerCamelCase						(      self		:						Optional[Any]):

        """simple docstring"""


        UpperCAmelCase_          =							self.image_processing_class(**self.image_processor_dict)
        # create random PIL images
        UpperCAmelCase_          =							prepare_image_inputs(self.image_processor_tester					,						equal_resolution=_snake_case)
        for image in image_inputs:
             self.assertIsInstance(_snake_case					,						Image.Image)

        # Test not batched input
        UpperCAmelCase_          =							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
        UpperCAmelCase_          =							image_processing(_snake_case					,						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 lowerCamelCase						(      self		:						Optional[int]):

        """simple docstring"""


        UpperCAmelCase_          =							self.image_processing_class(**self.image_processor_dict)
        # create random numpy tensors
        UpperCAmelCase_          =							prepare_image_inputs(self.image_processor_tester					,						equal_resolution=_snake_case					,						numpify=_snake_case)
        for image in image_inputs:
             self.assertIsInstance(_snake_case					,						np.ndarray)

        # Test not batched input
        UpperCAmelCase_          =							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
        UpperCAmelCase_          =							image_processing(_snake_case					,						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 lowerCamelCase						(      self		:						List[Any]):

        """simple docstring"""


        UpperCAmelCase_          =							self.image_processing_class(**self.image_processor_dict)
        # create random PyTorch tensors
        UpperCAmelCase_          =							prepare_image_inputs(self.image_processor_tester					,						equal_resolution=_snake_case					,						torchify=_snake_case)
        for image in image_inputs:
             self.assertIsInstance(_snake_case					,						torch.Tensor)

        # Test not batched input
        UpperCAmelCase_          =							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
        UpperCAmelCase_          =							image_processing(_snake_case					,						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'''],
            )					,						)












from datetime import datetime

import requests


def    A						(__A   :    str       )   ->      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(__A       ).content


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






