




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 	A	(						unittest.TestCase						):
     """simple docstring"""

     def __init__(			self     :      List[str]		,     A__     :      Any		,     A__     :      List[str]=7		,     A__     :      Tuple=3		,     A__     :      List[Any]=1_0		,     A__     :      int=1_8		,     A__     :      Any=3_0		,     A__     :      List[Any]=4_0_0		,     A__     :      Union[str, Any]=True		,     A__     :      str=None		,     A__     :      List[Any]=True		,     A__     :      Union[str, Any]=[0.5, 0.5, 0.5]		,     A__     :      List[Any]=[0.5, 0.5, 0.5]		,     A__     :      Dict=None		,     ) ->				Tuple:
           lowerCamelCase__					     = size if size is not None else {'shortest_edge': 1_8}
           lowerCamelCase__					     = crop_size if crop_size is not None else {'height': 1_8, 'width': 1_8}

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




     def        __snake_case      (			self     :      Any	) ->				str:
           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	(						_lowerCAmelCase	,  unittest.TestCase						):
     """simple docstring"""

     _snake_case:		List[Any]   =VideoMAEImageProcessor if is_vision_available() else None




     def        __snake_case      (			self     :      Union[str, Any]	) ->				Union[str, Any]:
           lowerCamelCase__					     = VideoMAEImageProcessingTester(self	)




     @property
     def        __snake_case      (			self     :      int	) ->				Dict:
           return self.image_processor_tester.prepare_image_processor_dict()




     def        __snake_case      (			self     :      str	) ->				int:
           lowerCamelCase__					     = 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        __snake_case      (			self     :      int	) ->				Union[str, Any]:
           lowerCamelCase__					     = self.image_processing_class.from_dict(self.image_processor_dict	)
           self.assertEqual(image_processor.size		,     {'shortest_edge': 1_8}	)
           self.assertEqual(image_processor.crop_size		,     {'height': 1_8, 'width': 1_8}	)

           lowerCamelCase__					     = self.image_processing_class.from_dict(self.image_processor_dict		,     size=4_2		,     crop_size=8_4	)
           self.assertEqual(image_processor.size		,     {'shortest_edge': 4_2}	)
           self.assertEqual(image_processor.crop_size		,     {'height': 8_4, 'width': 8_4}	)




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




     def        __snake_case      (			self     :      Union[str, Any]	) ->				Dict:
           # Initialize image_processing
           lowerCamelCase__					     = self.image_processing_class(**self.image_processor_dict	)
           # create random PIL videos
           lowerCamelCase__					     = 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
           lowerCamelCase__					     = 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
           lowerCamelCase__					     = 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        __snake_case      (			self     :      Tuple	) ->				Union[str, Any]:
           # Initialize image_processing
           lowerCamelCase__					     = self.image_processing_class(**self.image_processor_dict	)
           # create random numpy tensors
           lowerCamelCase__					     = 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
           lowerCamelCase__					     = 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
           lowerCamelCase__					     = 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        __snake_case      (			self     :      Optional[int]	) ->				Optional[int]:
           # Initialize image_processing
           lowerCamelCase__					     = self.image_processing_class(**self.image_processor_dict	)
           # create random PyTorch tensors
           lowerCamelCase__					     = 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
           lowerCamelCase__					     = 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
           lowerCamelCase__					     = 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'],
               )		,     )


from math import sqrt





def 	snake_case_      (__A     :						int     )			->	list[int]:
   __lowerCAmelCase  :			List[str]					    =						[1]
   for i in range(2					,   int(sqrt(__A     )     ) + 1					,   1     ):
      if number % i == 0:
         values.append(__A     )
         if int(number // i     ) != i:
            values.append(int(number // i     )     )
   return sorted(__A     )





def 	snake_case_      (__A     :						int     )			->	bool:
   return sum(factors(__A     )     ) > n





def 	snake_case_      (__A     :						int     )			->	bool:
   __lowerCAmelCase  :			Any					    =						factors(__A     )
   __lowerCAmelCase  :			Union[str, Any]					    =						len(__A     )
   __lowerCAmelCase  :			str					    =						[[0 for i in range(number + 1     )] for j in range(r + 1     )]
   for i in range(r + 1     ):
      __lowerCAmelCase  :			Tuple					    =						True

   for i in range(1					,   number + 1     ):
      __lowerCAmelCase  :			List[str]					    =						False

   for i in range(1					,   r + 1     ):
      for j in range(1					,   number + 1     ):
         if j < values[i - 1]:
            __lowerCAmelCase  :			Dict					    =						subset[i - 1][j]
         else:
            __lowerCAmelCase  :			Dict					    =						subset[i - 1][j] or subset[i - 1][j - values[i - 1]]

   return subset[r][number] != 0





def 	snake_case_      (__A     :						int     )			->	bool:
   return abundant(__A     ) and not semi_perfect(__A     )


if __name__ == "__main__":
   import doctest

   doctest.testmod(verbose=True)
   for number in (69, 70, 71):
      print(F'{number} is {"" if weird(number) else "not "}weird.')


