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 BlipImageProcessor
  
  
  
  
  
  
  
  class 		__magic_name__    (							unittest.TestCase							):
  
     '''simple docstring'''
  
  
  
  
     def __init__(       self,					lowercase_,					lowercase_=7,					lowercase_=3,					lowercase_=18,					lowercase_=30,					lowercase_=400,					lowercase_=True,					lowercase_=None,					lowercase_=True,					lowercase_=False,					lowercase_=[0.48145466, 0.4578275, 0.40821073],					lowercase_=[0.26862954, 0.26130258, 0.27577711],					lowercase_=True,					)							->					List[Any]:
  
  
  
  
  
  
       """simple docstring"""
  
  
  
  
  
  
       a__						=size if size is not None else {"height": 20, "width": 20}
       a__						=parent
       a__						=batch_size
       a__						=num_channels
       a__						=image_size
       a__						=min_resolution
       a__						=max_resolution
       a__						=do_resize
       a__						=size
       a__						=do_normalize
       a__						=image_mean
       a__						=image_std
       a__						=do_pad
       a__						=do_convert_rgb
  
  
  
     def 				_UpperCAmelCase				(       self )							->					str:
  
  
  
  
  
  
       """simple docstring"""
  
  
  
  
  
  
       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,					lowercase_=False,					lowercase_=False,					lowercase_=False )							->					Optional[int]:
  
  
  
  
  
  
       """simple docstring"""
  
  
  
  
  
  
       assert not (numpify and torchify), "You cannot specify both numpy and PyTorch tensors at the same time"
  
       if equal_resolution:
         a__						=[]
         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:
         a__						=[]
         for i in range(self.batch_size ):
           a__						=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
         a__						=[Image.fromarray(np.moveaxis(lowercase_,					0,					-1 ) ) for x in image_inputs]
  
       if torchify:
         a__						=[torch.from_numpy(lowercase_ ) for x in image_inputs]
  
       return image_inputs
  
  
  
  
  
  
  
  @require_torch
  @require_vision
  class 		__magic_name__    (							lowerCamelCase_	, unittest.TestCase							):
  
     '''simple docstring'''
  
  
  
  
     lowerCamelCase__				:			Dict												=     BlipImageProcessor if is_vision_available() else None
  
  
  
     def 				_UpperCAmelCase				(       self )							->					Optional[Any]:
  
  
  
  
  
  
       """simple docstring"""
  
  
  
  
  
  
       a__						=BlipImageProcessingTester(self )
  
  
  
     @property
     def 				_UpperCAmelCase				(       self )							->					Dict:
  
  
  
  
  
  
       """simple docstring"""
  
  
  
  
  
  
       return self.image_processor_tester.prepare_image_processor_dict()
  
  
  
     def 				_UpperCAmelCase				(       self )							->					Any:
  
  
  
  
  
  
       """simple docstring"""
  
  
  
  
  
  
       a__						=self.image_processing_class(**self.image_processor_dict )
       self.assertTrue(hasattr(lowercase_,					'''do_resize''' ) )
       self.assertTrue(hasattr(lowercase_,					'''size''' ) )
       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 				_UpperCAmelCase				(       self )							->					List[str]:
  
  
  
  
  
  
       """simple docstring"""
  
  
  
  
  
  
       pass
  
  
  
     def 				_UpperCAmelCase				(       self )							->					Any:
  
  
  
  
  
  
       """simple docstring"""
  
  
  
  
  
  
       a__						=self.image_processing_class(**self.image_processor_dict )
       # create random PIL images
       a__						=self.image_processor_tester.prepare_inputs(equal_resolution=lowercase_ )
       for image in image_inputs:
         self.assertIsInstance(lowercase_,					Image.Image )
  
       # Test not batched input
       a__						=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
       a__						=image_processor(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.size['''height'''],
               self.image_processor_tester.size['''width'''],
           ),					)
  
  
  
     def 				_UpperCAmelCase				(       self )							->					str:
  
  
  
  
  
  
       """simple docstring"""
  
  
  
  
  
  
       a__						=self.image_processing_class(**self.image_processor_dict )
       # create random numpy tensors
       a__						=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
       a__						=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
       a__						=image_processor(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.size['''height'''],
               self.image_processor_tester.size['''width'''],
           ),					)
  
  
  
     def 				_UpperCAmelCase				(       self )							->					Union[str, Any]:
  
  
  
  
  
  
       """simple docstring"""
  
  
  
  
  
  
       a__						=self.image_processing_class(**self.image_processor_dict )
       # create random PyTorch tensors
       a__						=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
       a__						=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
       a__						=image_processor(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.size['''height'''],
               self.image_processor_tester.size['''width'''],
           ),					)
  
  
  
  
  
  
  
  @require_torch
  @require_vision
  class 		__magic_name__    (							lowerCamelCase_	, unittest.TestCase							):
  
     '''simple docstring'''
  
  
  
  
     lowerCamelCase__				:			Union[str, Any]												=     BlipImageProcessor if is_vision_available() else None
  
  
  
     def 				_UpperCAmelCase				(       self )							->					Union[str, Any]:
  
  
  
  
  
  
       """simple docstring"""
  
  
  
  
  
  
       a__						=BlipImageProcessingTester(self,					num_channels=4 )
       a__						=3
  
  
  
     @property
     def 				_UpperCAmelCase				(       self )							->					List[Any]:
  
  
  
  
  
  
       """simple docstring"""
  
  
  
  
  
  
       return self.image_processor_tester.prepare_image_processor_dict()
  
  
  
     def 				_UpperCAmelCase				(       self )							->					Union[str, Any]:
  
  
  
  
  
  
       """simple docstring"""
  
  
  
  
  
  
       a__						=self.image_processing_class(**self.image_processor_dict )
       self.assertTrue(hasattr(lowercase_,					'''do_resize''' ) )
       self.assertTrue(hasattr(lowercase_,					'''size''' ) )
       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 				_UpperCAmelCase				(       self )							->					int:
  
  
  
  
  
  
       """simple docstring"""
  
  
  
  
  
  
       pass
  
  
  
     def 				_UpperCAmelCase				(       self )							->					Optional[Any]:
  
  
  
  
  
  
       """simple docstring"""
  
  
  
  
  
  
       a__						=self.image_processing_class(**self.image_processor_dict )
       # create random PIL images
       a__						=self.image_processor_tester.prepare_inputs(equal_resolution=lowercase_ )
       for image in image_inputs:
         self.assertIsInstance(lowercase_,					Image.Image )
  
       # Test not batched input
       a__						=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
       a__						=image_processor(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.size['''height'''],
               self.image_processor_tester.size['''width'''],
           ),					)
  
style_context: 
  
  from dataclasses import dataclass
  from typing import List, Optional, Union
  
  import numpy as np
  import PIL
  from PIL import Image
  
  from ...utils import BaseOutput, is_torch_available, is_transformers_available
  
  
  
  
  
  
  
  @dataclass
  # Copied from diffusers.pipelines.stable_diffusion.__init__.StableDiffusionPipelineOutput with Stable->Alt
  class 		__magic_name__    (							lowerCamelCase__							):
  
     '''simple docstring'''
  
  
  
  
     lowerCamelCase__				:			Union[List[PIL.Image.Image], np.ndarray]
     lowerCamelCase__				:			Optional[List[bool]]
  
  
  if is_transformers_available() and is_torch_available():
         from .modeling_roberta_series import RobertaSeriesModelWithTransformation
         from .pipeline_alt_diffusion import AltDiffusionPipeline
         from .pipeline_alt_diffusion_imgaimg import AltDiffusionImgaImgPipeline
  