




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







   def __init__(							self    ,      SCREAMING_SNAKE_CASE_    ,      SCREAMING_SNAKE_CASE_=7    ,      SCREAMING_SNAKE_CASE_=3    ,      SCREAMING_SNAKE_CASE_=18    ,      SCREAMING_SNAKE_CASE_=30    ,      SCREAMING_SNAKE_CASE_=400    ,      SCREAMING_SNAKE_CASE_=True    ,      SCREAMING_SNAKE_CASE_=None    ,      SCREAMING_SNAKE_CASE_=True    ,      SCREAMING_SNAKE_CASE_=None    ,      SCREAMING_SNAKE_CASE_=True    ,      SCREAMING_SNAKE_CASE_=[0.48145466, 0.4578275, 0.40821073]    ,      SCREAMING_SNAKE_CASE_=[0.26862954, 0.26130258, 0.27577711]    ,      SCREAMING_SNAKE_CASE_=True    ,      ):
       UpperCamelCase				:   str          =							size if size is not None else {"""shortest_edge""": 20}
       UpperCamelCase				:   Tuple          =							crop_size if crop_size is not None else {"""height""": 18, """width""": 18}
       UpperCamelCase				:   Optional[int]          =							parent
       UpperCamelCase				:   Union[str, Any]          =							batch_size
       UpperCamelCase				:   Dict          =							num_channels
       UpperCamelCase				:   Any          =							image_size
       UpperCamelCase				:   List[Any]          =							min_resolution
       UpperCamelCase				:   Optional[int]          =							max_resolution
       UpperCamelCase				:   Union[str, Any]          =							do_resize
       UpperCamelCase				:   int          =							size
       UpperCamelCase				:   Dict          =							do_center_crop
       UpperCamelCase				:   Dict          =							crop_size
       UpperCamelCase				:   Optional[Any]          =							do_normalize
       UpperCamelCase				:   Optional[int]          =							image_mean
       UpperCamelCase				:   List[Any]          =							image_std
       UpperCamelCase				:   List[Any]          =							do_convert_rgb







   def       a_							(							self ):
       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    ,      SCREAMING_SNAKE_CASE_=False    ,      SCREAMING_SNAKE_CASE_=False    ,      SCREAMING_SNAKE_CASE_=False ):
       assert not (numpify and torchify), "You cannot specify both numpy and PyTorch tensors at the same time"

       if equal_resolution:
           UpperCamelCase				:   List[Any]          =							[]
           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:
           UpperCamelCase				:   Dict          =							[]
           for i in range(self.batch_size ):
               UpperCamelCase       ,							UpperCamelCase				:   List[Any]          =							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
           UpperCamelCase				:   Optional[int]          =							[Image.fromarray(np.moveaxis(SCREAMING_SNAKE_CASE_    ,      0    ,      -1 ) ) for x in image_inputs]

       if torchify:
           UpperCamelCase				:   str          =							[torch.from_numpy(SCREAMING_SNAKE_CASE_ ) for x in image_inputs]

       return image_inputs







@require_torch
@require_vision
class 							lowerCamelCase		( _UpperCAmelCase	,  unittest.TestCase				):
   lowercase       :  Dict      =				CLIPImageProcessor if is_vision_available() else None







   def       a_							(							self ):
       UpperCamelCase				:   Tuple          =							CLIPImageProcessingTester(self )







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







   def       a_							(							self ):
       UpperCamelCase				:   Any          =							self.image_processing_class(**self.image_processor_dict )
       self.assertTrue(hasattr(SCREAMING_SNAKE_CASE_    ,      """do_resize""" ) )
       self.assertTrue(hasattr(SCREAMING_SNAKE_CASE_    ,      """size""" ) )
       self.assertTrue(hasattr(SCREAMING_SNAKE_CASE_    ,      """do_center_crop""" ) )
       self.assertTrue(hasattr(SCREAMING_SNAKE_CASE_    ,      """center_crop""" ) )
       self.assertTrue(hasattr(SCREAMING_SNAKE_CASE_    ,      """do_normalize""" ) )
       self.assertTrue(hasattr(SCREAMING_SNAKE_CASE_    ,      """image_mean""" ) )
       self.assertTrue(hasattr(SCREAMING_SNAKE_CASE_    ,      """image_std""" ) )
       self.assertTrue(hasattr(SCREAMING_SNAKE_CASE_    ,      """do_convert_rgb""" ) )







   def       a_							(							self ):
       UpperCamelCase				:   str          =							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} )

       UpperCamelCase				:   List[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       a_							(							self ):
       pass







   def       a_							(							self ):
       # Initialize image_processing
       UpperCamelCase				:   Any          =							self.image_processing_class(**self.image_processor_dict )
       # create random PIL images
       UpperCamelCase				:   Optional[int]          =							self.image_processor_tester.prepare_inputs(equal_resolution=SCREAMING_SNAKE_CASE_ )
       for image in image_inputs:
           self.assertIsInstance(SCREAMING_SNAKE_CASE_    ,      Image.Image )

       # Test not batched input
       UpperCamelCase				:   int          =							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
       UpperCamelCase				:   Any          =							image_processing(SCREAMING_SNAKE_CASE_    ,      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 ):
       # Initialize image_processing
       UpperCamelCase				:   Union[str, Any]          =							self.image_processing_class(**self.image_processor_dict )
       # create random numpy tensors
       UpperCamelCase				:   List[Any]          =							self.image_processor_tester.prepare_inputs(equal_resolution=SCREAMING_SNAKE_CASE_    ,      numpify=SCREAMING_SNAKE_CASE_ )
       for image in image_inputs:
           self.assertIsInstance(SCREAMING_SNAKE_CASE_    ,      np.ndarray )

       # Test not batched input
       UpperCamelCase				:   int          =							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
       UpperCamelCase				:   Dict          =							image_processing(SCREAMING_SNAKE_CASE_    ,      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 ):
       # Initialize image_processing
       UpperCamelCase				:   Dict          =							self.image_processing_class(**self.image_processor_dict )
       # create random PyTorch tensors
       UpperCamelCase				:   Tuple          =							self.image_processor_tester.prepare_inputs(equal_resolution=SCREAMING_SNAKE_CASE_    ,      torchify=SCREAMING_SNAKE_CASE_ )
       for image in image_inputs:
           self.assertIsInstance(SCREAMING_SNAKE_CASE_    ,      torch.Tensor )

       # Test not batched input
       UpperCamelCase				:   Optional[Any]          =							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
       UpperCamelCase				:   Any          =							image_processing(SCREAMING_SNAKE_CASE_    ,      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 							lowerCamelCase		( _UpperCAmelCase	,  unittest.TestCase				):
   lowercase       :  List[Any]      =				CLIPImageProcessor if is_vision_available() else None







   def       a_							(							self ):
       UpperCamelCase				:   Union[str, Any]          =							CLIPImageProcessingTester(self    ,      num_channels=4 )
       UpperCamelCase				:   Optional[int]          =							3







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







   def       a_							(							self ):
       UpperCamelCase				:   Any          =							self.image_processing_class(**self.image_processor_dict )
       self.assertTrue(hasattr(SCREAMING_SNAKE_CASE_    ,      """do_resize""" ) )
       self.assertTrue(hasattr(SCREAMING_SNAKE_CASE_    ,      """size""" ) )
       self.assertTrue(hasattr(SCREAMING_SNAKE_CASE_    ,      """do_center_crop""" ) )
       self.assertTrue(hasattr(SCREAMING_SNAKE_CASE_    ,      """center_crop""" ) )
       self.assertTrue(hasattr(SCREAMING_SNAKE_CASE_    ,      """do_normalize""" ) )
       self.assertTrue(hasattr(SCREAMING_SNAKE_CASE_    ,      """image_mean""" ) )
       self.assertTrue(hasattr(SCREAMING_SNAKE_CASE_    ,      """image_std""" ) )
       self.assertTrue(hasattr(SCREAMING_SNAKE_CASE_    ,      """do_convert_rgb""" ) )







   def       a_							(							self ):
       pass







   def       a_							(							self ):
       # Initialize image_processing
       UpperCamelCase				:   int          =							self.image_processing_class(**self.image_processor_dict )
       # create random PIL images
       UpperCamelCase				:   Optional[int]          =							self.image_processor_tester.prepare_inputs(equal_resolution=SCREAMING_SNAKE_CASE_ )
       for image in image_inputs:
           self.assertIsInstance(SCREAMING_SNAKE_CASE_    ,      Image.Image )

       # Test not batched input
       UpperCamelCase				:   Union[str, Any]          =							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
       UpperCamelCase				:   Optional[Any]          =							image_processing(SCREAMING_SNAKE_CASE_    ,      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"""




def 					A_			(		snake_case_     :       Tuple						,snake_case_     :       Optional[Any]						,snake_case_     :       Optional[Any]    ):







    '''simple docstring'''
    assert b != 0, "This cannot accept modulo that is == 0"
    if n == 0:
        return 1

    if n % 2 == 1:
        return (bin_exp_mod(snake_case_						,n - 1						,snake_case_    ) * a) % b

    UpperCamelCase				:   List[Any]          =							bin_exp_mod(snake_case_						,n / 2						,snake_case_    )
    return (r * r) % b


if __name__ == "__main__":
  try:
    __A :		Any      							=    int(input('''Enter Base : ''').strip())
    __A :		Any      							=    int(input('''Enter Power : ''').strip())
    __A :		List[Any]      							=    int(input('''Enter Modulo : ''').strip())
  except ValueError:
    print('''Invalid literal for integer''')

  print(bin_exp_mod(BASE, POWER, MODULO))




