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_video_inputs


if is_torch_available():
		import torch

if is_vision_available():
		from PIL import Image

		from transformers import VivitImageProcessor






class 		a__						(					unittest.TestCase					):

					def __init__(    self      :       List[Any],_A      :       Any,_A      :       Union[str, Any]=7,_A      :       Optional[Any]=3,_A      :       Optional[int]=10,_A      :       Optional[int]=18,_A      :       Optional[Any]=30,_A      :       Optional[Any]=400,_A      :       int=True,_A      :       Dict=None,_A      :       Any=True,_A      :       List[Any]=[0.5, 0.5, 0.5],_A      :       Any=[0.5, 0.5, 0.5],_A      :       str=None,):







							"""simple docstring"""






							SCREAMING_SNAKE_CASE_  :		List[Any]				      =    size if size is not None else {"shortest_edge": 18}
							SCREAMING_SNAKE_CASE_  :		str				      =    crop_size if crop_size is not None else {"height": 18, "width": 18}

							SCREAMING_SNAKE_CASE_  :		List[Any]				      =    parent
							SCREAMING_SNAKE_CASE_  :		Union[str, Any]				      =    batch_size
							SCREAMING_SNAKE_CASE_  :		Any				      =    num_channels
							SCREAMING_SNAKE_CASE_  :		Any				      =    num_frames
							SCREAMING_SNAKE_CASE_  :		Tuple				      =    image_size
							SCREAMING_SNAKE_CASE_  :		Any				      =    min_resolution
							SCREAMING_SNAKE_CASE_  :		Dict				      =    max_resolution
							SCREAMING_SNAKE_CASE_  :		Union[str, Any]				      =    do_resize
							SCREAMING_SNAKE_CASE_  :		int				      =    size
							SCREAMING_SNAKE_CASE_  :		Dict				      =    do_normalize
							SCREAMING_SNAKE_CASE_  :		Optional[Any]				      =    image_mean
							SCREAMING_SNAKE_CASE_  :		Tuple				      =    image_std
							SCREAMING_SNAKE_CASE_  :		List[str]				      =    crop_size






					def 				__UpperCamelCase   (    self      :       Optional[Any]    ):







							"""simple docstring"""






							return {
							    "image_mean": self.image_mean,
							    "image_std": self.image_std,
							    "do_normalize": self.do_normalize,
							    "do_resize": self.do_resize,
							    "size": self.size,
							    "crop_size": self.crop_size,
							}







@require_torch
@require_vision
class 		a__						(					A__    ,		unittest.TestCase					):
					A	       =							VivitImageProcessor if is_vision_available() else None

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







							"""simple docstring"""






							SCREAMING_SNAKE_CASE_  :		str				      =    VivitImageProcessingTester(self    )

					@property
					def 				__UpperCamelCase   (    self      :       Union[str, Any]    ):







							"""simple docstring"""






							return self.image_processor_tester.prepare_image_processor_dict()

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







							"""simple docstring"""






							SCREAMING_SNAKE_CASE_  :		Optional[Any]				      =    self.image_processing_class(**self.image_processor_dict    )
							self.assertTrue(hasattr(_A,"image_mean"    )    )
							self.assertTrue(hasattr(_A,"image_std"    )    )
							self.assertTrue(hasattr(_A,"do_normalize"    )    )
							self.assertTrue(hasattr(_A,"do_resize"    )    )
							self.assertTrue(hasattr(_A,"do_center_crop"    )    )
							self.assertTrue(hasattr(_A,"size"    )    )

					def 				__UpperCamelCase   (    self      :       str    ):







							"""simple docstring"""






							SCREAMING_SNAKE_CASE_  :		Dict				      =    self.image_processing_class.from_dict(self.image_processor_dict    )
							self.assertEqual(image_processor.size,{"shortest_edge": 18}    )
							self.assertEqual(image_processor.crop_size,{"height": 18, "width": 18}    )

							SCREAMING_SNAKE_CASE_  :		List[Any]				      =    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 				__UpperCamelCase   (    self      :       Dict    ):







							"""simple docstring"""






							SCREAMING_SNAKE_CASE_  :		List[str]				      =    self.image_processing_class(**self.image_processor_dict    )
							# create random PIL videos
							SCREAMING_SNAKE_CASE_  :		List[str]				      =    prepare_video_inputs(self.image_processor_tester,equal_resolution=_A    )
							for video in video_inputs:
									self.assertIsInstance(_A,_A    )
									self.assertIsInstance(video[0],Image.Image    )

							# Test not batched input
							SCREAMING_SNAKE_CASE_  :		int				      =    image_processing(video_inputs[0],return_tensors="pt"    ).pixel_values
							self.assertEqual(
							    encoded_videos.shape,(
							        1,
							        self.image_processor_tester.num_frames,
							        self.image_processor_tester.num_channels,
							        self.image_processor_tester.crop_size["height"],
							        self.image_processor_tester.crop_size["width"],
							    ),)

							# Test batched
							SCREAMING_SNAKE_CASE_  :		Tuple				      =    image_processing(_A,return_tensors="pt"    ).pixel_values
							self.assertEqual(
							    encoded_videos.shape,(
							        self.image_processor_tester.batch_size,
							        self.image_processor_tester.num_frames,
							        self.image_processor_tester.num_channels,
							        self.image_processor_tester.crop_size["height"],
							        self.image_processor_tester.crop_size["width"],
							    ),)

					def 				__UpperCamelCase   (    self      :       Optional[Any]    ):







							"""simple docstring"""






							SCREAMING_SNAKE_CASE_  :		List[str]				      =    self.image_processing_class(**self.image_processor_dict    )
							# create random numpy tensors
							SCREAMING_SNAKE_CASE_  :		str				      =    prepare_video_inputs(self.image_processor_tester,equal_resolution=_A,numpify=_A    )
							for video in video_inputs:
									self.assertIsInstance(_A,_A    )
									self.assertIsInstance(video[0],np.ndarray    )

							# Test not batched input
							SCREAMING_SNAKE_CASE_  :		Optional[int]				      =    image_processing(video_inputs[0],return_tensors="pt"    ).pixel_values
							self.assertEqual(
							    encoded_videos.shape,(
							        1,
							        self.image_processor_tester.num_frames,
							        self.image_processor_tester.num_channels,
							        self.image_processor_tester.crop_size["height"],
							        self.image_processor_tester.crop_size["width"],
							    ),)

							# Test batched
							SCREAMING_SNAKE_CASE_  :		List[str]				      =    image_processing(_A,return_tensors="pt"    ).pixel_values
							self.assertEqual(
							    encoded_videos.shape,(
							        self.image_processor_tester.batch_size,
							        self.image_processor_tester.num_frames,
							        self.image_processor_tester.num_channels,
							        self.image_processor_tester.crop_size["height"],
							        self.image_processor_tester.crop_size["width"],
							    ),)






					def 				__UpperCamelCase   (    self      :       Tuple    ):







							"""simple docstring"""






							SCREAMING_SNAKE_CASE_  :		List[str]				      =    self.image_processing_class(**self.image_processor_dict    )
							# create random PyTorch tensors
							SCREAMING_SNAKE_CASE_  :		Dict				      =    prepare_video_inputs(self.image_processor_tester,equal_resolution=_A,torchify=_A    )
							for video in video_inputs:
									self.assertIsInstance(_A,_A    )
									self.assertIsInstance(video[0],torch.Tensor    )

							# Test not batched input
							SCREAMING_SNAKE_CASE_  :		List[str]				      =    image_processing(video_inputs[0],return_tensors="pt"    ).pixel_values
							self.assertEqual(
							    encoded_videos.shape,(
							        1,
							        self.image_processor_tester.num_frames,
							        self.image_processor_tester.num_channels,
							        self.image_processor_tester.crop_size["height"],
							        self.image_processor_tester.crop_size["width"],
							    ),)

							# Test batched
							SCREAMING_SNAKE_CASE_  :		Optional[int]				      =    image_processing(_A,return_tensors="pt"    ).pixel_values
							self.assertEqual(
							    encoded_videos.shape,(
							        self.image_processor_tester.batch_size,
							        self.image_processor_tester.num_frames,
							        self.image_processor_tester.num_channels,
							        self.image_processor_tester.crop_size["height"],
							        self.image_processor_tester.crop_size["width"],
							    ),)




# flake8: noqa
# Lint as: python3
UpperCAmelCase__   	=							[
    '''VerificationMode''',
    '''Version''',
    '''disable_progress_bar''',
    '''enable_progress_bar''',
    '''is_progress_bar_enabled''',
    '''experimental''',
]

from .info_utils import VerificationMode
from .logging import disable_progress_bar, enable_progress_bar, is_progress_bar_enabled
from .version import Version
from .experimental import experimental

