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 			a_					(    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=False			,    SCREAMING_SNAKE_CASE=[0.4_8_1_4_5_4_6_6, 0.4_5_7_8_2_7_5, 0.4_0_8_2_1_0_7_3]			,    SCREAMING_SNAKE_CASE=[0.2_6_8_6_2_9_5_4, 0.2_6_1_3_0_2_5_8, 0.2_7_5_7_7_7_1_1]			,    SCREAMING_SNAKE_CASE=True			,    )     ->				Union[str, Any]:
  
  
  
  
  				"""simple docstring"""
  
  
  
  				SCREAMING_SNAKE_CASE_			=	size if size is not None else {'height': 20, 'width': 20}
  				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_resize
  				SCREAMING_SNAKE_CASE_			=	size
  				SCREAMING_SNAKE_CASE_			=	do_normalize
  				SCREAMING_SNAKE_CASE_			=	image_mean
  				SCREAMING_SNAKE_CASE_			=	image_std
  				SCREAMING_SNAKE_CASE_			=	do_pad
  				SCREAMING_SNAKE_CASE_			=	do_convert_rgb
  
  
  
  
  
  	def 	A_(       self			)     ->				List[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 	A_(       self			,    SCREAMING_SNAKE_CASE=False			,    SCREAMING_SNAKE_CASE=False			,    SCREAMING_SNAKE_CASE=False			)     ->				str:
  
  
  
  
  				"""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(
  										        255			,    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(255			,    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(SCREAMING_SNAKE_CASE			,    0			,    -1			)			) for x in image_inputs]
  
  				if torchify:
  							SCREAMING_SNAKE_CASE_			=	[torch.from_numpy(SCREAMING_SNAKE_CASE			) for x in image_inputs]
  
  				return image_inputs
  
  
  
  
  @require_torch
  @require_vision
  class 			a_					(    SCREAMING_SNAKE_CASE__     ,						unittest.TestCase    ):
  	A						       =   BlipImageProcessor if is_vision_available() else None
  
  
  
  
  
  	def 	A_(       self			)     ->				Union[str, Any]:
  
  
  
  
  				"""simple docstring"""
  
  
  
  				SCREAMING_SNAKE_CASE_			=	BlipImageProcessingTester(self			)
  
  
  
  
  
  	@property
  	def 	A_(       self			)     ->				str:
  
  
  
  
  				"""simple docstring"""
  
  
  
  				return self.image_processor_tester.prepare_image_processor_dict()
  
  
  
  
  
  	def 	A_(       self			)     ->				Any:
  
  
  
  
  				"""simple docstring"""
  
  
  
  				SCREAMING_SNAKE_CASE_			=	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_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			)     ->				Tuple:
  
  
  
  
  				"""simple docstring"""
  
  
  
  				pass
  
  
  
  
  
  	def 	A_(       self			)     ->				Optional[Any]:
  
  
  
  
  				"""simple docstring"""
  
  
  
  				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=SCREAMING_SNAKE_CASE			)
  				for image in image_inputs:
  							self.assertIsInstance(SCREAMING_SNAKE_CASE			,    Image.Image			)
  
  				# Test not batched input
  				SCREAMING_SNAKE_CASE_			=	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
  				SCREAMING_SNAKE_CASE_			=	image_processor(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.size['height'],
  				        self.image_processor_tester.size['width'],
  				    )			,    )
  
  
  
  
  
  	def 	A_(       self			)     ->				List[str]:
  
  
  
  
  				"""simple docstring"""
  
  
  
  				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=SCREAMING_SNAKE_CASE			,    numpify=SCREAMING_SNAKE_CASE			)
  				for image in image_inputs:
  							self.assertIsInstance(SCREAMING_SNAKE_CASE			,    np.ndarray			)
  
  				# Test not batched input
  				SCREAMING_SNAKE_CASE_			=	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
  				SCREAMING_SNAKE_CASE_			=	image_processor(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.size['height'],
  				        self.image_processor_tester.size['width'],
  				    )			,    )
  
  
  
  
  
  	def 	A_(       self			)     ->				Any:
  
  
  
  
  				"""simple docstring"""
  
  
  
  				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=SCREAMING_SNAKE_CASE			,    torchify=SCREAMING_SNAKE_CASE			)
  				for image in image_inputs:
  							self.assertIsInstance(SCREAMING_SNAKE_CASE			,    torch.Tensor			)
  
  				# Test not batched input
  				SCREAMING_SNAKE_CASE_			=	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
  				SCREAMING_SNAKE_CASE_			=	image_processor(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.size['height'],
  				        self.image_processor_tester.size['width'],
  				    )			,    )
  
  
  
  
  @require_torch
  @require_vision
  class 			a_					(    SCREAMING_SNAKE_CASE__     ,						unittest.TestCase    ):
  	A						       =   BlipImageProcessor if is_vision_available() else None
  
  
  
  
  
  	def 	A_(       self			)     ->				Dict:
  
  
  
  
  				"""simple docstring"""
  
  
  
  				SCREAMING_SNAKE_CASE_			=	BlipImageProcessingTester(self			,    num_channels=4			)
  				SCREAMING_SNAKE_CASE_			=	3
  
  
  
  
  
  	@property
  	def 	A_(       self			)     ->				Union[str, Any]:
  
  
  
  
  				"""simple docstring"""
  
  
  
  				return self.image_processor_tester.prepare_image_processor_dict()
  
  
  
  
  
  	def 	A_(       self			)     ->				Union[str, Any]:
  
  
  
  
  				"""simple docstring"""
  
  
  
  				SCREAMING_SNAKE_CASE_			=	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_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			)     ->				Tuple:
  
  
  
  
  				"""simple docstring"""
  
  
  
  				pass
  
  
  
  
  
  	def 	A_(       self			)     ->				List[Any]:
  
  
  
  
  				"""simple docstring"""
  
  
  
  				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=SCREAMING_SNAKE_CASE			)
  				for image in image_inputs:
  							self.assertIsInstance(SCREAMING_SNAKE_CASE			,    Image.Image			)
  
  				# Test not batched input
  				SCREAMING_SNAKE_CASE_			=	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
  				SCREAMING_SNAKE_CASE_			=	image_processor(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.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 ...utils import BaseOutput, is_invisible_watermark_available, is_torch_available, is_transformers_available
  
  
  
  @dataclass
  class 			a_					(    SCREAMING_SNAKE_CASE__    ):
  	A						       =   42
  
  
  if is_transformers_available() and is_torch_available() and is_invisible_watermark_available():
  				from .pipeline_stable_diffusion_xl import StableDiffusionXLPipeline
  				from .pipeline_stable_diffusion_xl_imgaimg import StableDiffusionXLImgaImgPipeline
  