






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 VideoMAEImageProcessor


class  __lowercase (		unittest.TestCase					):







     '''simple docstring'''




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


         """simple docstring"""



         __A             =		size if size is not None else {"""shortest_edge""": 18}
         __A             =		crop_size if crop_size is not None else {"""height""": 18, """width""": 18}

         __A             =		parent
         __A             =		batch_size
         __A             =		num_channels
         __A             =		num_frames
         __A             =		image_size
         __A             =		min_resolution
         __A             =		max_resolution
         __A             =		do_resize
         __A             =		size
         __A             =		do_normalize
         __A             =		image_mean
         __A             =		image_std
         __A             =		crop_size





     def 						lowerCAmelCase_       (			self    :     List[str]			):


         """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  __lowercase (		lowercase_     , unittest.TestCase					):







     '''simple docstring'''
     SCREAMING_SNAKE_CASE				  =			VideoMAEImageProcessor if is_vision_available() else None




     def 						lowerCAmelCase_       (			self    :     str			):


         """simple docstring"""



         __A             =		VideoMAEImageProcessingTester(self			)




     @property
     def 						lowerCAmelCase_       (			self    :     Tuple			):


         """simple docstring"""



         return self.image_processor_tester.prepare_image_processor_dict()




     def 						lowerCAmelCase_       (			self    :     List[Any]			):


         """simple docstring"""



         __A             =		self.image_processing_class(**self.image_processor_dict			)
         self.assertTrue(hasattr(UpperCamelCase_	,		"""image_mean"""			)			)
         self.assertTrue(hasattr(UpperCamelCase_	,		"""image_std"""			)			)
         self.assertTrue(hasattr(UpperCamelCase_	,		"""do_normalize"""			)			)
         self.assertTrue(hasattr(UpperCamelCase_	,		"""do_resize"""			)			)
         self.assertTrue(hasattr(UpperCamelCase_	,		"""do_center_crop"""			)			)
         self.assertTrue(hasattr(UpperCamelCase_	,		"""size"""			)			)




     def 						lowerCAmelCase_       (			self    :     int			):


         """simple docstring"""



         __A             =		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}			)

         __A             =		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    :     List[str]			):


         """simple docstring"""



         pass




     def 						lowerCAmelCase_       (			self    :     Any			):


         """simple docstring"""



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

         # Test not batched input
         __A             =		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
         __A             =		image_processing(UpperCamelCase_	,		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 						lowerCAmelCase_       (			self    :     Tuple			):


         """simple docstring"""



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

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


         """simple docstring"""



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

         # Test not batched input
         __A             =		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
         __A             =		image_processing(UpperCamelCase_	,		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      _SCREAMING_SNAKE_CASE  (	__lowercase				:     int     ,			__lowercase				:     int      )  -> int:





    """simple docstring"""

    __A             =		1.0
    for i in range(1     ,			r + 1      ):
        ret *= (n + 1 - i) / i
    return round(__lowercase      )



def      _SCREAMING_SNAKE_CASE  (	__lowercase				:     int      )  -> int:





    """simple docstring"""

    return choose(8 + n     ,			__lowercase      ) + choose(9 + n     ,			__lowercase      ) - 1_0



def      _SCREAMING_SNAKE_CASE  (	__lowercase				:     int      )  -> int:





    """simple docstring"""

    return sum(non_bouncy_exact(__lowercase      ) for i in range(1     ,			n + 1      )      )



def      _SCREAMING_SNAKE_CASE  (	__lowercase				:     int = 1_0_0      )  -> int:





    """simple docstring"""

    return non_bouncy_upto(__lowercase      )


if __name__ == "__main__":
  print(f"""{solution() = }""")




