




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 BlipImageProcessor
class      _UpperCamelCase (			unittest.TestCase						):
						def __init__(     self				:int	, lowerCamelCase				:Any	, lowerCamelCase				:List[Any]=7	, lowerCamelCase				:List[Any]=3	, lowerCamelCase				:Any=18	, lowerCamelCase				:Dict=30	, lowerCamelCase				:Optional[Any]=400	, lowerCamelCase				:Tuple=True	, lowerCamelCase				:Union[str, Any]=None	, lowerCamelCase				:List[str]=True	, lowerCamelCase				:List[Any]=False	, lowerCamelCase				:str=[0.48_14_54_66, 0.4_57_82_75, 0.40_82_10_73]	, lowerCamelCase				:str=[0.26_86_29_54, 0.26_13_02_58, 0.27_57_77_11]	, lowerCamelCase				:List[str]=True	, )       ->     Optional[Any]:
							UpperCAmelCase__								=  size if size is not None else {"height": 20, "width": 20}
							UpperCAmelCase__								=  parent
							UpperCAmelCase__								=  batch_size
							UpperCAmelCase__								=  num_channels
							UpperCAmelCase__								=  image_size
							UpperCAmelCase__								=  min_resolution
							UpperCAmelCase__								=  max_resolution
							UpperCAmelCase__								=  do_resize
							UpperCAmelCase__								=  size
							UpperCAmelCase__								=  do_normalize
							UpperCAmelCase__								=  image_mean
							UpperCAmelCase__								=  image_std
							UpperCAmelCase__								=  do_pad
							UpperCAmelCase__								=  do_convert_rgb
						def 		UpperCAmelCase_  (     self				:Tuple )       ->     str:
							return {
							    "do_resize": self.do_resize,
							    "size": self.size,
							    "do_normalize": self.do_normalize,
							    "image_mean": self.image_mean,
							    "image_std": self.image_std,
							    "do_convert_rgb": self.do_convert_rgb,
							    "do_pad": self.do_pad,
							}







						def 		UpperCAmelCase_  (     self				:Union[str, Any]	, lowerCamelCase				:Union[str, Any]=False	, lowerCamelCase				:str=False	, lowerCamelCase				:int=False )       ->     List[Any]:
							assert not (numpify and torchify), "You cannot specify both numpy and PyTorch tensors at the same time"

							if equal_resolution:
								UpperCAmelCase__								=  []
								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__								=  []
								for i in range(self.batch_size ):
									UpperCAmelCase__								=  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__								=  [Image.fromarray(np.moveaxis(UpperCamelCase__	, 0	, -1 ) ) for x in image_inputs]

							if torchify:
								UpperCAmelCase__								=  [torch.from_numpy(UpperCamelCase__ ) for x in image_inputs]

							return image_inputs



@require_torch
@require_vision
class      _UpperCamelCase (			lowerCAmelCase__		,    unittest.TestCase						):
						UpperCAmelCase_            =						BlipImageProcessor if is_vision_available() else None
						def 		UpperCAmelCase_  (     self				:List[str] )       ->     List[Any]:
							UpperCAmelCase__								=  BlipImageProcessingTester(self )
						@property
						def 		UpperCAmelCase_  (     self				:List[Any] )       ->     int:
							return self.image_processor_tester.prepare_image_processor_dict()
						def 		UpperCAmelCase_  (     self				:int )       ->     List[str]:
							UpperCAmelCase__								=  self.image_processing_class(**self.image_processor_dict )
							self.assertTrue(hasattr(UpperCamelCase__	, "do_resize" ) )
							self.assertTrue(hasattr(UpperCamelCase__	, "size" ) )
							self.assertTrue(hasattr(UpperCamelCase__	, "do_normalize" ) )
							self.assertTrue(hasattr(UpperCamelCase__	, "image_mean" ) )
							self.assertTrue(hasattr(UpperCamelCase__	, "image_std" ) )
							self.assertTrue(hasattr(UpperCamelCase__	, "do_convert_rgb" ) )
						def 		UpperCAmelCase_  (     self				:List[Any] )       ->     List[Any]:
							pass
						def 		UpperCAmelCase_  (     self				:Dict )       ->     Any:
							# Initialize image_processor
							UpperCAmelCase__								=  self.image_processing_class(**self.image_processor_dict )
							# create random PIL images
							UpperCAmelCase__								=  self.image_processor_tester.prepare_inputs(equal_resolution=UpperCamelCase__ )
							for image in image_inputs:
								self.assertIsInstance(UpperCamelCase__	, Image.Image )

							# Test not batched input
							UpperCAmelCase__								=  image_processor(image_inputs[0]	, return_tensors="pt" ).pixel_values
							self.assertEqual(
							    encoded_images.shape	, (
							        1,
							        self.image_processor_tester.num_channels,
							        self.image_processor_tester.size["height"],
							        self.image_processor_tester.size["width"],
							    )	, )

							# Test batched
							UpperCAmelCase__								=  image_processor(UpperCamelCase__	, 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.size["height"],
							        self.image_processor_tester.size["width"],
							    )	, )
						def 		UpperCAmelCase_  (     self				:Optional[Any] )       ->     Dict:
							# Initialize image_processor
							UpperCAmelCase__								=  self.image_processing_class(**self.image_processor_dict )
							# create random numpy tensors
							UpperCAmelCase__								=  self.image_processor_tester.prepare_inputs(equal_resolution=UpperCamelCase__	, numpify=UpperCamelCase__ )
							for image in image_inputs:
								self.assertIsInstance(UpperCamelCase__	, np.ndarray )

							# Test not batched input
							UpperCAmelCase__								=  image_processor(image_inputs[0]	, return_tensors="pt" ).pixel_values
							self.assertEqual(
							    encoded_images.shape	, (
							        1,
							        self.image_processor_tester.num_channels,
							        self.image_processor_tester.size["height"],
							        self.image_processor_tester.size["width"],
							    )	, )

							# Test batched
							UpperCAmelCase__								=  image_processor(UpperCamelCase__	, 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.size["height"],
							        self.image_processor_tester.size["width"],
							    )	, )







						def 		UpperCAmelCase_  (     self				:List[Any] )       ->     Dict:
							# Initialize image_processor
							UpperCAmelCase__								=  self.image_processing_class(**self.image_processor_dict )
							# create random PyTorch tensors
							UpperCAmelCase__								=  self.image_processor_tester.prepare_inputs(equal_resolution=UpperCamelCase__	, torchify=UpperCamelCase__ )
							for image in image_inputs:
								self.assertIsInstance(UpperCamelCase__	, torch.Tensor )

							# Test not batched input
							UpperCAmelCase__								=  image_processor(image_inputs[0]	, return_tensors="pt" ).pixel_values
							self.assertEqual(
							    encoded_images.shape	, (
							        1,
							        self.image_processor_tester.num_channels,
							        self.image_processor_tester.size["height"],
							        self.image_processor_tester.size["width"],
							    )	, )

							# Test batched
							UpperCAmelCase__								=  image_processor(UpperCamelCase__	, 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.size["height"],
							        self.image_processor_tester.size["width"],
							    )	, )



@require_torch
@require_vision
class      _UpperCamelCase (			lowerCAmelCase__		,    unittest.TestCase						):
						UpperCAmelCase_            =						BlipImageProcessor if is_vision_available() else None
						def 		UpperCAmelCase_  (     self				:Union[str, Any] )       ->     Dict:
							UpperCAmelCase__								=  BlipImageProcessingTester(self	, num_channels=4 )
							UpperCAmelCase__								=  3
						@property
						def 		UpperCAmelCase_  (     self				:Optional[Any] )       ->     Optional[Any]:
							return self.image_processor_tester.prepare_image_processor_dict()
						def 		UpperCAmelCase_  (     self				:List[str] )       ->     List[str]:
							UpperCAmelCase__								=  self.image_processing_class(**self.image_processor_dict )
							self.assertTrue(hasattr(UpperCamelCase__	, "do_resize" ) )
							self.assertTrue(hasattr(UpperCamelCase__	, "size" ) )
							self.assertTrue(hasattr(UpperCamelCase__	, "do_normalize" ) )
							self.assertTrue(hasattr(UpperCamelCase__	, "image_mean" ) )
							self.assertTrue(hasattr(UpperCamelCase__	, "image_std" ) )
							self.assertTrue(hasattr(UpperCamelCase__	, "do_convert_rgb" ) )
						def 		UpperCAmelCase_  (     self				:int )       ->     List[Any]:
							pass







						def 		UpperCAmelCase_  (     self				:List[Any] )       ->     Optional[int]:
							# Initialize image_processor
							UpperCAmelCase__								=  self.image_processing_class(**self.image_processor_dict )
							# create random PIL images
							UpperCAmelCase__								=  self.image_processor_tester.prepare_inputs(equal_resolution=UpperCamelCase__ )
							for image in image_inputs:
								self.assertIsInstance(UpperCamelCase__	, Image.Image )

							# Test not batched input
							UpperCAmelCase__								=  image_processor(image_inputs[0]	, return_tensors="pt" ).pixel_values
							self.assertEqual(
							    encoded_images.shape	, (
							        1,
							        self.expected_encoded_image_num_channels,
							        self.image_processor_tester.size["height"],
							        self.image_processor_tester.size["width"],
							    )	, )

							# Test batched
							UpperCAmelCase__								=  image_processor(UpperCamelCase__	, 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.size["height"],
							        self.image_processor_tester.size["width"],
							    )	, )











def   lowerCAmelCase						(						_lowerCAmelCase							:				int  ,							_lowerCAmelCase							:				int		):




 """simple docstring"""







 if a < b:
  return gcd(_lowerCAmelCase  ,							_lowerCAmelCase		)
 if a % b == 0:
  return b
 return gcd(_lowerCAmelCase  ,							a % b		)



def   lowerCAmelCase						(						_lowerCAmelCase							:				int  ,							_lowerCAmelCase							:				int  ,							_lowerCAmelCase							:				int		):




 """simple docstring"""







 if y == 0:
  return 1
 UpperCAmelCase__								=  power(_lowerCAmelCase  ,							y // 2  ,							_lowerCAmelCase		) % mod
 UpperCAmelCase__								=  (temp * temp) % mod
 if y % 2 == 1:
  UpperCAmelCase__								=  (temp * x) % mod
 return temp



def   lowerCAmelCase						(						_lowerCAmelCase							:				int		):




 """simple docstring"""







 UpperCAmelCase__								=  2
 while b < n:
  if gcd(_lowerCAmelCase  ,							_lowerCAmelCase		) == 1 and power(_lowerCAmelCase  ,							n - 1  ,							_lowerCAmelCase		) != 1:
   return False
  b += 1
 return True


if __name__ == "__main__":
  _lowerCAmelCase  :				Dict						=				int(input("Enter number: ").strip())
  if is_carmichael_number(number):
    print(F'''{number} is a Carmichael Number.''')
  else:
    print(F'''{number} is not a Carmichael Number.''')





