


'''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 VideoMAEImageProcessor







class 					_A						(						unittest.TestCase							):



   '''simple docstring'''






   def __init__(	self	:					List[str]					, lowerCamelCase	:					Optional[Any]					, lowerCamelCase	:					Optional[Any]=7					, lowerCamelCase	:					Any=3					, lowerCamelCase	:					Any=10					, lowerCamelCase	:					str=18					, lowerCamelCase	:					List[Any]=30					, lowerCamelCase	:					Optional[int]=400					, lowerCamelCase	:					Tuple=True					, lowerCamelCase	:					Tuple=None					, lowerCamelCase	:					Union[str, Any]=True					, lowerCamelCase	:					List[str]=[0.5, 0.5, 0.5]					, lowerCamelCase	:					Any=[0.5, 0.5, 0.5]					, lowerCamelCase	:					Optional[int]=None					, )->	List[Any]:
          snake_case__					:	int          =					size if size is not None else {"""shortest_edge""": 18}
          snake_case__					:	Optional[int]          =					crop_size if crop_size is not None else {"""height""": 18, """width""": 18}

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




   def   __lowerCAmelCase						(	self	:					List[Any]						)->	List[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						(						UpperCamelCase    ,  unittest.TestCase							):



   '''simple docstring'''






   _lowercase    						= VideoMAEImageProcessor if is_vision_available() else None




   def   __lowerCAmelCase						(	self	:					Any						)->	Union[str, Any]:
          snake_case__					:	Union[str, Any]          =					VideoMAEImageProcessingTester(self						)




   @property
   def   __lowerCAmelCase						(	self	:					List[Any]						)->	List[Any]:
          return self.image_processor_tester.prepare_image_processor_dict()




   def   __lowerCAmelCase						(	self	:					str						)->	Union[str, Any]:
          snake_case__					:	Union[str, Any]          =					self.image_processing_class(**self.image_processor_dict						)
          self.assertTrue(hasattr(lowerCamelCase					, """image_mean"""						)						)
          self.assertTrue(hasattr(lowerCamelCase					, """image_std"""						)						)
          self.assertTrue(hasattr(lowerCamelCase					, """do_normalize"""						)						)
          self.assertTrue(hasattr(lowerCamelCase					, """do_resize"""						)						)
          self.assertTrue(hasattr(lowerCamelCase					, """do_center_crop"""						)						)
          self.assertTrue(hasattr(lowerCamelCase					, """size"""						)						)




   def   __lowerCAmelCase						(	self	:					Dict						)->	Tuple:
          snake_case__					:	str          =					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}						)

          snake_case__					:	Optional[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   __lowerCAmelCase						(	self	:					str						)->	Dict:
          pass




   def   __lowerCAmelCase						(	self	:					Tuple						)->	Tuple:
          # Initialize image_processing
          snake_case__					:	Optional[int]          =					self.image_processing_class(**self.image_processor_dict						)
          # create random PIL videos
          snake_case__					:	Dict          =					prepare_video_inputs(self.image_processor_tester					, equal_resolution=lowerCamelCase						)
          for video in video_inputs:
                 self.assertIsInstance(lowerCamelCase					, lowerCamelCase						)
                 self.assertIsInstance(video[0]					, Image.Image						)

          # Test not batched input
          snake_case__					:	Optional[Any]          =					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
          snake_case__					:	List[Any]          =					image_processing(lowerCamelCase					, 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	:					Dict						)->	Tuple:
          # Initialize image_processing
          snake_case__					:	List[str]          =					self.image_processing_class(**self.image_processor_dict						)
          # create random numpy tensors
          snake_case__					:	Tuple          =					prepare_video_inputs(self.image_processor_tester					, equal_resolution=lowerCamelCase					, numpify=lowerCamelCase						)
          for video in video_inputs:
                 self.assertIsInstance(lowerCamelCase					, lowerCamelCase						)
                 self.assertIsInstance(video[0]					, np.ndarray						)

          # Test not batched input
          snake_case__					:	Dict          =					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
          snake_case__					:	Dict          =					image_processing(lowerCamelCase					, 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	:					Any						)->	str:
          # Initialize image_processing
          snake_case__					:	int          =					self.image_processing_class(**self.image_processor_dict						)
          # create random PyTorch tensors
          snake_case__					:	Any          =					prepare_video_inputs(self.image_processor_tester					, equal_resolution=lowerCamelCase					, torchify=lowerCamelCase						)
          for video in video_inputs:
                 self.assertIsInstance(lowerCamelCase					, lowerCamelCase						)
                 self.assertIsInstance(video[0]					, torch.Tensor						)

          # Test not batched input
          snake_case__					:	Optional[Any]          =					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
          snake_case__					:	Tuple          =					image_processing(lowerCamelCase					, 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'''
import math



def 				lowerCAmelCase__	(       UpperCAmelCase     ):






       """simple docstring"""





       snake_case__					:	Tuple          =					math.log(2    ,       10     ) * number
       snake_case__					:	int          =					round((log_number - int(UpperCAmelCase     ))    ,       15     )

       return difference



def 				lowerCAmelCase__	(       UpperCAmelCase = 67_8910     ):






       """simple docstring"""





       snake_case__					:	str          =					90
       snake_case__					:	Dict          =					0

       snake_case__					:	List[str]          =					math.log(1.2_3    ,       10     )
       snake_case__					:	Optional[Any]          =					math.log(1.2_4    ,       10     )
       snake_case__					:	Any          =					0

       while position < number:
              snake_case__					:	Tuple          =					log_difference(UpperCAmelCase     )

              if difference >= upper_limit:
                     power_iterator += 93

              elif difference < lower_limit:
                     power_iterator += 196

              else:
                     snake_case__					:	Union[str, Any]          =					power_iterator
                     power_iterator += 196
                     position += 1

       return previous_power


if __name__ == "__main__":
     import doctest

     doctest.testmod()

     print(f"""{solution() = }""")




