code: 
  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      UpperCamelCase_			(			unittest.TestCase		):
  
  
  
  
  
  
  
  						'''simple docstring'''
  
  
  
  						def __init__( self       :Union[str, Any]		,						lowerCAmelCase__       :str		,						lowerCAmelCase__       :Tuple=7		,						lowerCAmelCase__       :Any=3		,						lowerCAmelCase__       :Any=18		,						lowerCAmelCase__       :Any=30		,						lowerCAmelCase__       :Dict=400		,						lowerCAmelCase__       :Dict=True		,						lowerCAmelCase__       :Optional[int]=1 / 255		,						lowerCAmelCase__       :List[str]=True		,						lowerCAmelCase__       :Dict=8		,						)     ->Tuple:
  										lowercase						    =			parent
  										lowercase						    =			batch_size
  										lowercase						    =			num_channels
  										lowercase						    =			image_size
  										lowercase						    =			min_resolution
  										lowercase						    =			max_resolution
  										lowercase						    =			do_rescale
  										lowercase						    =			rescale_factor
  										lowercase						    =			do_pad
  										lowercase						    =			pad_size
  
  
  
  
  
  						def 					SCREAMING_SNAKE_CASE( self       :Optional[int]    )     ->Tuple:
  										return {
  										    "do_rescale": self.do_rescale,
  										    "rescale_factor": self.rescale_factor,
  										    "do_pad": self.do_pad,
  										    "pad_size": self.pad_size,
  										}
  
  
  
  
  
  						def 					SCREAMING_SNAKE_CASE( self       :Any		,						lowerCAmelCase__       :Dict=False		,						lowerCAmelCase__       :Union[str, Any]=False		,						lowerCAmelCase__       :List[str]=False    )     ->Any:
  										assert not (numpify and torchify), "You cannot specify both numpy and PyTorch tensors at the same time"
  
  										if equal_resolution:
  														lowercase						    =			[]
  														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:
  														lowercase						    =			[]
  														for i in range(self.batch_size    ):
  																		lowercase    ,  lowercase						    =			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
  														lowercase						    =			[Image.fromarray(np.moveaxis(lowerCAmelCase__		,						0		,						-1    )    ) for x in image_inputs]
  
  										if torchify:
  														lowercase						    =			[torch.from_numpy(lowerCAmelCase__    ) for x in image_inputs]
  
  										return image_inputs
  
  
  
  
  
  @require_torch
  @require_vision
  class      UpperCamelCase_			(			__a		,						unittest.TestCase		):
  
  
  
  
  
  
  
  						'''simple docstring'''
  
  
  
  						UpperCamelCase			:     Union[str, Any]							      =				SwinaSRImageProcessor if is_vision_available() else None
  
  
  
  
  
  						def 					SCREAMING_SNAKE_CASE( self       :List[str]    )     ->List[Any]:
  										lowercase						    =			SwinaSRImageProcessingTester(self    )
  
  
  
  
  
  						@property
  						def 					SCREAMING_SNAKE_CASE( self       :Optional[int]    )     ->List[Any]:
  										return self.image_processor_tester.prepare_image_processor_dict()
  
  
  
  
  
  						def 					SCREAMING_SNAKE_CASE( self       :Optional[Any]    )     ->Union[str, Any]:
  										lowercase						    =			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 					SCREAMING_SNAKE_CASE( self       :Dict    )     ->Optional[int]:
  										pass
  
  
  
  
  
  						def 					SCREAMING_SNAKE_CASE( self       :Union[str, Any]		,						lowerCAmelCase__       :List[str]    )     ->str:
  										lowercase    ,  lowercase						    =			get_image_size(lowerCAmelCase__    )
  										lowercase						    =			self.image_processor_tester.pad_size
  
  										lowercase						    =			(old_height // size + 1) * size - old_height
  										lowercase						    =			(old_width // size + 1) * size - old_width
  										return old_height + pad_height, old_width + pad_width
  
  
  
  
  
  						def 					SCREAMING_SNAKE_CASE( self       :List[Any]    )     ->List[Any]:
  										# Initialize image_processor
  										lowercase						    =			self.image_processing_class(**self.image_processor_dict    )
  										# create random PIL images
  										lowercase						    =			self.image_processor_tester.prepare_inputs(equal_resolution=lowerCAmelCase__    )
  										for image in image_inputs:
  														self.assertIsInstance(lowerCAmelCase__		,						Image.Image    )
  
  										# Test not batched input
  										lowercase						    =			image_processor(image_inputs[0]		,						return_tensors="pt"    ).pixel_values
  										lowercase    ,  lowercase						    =			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 					SCREAMING_SNAKE_CASE( self       :Any    )     ->List[str]:
  										# Initialize image_processor
  										lowercase						    =			self.image_processing_class(**self.image_processor_dict    )
  										# create random numpy tensors
  										lowercase						    =			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
  										lowercase						    =			image_processor(image_inputs[0]		,						return_tensors="pt"    ).pixel_values
  										lowercase    ,  lowercase						    =			self.calculate_expected_size(image_inputs[0]    )
  										self.assertEqual(
  										    encoded_images.shape		,						(
  										        1,
  										        self.image_processor_tester.num_channels,
  										        expected_height,
  										        expected_width,
  										    )		,						)
  
  
  
  
  
  						def 					SCREAMING_SNAKE_CASE( self       :List[str]    )     ->Optional[Any]:
  										# Initialize image_processor
  										lowercase						    =			self.image_processing_class(**self.image_processor_dict    )
  										# create random PyTorch tensors
  										lowercase						    =			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
  										lowercase						    =			image_processor(image_inputs[0]		,						return_tensors="pt"    ).pixel_values
  										lowercase    ,  lowercase						    =			self.calculate_expected_size(image_inputs[0]    )
  										self.assertEqual(
  										    encoded_images.shape		,						(
  										        1,
  										        self.image_processor_tester.num_channels,
  										        expected_height,
  										        expected_width,
  										    )		,						)
  
style_context: 
  from transformers import PretrainedConfig
  
  
  
  
  
  class      UpperCamelCase_			(			__a		):
  
  
  
  
  
  
  
  						'''simple docstring'''
  
  
  
  						UpperCamelCase			:     List[str]							      =				'''custom'''
  
  
  
  
  
  						def __init__( self       :Tuple		,						lowerCAmelCase__       :int=1		,						**lowerCAmelCase__       :List[Any]    )     ->int:
  										lowercase						    =			attribute
  										super().__init__(**lowerCAmelCase__    )
  
  
  
  
  
  class      UpperCamelCase_			(			__a		):
  
  
  
  
  
  
  
  						'''simple docstring'''
  
  
  
  						UpperCamelCase			:     Union[str, Any]							      =				'''custom'''
  
  
  
  
  
  						def __init__( self       :Union[str, Any]		,						lowerCAmelCase__       :Dict=1		,						**lowerCAmelCase__       :Dict    )     ->List[str]:
  										lowercase						    =			attribute
  