




'''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 SwinaSRImageProcessor
 from transformers.image_transforms import get_image_size







class 	lowercase_					(				unittest.TestCase     ):


   """simple docstring"""

   def __init__(					self      :			Any						,   __lowerCamelCase      :			List[str]						,   __lowerCamelCase      :			Optional[int]=7						,   __lowerCamelCase      :			Tuple=3						,   __lowerCamelCase      :			Optional[Any]=1_8						,   __lowerCamelCase      :			str=3_0						,   __lowerCamelCase      :			str=4_0_0						,   __lowerCamelCase      :			List[str]=True						,   __lowerCamelCase      :			Union[str, Any]=1 / 2_5_5						,   __lowerCamelCase      :			str=True						,   __lowerCamelCase      :			Optional[Any]=8						,   ):

      """simple docstring"""
      _SCREAMING_SNAKE_CASE =   parent
      _SCREAMING_SNAKE_CASE =   batch_size
      _SCREAMING_SNAKE_CASE =   num_channels
      _SCREAMING_SNAKE_CASE =   image_size
      _SCREAMING_SNAKE_CASE =   min_resolution
      _SCREAMING_SNAKE_CASE =   max_resolution
      _SCREAMING_SNAKE_CASE =   do_rescale
      _SCREAMING_SNAKE_CASE =   rescale_factor
      _SCREAMING_SNAKE_CASE =   do_pad
      _SCREAMING_SNAKE_CASE =   pad_size



   def 							lowerCAmelCase_    (					self      :			List[Any]					):

      """simple docstring"""
      return {
          "do_rescale": self.do_rescale,
          "rescale_factor": self.rescale_factor,
          "do_pad": self.do_pad,
          "pad_size": self.pad_size,
      }



   def 							lowerCAmelCase_    (					self      :			int						,   __lowerCamelCase      :			List[str]=False						,   __lowerCamelCase      :			List[Any]=False						,   __lowerCamelCase      :			Optional[Any]=False					):

      """simple docstring"""
      assert not (numpify and torchify), "You cannot specify both numpy and PyTorch tensors at the same time"

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

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

      if torchify:
         _SCREAMING_SNAKE_CASE =   [torch.from_numpy(__lowerCamelCase					) for x in image_inputs]

      return image_inputs







@require_torch
@require_vision
class 	lowercase_					(				A  ,						unittest.TestCase     ):


   """simple docstring"""

   lowerCamelCase_       						=		SwinaSRImageProcessor if is_vision_available() else None



   def 							lowerCAmelCase_    (					self      :			Union[str, Any]					):

      """simple docstring"""
      _SCREAMING_SNAKE_CASE =   SwinaSRImageProcessingTester(self					)



   @property
   def 							lowerCAmelCase_    (					self      :			str					):

      """simple docstring"""
      return self.image_processor_tester.prepare_image_processor_dict()



   def 							lowerCAmelCase_    (					self      :			Optional[int]					):

      """simple docstring"""
      _SCREAMING_SNAKE_CASE =   self.image_processing_class(**self.image_processor_dict					)
      self.assertTrue(hasattr(__lowerCamelCase						,   "do_rescale"					)					)
      self.assertTrue(hasattr(__lowerCamelCase						,   "rescale_factor"					)					)
      self.assertTrue(hasattr(__lowerCamelCase						,   "do_pad"					)					)
      self.assertTrue(hasattr(__lowerCamelCase						,   "pad_size"					)					)



   def 							lowerCAmelCase_    (					self      :			Optional[Any]					):

      """simple docstring"""
      pass



   def 							lowerCAmelCase_    (					self      :			List[Any]						,   __lowerCamelCase      :			Optional[int]					):

      """simple docstring"""
      _SCREAMING_SNAKE_CASE, _SCREAMING_SNAKE_CASE =   get_image_size(__lowerCamelCase					)
      _SCREAMING_SNAKE_CASE =   self.image_processor_tester.pad_size

      _SCREAMING_SNAKE_CASE =   (old_height // size + 1) * size - old_height
      _SCREAMING_SNAKE_CASE =   (old_width // size + 1) * size - old_width
      return old_height + pad_height, old_width + pad_width



   def 							lowerCAmelCase_    (					self      :			Optional[Any]					):

      """simple docstring"""
      # Initialize image_processor
      _SCREAMING_SNAKE_CASE =   self.image_processing_class(**self.image_processor_dict					)
      # create random PIL images
      _SCREAMING_SNAKE_CASE =   self.image_processor_tester.prepare_inputs(equal_resolution=__lowerCamelCase					)
      for image in image_inputs:
         self.assertIsInstance(__lowerCamelCase						,   Image.Image					)

      # Test not batched input
      _SCREAMING_SNAKE_CASE =   image_processor(image_inputs[0]						,   return_tensors="pt"					).pixel_values
      _SCREAMING_SNAKE_CASE, _SCREAMING_SNAKE_CASE =   self.calculate_expected_size(np.array(image_inputs[0]					)					)
      self.assertEqual(
          encoded_images.shape						,   (
              1,
              self.image_processor_tester.num_channels,
              expected_height,
              expected_width,
          )						,   )



   def 							lowerCAmelCase_    (					self      :			Tuple					):

      """simple docstring"""
      # Initialize image_processor
      _SCREAMING_SNAKE_CASE =   self.image_processing_class(**self.image_processor_dict					)
      # create random numpy tensors
      _SCREAMING_SNAKE_CASE =   self.image_processor_tester.prepare_inputs(equal_resolution=__lowerCamelCase						,   numpify=__lowerCamelCase					)
      for image in image_inputs:
         self.assertIsInstance(__lowerCamelCase						,   np.ndarray					)

      # Test not batched input
      _SCREAMING_SNAKE_CASE =   image_processor(image_inputs[0]						,   return_tensors="pt"					).pixel_values
      _SCREAMING_SNAKE_CASE, _SCREAMING_SNAKE_CASE =   self.calculate_expected_size(image_inputs[0]					)
      self.assertEqual(
          encoded_images.shape						,   (
              1,
              self.image_processor_tester.num_channels,
              expected_height,
              expected_width,
          )						,   )



   def 							lowerCAmelCase_    (					self      :			str					):

      """simple docstring"""
      # Initialize image_processor
      _SCREAMING_SNAKE_CASE =   self.image_processing_class(**self.image_processor_dict					)
      # create random PyTorch tensors
      _SCREAMING_SNAKE_CASE =   self.image_processor_tester.prepare_inputs(equal_resolution=__lowerCamelCase						,   torchify=__lowerCamelCase					)
      for image in image_inputs:
         self.assertIsInstance(__lowerCamelCase						,   torch.Tensor					)

      # Test not batched input
      _SCREAMING_SNAKE_CASE =   image_processor(image_inputs[0]						,   return_tensors="pt"					).pixel_values
      _SCREAMING_SNAKE_CASE, _SCREAMING_SNAKE_CASE =   self.calculate_expected_size(image_inputs[0]					)
      self.assertEqual(
          encoded_images.shape						,   (
              1,
              self.image_processor_tester.num_channels,
              expected_height,
              expected_width,
          )						,   )







'''simple docstring'''



def 				SCREAMING_SNAKE_CASE_				(							__A       :				List[Any] ,  __A       :				Dict						)				->				Union[str, Any]:
   if n == 0:
      return 1

   elif n % 2 == 1:
      return binary_exponentiation(__A ,  n - 1						) * a

   else:
      _SCREAMING_SNAKE_CASE =   binary_exponentiation(__A ,  n / 2						)
      return b * b


if __name__ == "__main__":
 try:
  lowerCamelCase_	 =		int(input('Enter Base : ').strip())
  lowerCamelCase_	 =		int(input('Enter Power : ').strip())
 except ValueError:
  print('Invalid literal for integer')

 lowerCamelCase_	 =		binary_exponentiation(BASE, POWER)
 print(f'''{BASE}^({POWER}) : {RESULT}''')

