
"""simple docstring"""

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 __lowerCAmelCase		(				unittest.TestCase      ):





     def __init__(     self     ,					__UpperCAmelCase     ,					__UpperCAmelCase=7     ,					__UpperCAmelCase=3     ,					__UpperCAmelCase=10     ,					__UpperCAmelCase=18     ,					__UpperCAmelCase=30     ,					__UpperCAmelCase=400     ,					__UpperCAmelCase=True     ,					__UpperCAmelCase=None     ,					__UpperCAmelCase=True     ,					__UpperCAmelCase=[0.5, 0.5, 0.5]     ,					__UpperCAmelCase=[0.5, 0.5, 0.5]     ,					__UpperCAmelCase=None     ,					):

      '''simple docstring'''




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

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







     def 						UpperCAmelCase (     self				):

      '''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 __lowerCAmelCase		(				__SCREAMING_SNAKE_CASE      ,  unittest.TestCase      ):
     lowercase						       =						VivitImageProcessor if is_vision_available() else None





     def 						UpperCAmelCase (     self				):

      '''simple docstring'''




      __UpperCamelCase      =	VivitImageProcessingTester(self				)





     @property
     def 						UpperCAmelCase (     self				):

      '''simple docstring'''




      return self.image_processor_tester.prepare_image_processor_dict()





     def 						UpperCAmelCase (     self				):

      '''simple docstring'''




      __UpperCamelCase      =	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 						UpperCAmelCase (     self				):

      '''simple docstring'''




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

      __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 						UpperCAmelCase (     self				):

      '''simple docstring'''




      __UpperCamelCase      =	self.image_processing_class(**self.image_processor_dict				)
      # create random PIL videos
      __UpperCamelCase      =	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
      __UpperCamelCase      =	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
      __UpperCamelCase      =	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 						UpperCAmelCase (     self				):

      '''simple docstring'''




      __UpperCamelCase      =	self.image_processing_class(**self.image_processor_dict				)
      # create random numpy tensors
      __UpperCamelCase      =	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
      __UpperCamelCase      =	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
      __UpperCamelCase      =	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 						UpperCAmelCase (     self				):

      '''simple docstring'''




      __UpperCamelCase      =	self.image_processing_class(**self.image_processor_dict				)
      # create random PyTorch tensors
      __UpperCamelCase      =	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
      __UpperCamelCase      =	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
      __UpperCamelCase      =	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'],
          )     ,					)





"""simple docstring"""

def 							A						(    snake_case				:int		)				->     bool:
 return sum(i for i in range(1    , number // 2 + 1		) if number % i == 0		) == number


if __name__ == "__main__":
      print("Program to check whether a number is a Perfect number or not...")
      UpperCamelCase     :    Union[str, Any]       =			int(input("Enter number: ").strip())
      print(f'''{number} is {"" if perfect(number) else "not "}a Perfect Number.''')



