"""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


if is_torch_available():
    import torch

if is_vision_available():
    from PIL import Image

    from transformers import CLIPImageProcessor




class 				UpperCamelCase      (       unittest.TestCase     ):







       def __init__(				self,							lowerCAmelCase__,							lowerCAmelCase__=7,							lowerCAmelCase__=3,							lowerCAmelCase__=18,							lowerCAmelCase__=30,							lowerCAmelCase__=400,							lowerCAmelCase__=True,							lowerCAmelCase__=None,							lowerCAmelCase__=True,							lowerCAmelCase__=None,							lowerCAmelCase__=True,							lowerCAmelCase__=[0.48145466, 0.4578275, 0.40821073],							lowerCAmelCase__=[0.26862954, 0.26130258, 0.27577711],							lowerCAmelCase__=True,							)   ->   Any:
            snake_case_       =      size if size is not None else {'''shortest_edge''': 20}
            snake_case_       =      crop_size if crop_size is not None else {'''height''': 18, '''width''': 18}
            snake_case_       =      parent
            snake_case_       =      batch_size
            snake_case_       =      num_channels
            snake_case_       =      image_size
            snake_case_       =      min_resolution
            snake_case_       =      max_resolution
            snake_case_       =      do_resize
            snake_case_       =      size
            snake_case_       =      do_center_crop
            snake_case_       =      crop_size
            snake_case_       =      do_normalize
            snake_case_       =      image_mean
            snake_case_       =      image_std
            snake_case_       =      do_convert_rgb







       def 	a_		(				self)   ->   int:
            return {
                "do_resize": self.do_resize,
                "size": self.size,
                "do_center_crop": self.do_center_crop,
                "crop_size": self.crop_size,
                "do_normalize": self.do_normalize,
                "image_mean": self.image_mean,
                "image_std": self.image_std,
                "do_convert_rgb": self.do_convert_rgb,
            }







       def 	a_		(				self,							lowerCAmelCase__=False,							lowerCAmelCase__=False,							lowerCAmelCase__=False)   ->   Optional[int]:
            assert not (numpify and torchify), "You cannot specify both numpy and PyTorch tensors at the same time"

            if equal_resolution:
                 snake_case_       =      []
                 for i in range(self.batch_size):
                      image_inputs.append(
                          np.random.randint(
                              255,							size=(self.num_channels, self.max_resolution, self.max_resolution),							dtype=np.uinta))
            else:
                 snake_case_       =      []
                 for i in range(self.batch_size):
                      snake_case_       =      np.random.choice(np.arange(self.min_resolution,							self.max_resolution),							2)
                      image_inputs.append(np.random.randint(255,							size=(self.num_channels, width, height),							dtype=np.uinta))

            if not numpify and not torchify:
                 # PIL expects the channel dimension as last dimension
                 snake_case_       =      [Image.fromarray(np.moveaxis(lowercase_,							0,							-1)) for x in image_inputs]

            if torchify:
                 snake_case_       =      [torch.from_numpy(lowercase_) for x in image_inputs]

            return image_inputs




@require_torch
@require_vision
class 				UpperCamelCase      (       __UpperCAmelCase					,	unittest.TestCase     ):
       SCREAMING_SNAKE_CASE_				=   CLIPImageProcessor if is_vision_available() else None







       def 	a_		(				self)   ->   int:
            snake_case_       =      CLIPImageProcessingTester(self)







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







       def 	a_		(				self)   ->   Tuple:
            snake_case_       =      self.image_processing_class(**self.image_processor_dict)
            self.assertTrue(hasattr(lowercase_,							'do_resize'))
            self.assertTrue(hasattr(lowercase_,							'size'))
            self.assertTrue(hasattr(lowercase_,							'do_center_crop'))
            self.assertTrue(hasattr(lowercase_,							'center_crop'))
            self.assertTrue(hasattr(lowercase_,							'do_normalize'))
            self.assertTrue(hasattr(lowercase_,							'image_mean'))
            self.assertTrue(hasattr(lowercase_,							'image_std'))
            self.assertTrue(hasattr(lowercase_,							'do_convert_rgb'))







       def 	a_		(				self)   ->   Any:
            snake_case_       =      self.image_processing_class.from_dict(self.image_processor_dict)
            self.assertEqual(image_processor.size,							{'shortest_edge': 20})
            self.assertEqual(image_processor.crop_size,							{'height': 18, 'width': 18})

            snake_case_       =      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 	a_		(				self)   ->   Optional[int]:
            pass







       def 	a_		(				self)   ->   str:
            snake_case_       =      self.image_processing_class(**self.image_processor_dict)
            # create random PIL images
            snake_case_       =      self.image_processor_tester.prepare_inputs(equal_resolution=lowercase_)
            for image in image_inputs:
                 self.assertIsInstance(lowercase_,							Image.Image)

            # Test not batched input
            snake_case_       =      image_processing(image_inputs[0],							return_tensors='pt').pixel_values
            self.assertEqual(
                encoded_images.shape,							(
                    1,
                    self.image_processor_tester.num_channels,
                    self.image_processor_tester.crop_size['height'],
                    self.image_processor_tester.crop_size['width'],
                ),							)

            # Test batched
            snake_case_       =      image_processing(lowercase_,							return_tensors='pt').pixel_values
            self.assertEqual(
                encoded_images.shape,							(
                    self.image_processor_tester.batch_size,
                    self.image_processor_tester.num_channels,
                    self.image_processor_tester.crop_size['height'],
                    self.image_processor_tester.crop_size['width'],
                ),							)







       def 	a_		(				self)   ->   Tuple:
            snake_case_       =      self.image_processing_class(**self.image_processor_dict)
            # create random numpy tensors
            snake_case_       =      self.image_processor_tester.prepare_inputs(equal_resolution=lowercase_,							numpify=lowercase_)
            for image in image_inputs:
                 self.assertIsInstance(lowercase_,							np.ndarray)

            # Test not batched input
            snake_case_       =      image_processing(image_inputs[0],							return_tensors='pt').pixel_values
            self.assertEqual(
                encoded_images.shape,							(
                    1,
                    self.image_processor_tester.num_channels,
                    self.image_processor_tester.crop_size['height'],
                    self.image_processor_tester.crop_size['width'],
                ),							)

            # Test batched
            snake_case_       =      image_processing(lowercase_,							return_tensors='pt').pixel_values
            self.assertEqual(
                encoded_images.shape,							(
                    self.image_processor_tester.batch_size,
                    self.image_processor_tester.num_channels,
                    self.image_processor_tester.crop_size['height'],
                    self.image_processor_tester.crop_size['width'],
                ),							)







       def 	a_		(				self)   ->   List[str]:
            snake_case_       =      self.image_processing_class(**self.image_processor_dict)
            # create random PyTorch tensors
            snake_case_       =      self.image_processor_tester.prepare_inputs(equal_resolution=lowercase_,							torchify=lowercase_)
            for image in image_inputs:
                 self.assertIsInstance(lowercase_,							torch.Tensor)

            # Test not batched input
            snake_case_       =      image_processing(image_inputs[0],							return_tensors='pt').pixel_values
            self.assertEqual(
                encoded_images.shape,							(
                    1,
                    self.image_processor_tester.num_channels,
                    self.image_processor_tester.crop_size['height'],
                    self.image_processor_tester.crop_size['width'],
                ),							)

            # Test batched
            snake_case_       =      image_processing(lowercase_,							return_tensors='pt').pixel_values
            self.assertEqual(
                encoded_images.shape,							(
                    self.image_processor_tester.batch_size,
                    self.image_processor_tester.num_channels,
                    self.image_processor_tester.crop_size['height'],
                    self.image_processor_tester.crop_size['width'],
                ),							)




@require_torch
@require_vision
class 				UpperCamelCase      (       __UpperCAmelCase					,	unittest.TestCase     ):
       SCREAMING_SNAKE_CASE_				=   CLIPImageProcessor if is_vision_available() else None







       def 	a_		(				self)   ->   Dict:
            snake_case_       =      CLIPImageProcessingTester(self,							num_channels=4)
            snake_case_       =      3







       @property
       def 	a_		(				self)   ->   Tuple:
            return self.image_processor_tester.prepare_image_processor_dict()







       def 	a_		(				self)   ->   Optional[Any]:
            snake_case_       =      self.image_processing_class(**self.image_processor_dict)
            self.assertTrue(hasattr(lowercase_,							'do_resize'))
            self.assertTrue(hasattr(lowercase_,							'size'))
            self.assertTrue(hasattr(lowercase_,							'do_center_crop'))
            self.assertTrue(hasattr(lowercase_,							'center_crop'))
            self.assertTrue(hasattr(lowercase_,							'do_normalize'))
            self.assertTrue(hasattr(lowercase_,							'image_mean'))
            self.assertTrue(hasattr(lowercase_,							'image_std'))
            self.assertTrue(hasattr(lowercase_,							'do_convert_rgb'))







       def 	a_		(				self)   ->   Dict:
            pass







       def 	a_		(				self)   ->   List[Any]:
            snake_case_       =      self.image_processing_class(**self.image_processor_dict)
            # create random PIL images
            snake_case_       =      self.image_processor_tester.prepare_inputs(equal_resolution=lowercase_)
            for image in image_inputs:
                 self.assertIsInstance(lowercase_,							Image.Image)

            # Test not batched input
            snake_case_       =      image_processing(image_inputs[0],							return_tensors='pt').pixel_values
            self.assertEqual(
                encoded_images.shape,							(
                    1,
                    self.expected_encoded_image_num_channels,
                    self.image_processor_tester.crop_size['height'],
                    self.image_processor_tester.crop_size['width'],
                ),							)

            # Test batched
            snake_case_       =      image_processing(lowercase_,							return_tensors='pt').pixel_values
            self.assertEqual(
                encoded_images.shape,							(
                    self.image_processor_tester.batch_size,
                    self.expected_encoded_image_num_channels,
                    self.image_processor_tester.crop_size['height'],
                    self.image_processor_tester.crop_size['width'],
                ),							)


"""simple docstring"""


import math







def       UpperCAmelCase					(	UpperCAmelCase      )       ->   float:
     snake_case_       =      math.log(2		,      10      ) * number
     snake_case_       =      round((log_number - int(UpperCAmelCase      ))		,      15      )

     return difference







def       UpperCAmelCase					(	UpperCAmelCase = 678910      )       ->   int:
     snake_case_       =      90
     snake_case_       =      0

     snake_case_       =      math.log(1.23		,      10      )
     snake_case_       =      math.log(1.24		,      10      )
     snake_case_       =      0

     while position < number:
          snake_case_       =      log_difference(UpperCAmelCase      )

          if difference >= upper_limit:
               power_iterator += 93

          elif difference < lower_limit:
               power_iterator += 196

          else:
               snake_case_       =      power_iterator
               power_iterator += 196
               position += 1

     return previous_power


if __name__ == "__main__":
    import doctest

    doctest.testmod()

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

