


import random
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, prepare_image_inputs


if is_torch_available():
						import torch

if is_vision_available():
						import PIL

						from transformers import FlavaImageProcessor
						from transformers.image_utils import PILImageResampling
						from transformers.models.flava.image_processing_flava import (
						    FLAVA_CODEBOOK_MEAN,
						    FLAVA_CODEBOOK_STD,
						    FLAVA_IMAGE_MEAN,
						    FLAVA_IMAGE_STD,
						)
else:
						__lowerCAmelCase     :			Optional[int]      =None
class 	_lowercase				(      unittest.TestCase	):






				'''simple docstring'''



				def __init__(	self      :str      ,      lowerCAmelCase__      :Dict      ,      lowerCAmelCase__      :Any=7      ,      lowerCAmelCase__      :int=3      ,      lowerCAmelCase__      :Optional[Any]=30      ,      lowerCAmelCase__      :Tuple=400      ,      lowerCAmelCase__      :Dict=True      ,      lowerCAmelCase__      :Any=None      ,      lowerCAmelCase__      :Dict=True      ,      lowerCAmelCase__      :str=None      ,      lowerCAmelCase__      :str=None      ,      lowerCAmelCase__      :List[str]=True      ,      lowerCAmelCase__      :List[Any]=1 / 255      ,      lowerCAmelCase__      :Optional[int]=True      ,      lowerCAmelCase__      :List[Any]=FLAVA_IMAGE_MEAN      ,      lowerCAmelCase__      :List[Any]=FLAVA_IMAGE_STD      ,      lowerCAmelCase__      :List[Any]=14      ,      lowerCAmelCase__      :Optional[int]=75      ,      lowerCAmelCase__      :str=None      ,      lowerCAmelCase__      :Optional[Any]=16      ,      lowerCAmelCase__      :Optional[Any]=0.3      ,      lowerCAmelCase__      :str=None      ,      lowerCAmelCase__      :List[Any]=True      ,      lowerCAmelCase__      :Optional[int]=None      ,      lowerCAmelCase__      :Optional[Any]=None      ,      lowerCAmelCase__      :int=True      ,      lowerCAmelCase__      :Optional[Any]=None      ,      lowerCAmelCase__      :Union[str, Any]=True      ,      lowerCAmelCase__      :Union[str, Any]=True      ,      lowerCAmelCase__      :List[Any]=FLAVA_CODEBOOK_MEAN      ,      lowerCAmelCase__      :Optional[Any]=FLAVA_CODEBOOK_STD      ,      )		->      Optional[int]:
										__SCREAMING_SNAKE_CASE						:					List[Any]		      =		size if size is not None else {'''height''': 224, '''width''': 224}
										__SCREAMING_SNAKE_CASE						:					Optional[int]		      =		crop_size if crop_size is not None else {'''height''': 224, '''width''': 224}
										__SCREAMING_SNAKE_CASE						:					Union[str, Any]		      =		codebook_size if codebook_size is not None else {'''height''': 112, '''width''': 112}
										__SCREAMING_SNAKE_CASE						:					Dict		      =		codebook_crop_size if codebook_crop_size is not None else {'''height''': 112, '''width''': 112}

										__SCREAMING_SNAKE_CASE						:					int		      =		parent
										__SCREAMING_SNAKE_CASE						:					str		      =		batch_size
										__SCREAMING_SNAKE_CASE						:					int		      =		num_channels
										__SCREAMING_SNAKE_CASE						:					str		      =		do_resize
										__SCREAMING_SNAKE_CASE						:					Dict		      =		do_rescale
										__SCREAMING_SNAKE_CASE						:					Dict		      =		rescale_factor
										__SCREAMING_SNAKE_CASE						:					List[Any]		      =		min_resolution
										__SCREAMING_SNAKE_CASE						:					Any		      =		max_resolution
										__SCREAMING_SNAKE_CASE						:					Optional[int]		      =		size
										__SCREAMING_SNAKE_CASE						:					Optional[Any]		      =		resample if resample is not None else PILImageResampling.BICUBIC
										__SCREAMING_SNAKE_CASE						:					Tuple		      =		do_normalize
										__SCREAMING_SNAKE_CASE						:					Any		      =		image_mean
										__SCREAMING_SNAKE_CASE						:					Dict		      =		image_std
										__SCREAMING_SNAKE_CASE						:					Any		      =		do_center_crop
										__SCREAMING_SNAKE_CASE						:					str		      =		crop_size

										__SCREAMING_SNAKE_CASE						:					Tuple		      =		input_size_patches
										__SCREAMING_SNAKE_CASE						:					Any		      =		total_mask_patches
										__SCREAMING_SNAKE_CASE						:					Union[str, Any]		      =		mask_group_max_patches
										__SCREAMING_SNAKE_CASE						:					Optional[int]		      =		mask_group_min_patches
										__SCREAMING_SNAKE_CASE						:					Dict		      =		mask_group_min_aspect_ratio
										__SCREAMING_SNAKE_CASE						:					List[Any]		      =		mask_group_max_aspect_ratio

										__SCREAMING_SNAKE_CASE						:					Dict		      =		codebook_do_resize
										__SCREAMING_SNAKE_CASE						:					int		      =		codebook_size
										__SCREAMING_SNAKE_CASE						:					int		      =		codebook_resample if codebook_resample is not None else PILImageResampling.LANCZOS
										__SCREAMING_SNAKE_CASE						:					str		      =		codebook_do_center_crop
										__SCREAMING_SNAKE_CASE						:					Any		      =		codebook_crop_size
										__SCREAMING_SNAKE_CASE						:					List[str]		      =		codebook_do_map_pixels
										__SCREAMING_SNAKE_CASE						:					str		      =		codebook_do_normalize
										__SCREAMING_SNAKE_CASE						:					List[str]		      =		codebook_image_mean
										__SCREAMING_SNAKE_CASE						:					Any		      =		codebook_image_std


				def 		__magic_name__(	self      :List[Any]     )		->      Dict:
										return {
										    "image_mean": self.image_mean,
										    "image_std": self.image_std,
										    "do_normalize": self.do_normalize,
										    "do_resize": self.do_resize,
										    "size": self.size,
										    "resample": self.resample,
										    "do_rescale": self.do_rescale,
										    "rescale_factor": self.rescale_factor,
										    "do_center_crop": self.do_center_crop,
										    "crop_size": self.crop_size,
										    "input_size_patches": self.input_size_patches,
										    "total_mask_patches": self.total_mask_patches,
										    "mask_group_max_patches": self.mask_group_max_patches,
										    "mask_group_min_patches": self.mask_group_min_patches,
										    "mask_group_min_aspect_ratio": self.mask_group_min_aspect_ratio,
										    "mask_group_max_aspect_ratio": self.mask_group_min_aspect_ratio,
										    "codebook_do_resize": self.codebook_do_resize,
										    "codebook_size": self.codebook_size,
										    "codebook_resample": self.codebook_resample,
										    "codebook_do_center_crop": self.codebook_do_center_crop,
										    "codebook_crop_size": self.codebook_crop_size,
										    "codebook_do_map_pixels": self.codebook_do_map_pixels,
										    "codebook_do_normalize": self.codebook_do_normalize,
										    "codebook_image_mean": self.codebook_image_mean,
										    "codebook_image_std": self.codebook_image_std,
										}


				def 		__magic_name__(	self      :Union[str, Any]     )		->      int:
										return (self.size["height"], self.size["width"])


				def 		__magic_name__(	self      :Tuple     )		->      List[str]:
										return (
										    (self.input_size_patches, self.input_size_patches)
										    if not isinstance(self.input_size_patches      ,      lowerCAmelCase__     )
										    else self.input_size_patches
										)



				def 		__magic_name__(	self      :Union[str, Any]     )		->      int:
										return (self.codebook_size["height"], self.codebook_size["width"])




@require_torch
@require_vision
class 	_lowercase				(      A__						,      unittest.TestCase	):






				'''simple docstring'''



				SCREAMING_SNAKE_CASE__    :      str      =		FlavaImageProcessor if is_vision_available() else None
				SCREAMING_SNAKE_CASE__    :      Union[str, Any]      =		None


				def 		__magic_name__(	self      :List[Any]     )		->      List[str]:
										__SCREAMING_SNAKE_CASE						:					Any		      =		FlavaImageProcessingTester(self     )


				@property
				def 		__magic_name__(	self      :Dict     )		->      Optional[int]:
										return self.image_processor_tester.prepare_image_processor_dict()


				def 		__magic_name__(	self      :Union[str, Any]     )		->      str:
										__SCREAMING_SNAKE_CASE						:					Optional[int]		      =		self.image_processing_class(**self.image_processor_dict     )
										self.assertTrue(hasattr(lowerCAmelCase__      ,      '''image_mean'''     )     )
										self.assertTrue(hasattr(lowerCAmelCase__      ,      '''image_std'''     )     )
										self.assertTrue(hasattr(lowerCAmelCase__      ,      '''do_normalize'''     )     )
										self.assertTrue(hasattr(lowerCAmelCase__      ,      '''do_resize'''     )     )
										self.assertTrue(hasattr(lowerCAmelCase__      ,      '''resample'''     )     )
										self.assertTrue(hasattr(lowerCAmelCase__      ,      '''crop_size'''     )     )
										self.assertTrue(hasattr(lowerCAmelCase__      ,      '''do_center_crop'''     )     )
										self.assertTrue(hasattr(lowerCAmelCase__      ,      '''do_rescale'''     )     )
										self.assertTrue(hasattr(lowerCAmelCase__      ,      '''rescale_factor'''     )     )
										self.assertTrue(hasattr(lowerCAmelCase__      ,      '''masking_generator'''     )     )
										self.assertTrue(hasattr(lowerCAmelCase__      ,      '''codebook_do_resize'''     )     )
										self.assertTrue(hasattr(lowerCAmelCase__      ,      '''codebook_size'''     )     )
										self.assertTrue(hasattr(lowerCAmelCase__      ,      '''codebook_resample'''     )     )
										self.assertTrue(hasattr(lowerCAmelCase__      ,      '''codebook_do_center_crop'''     )     )
										self.assertTrue(hasattr(lowerCAmelCase__      ,      '''codebook_crop_size'''     )     )
										self.assertTrue(hasattr(lowerCAmelCase__      ,      '''codebook_do_map_pixels'''     )     )
										self.assertTrue(hasattr(lowerCAmelCase__      ,      '''codebook_do_normalize'''     )     )
										self.assertTrue(hasattr(lowerCAmelCase__      ,      '''codebook_image_mean'''     )     )
										self.assertTrue(hasattr(lowerCAmelCase__      ,      '''codebook_image_std'''     )     )


				def 		__magic_name__(	self      :Any     )		->      Optional[Any]:
										__SCREAMING_SNAKE_CASE						:					List[str]		      =		self.image_processing_class.from_dict(self.image_processor_dict     )
										self.assertEqual(image_processor.size      ,      {'''height''': 224, '''width''': 224}     )
										self.assertEqual(image_processor.crop_size      ,      {'''height''': 224, '''width''': 224}     )
										self.assertEqual(image_processor.codebook_size      ,      {'''height''': 112, '''width''': 112}     )
										self.assertEqual(image_processor.codebook_crop_size      ,      {'''height''': 112, '''width''': 112}     )

										__SCREAMING_SNAKE_CASE						:					Tuple		      =		self.image_processing_class.from_dict(
										    self.image_processor_dict      ,      size=42      ,      crop_size=84      ,      codebook_size=33      ,      codebook_crop_size=66     )
										self.assertEqual(image_processor.size      ,      {'''height''': 42, '''width''': 42}     )
										self.assertEqual(image_processor.crop_size      ,      {'''height''': 84, '''width''': 84}     )
										self.assertEqual(image_processor.codebook_size      ,      {'''height''': 33, '''width''': 33}     )
										self.assertEqual(image_processor.codebook_crop_size      ,      {'''height''': 66, '''width''': 66}     )


				def 		__magic_name__(	self      :List[Any]     )		->      List[Any]:
										pass


				def 		__magic_name__(	self      :int     )		->      int:
										# Initialize image_processing
										__SCREAMING_SNAKE_CASE						:					Dict		      =		self.image_processing_class(**self.image_processor_dict     )
										# create random PIL images
										__SCREAMING_SNAKE_CASE						:					List[str]		      =		prepare_image_inputs(self.image_processor_tester      ,      equal_resolution=lowerCAmelCase__     )
										for image in image_inputs:
																self.assertIsInstance(lowerCAmelCase__      ,      PIL.Image.Image     )

										# Test not batched input
										__SCREAMING_SNAKE_CASE						:					Dict		      =		image_processing(image_inputs[0]      ,      return_tensors='''pt'''     )

										# Test no bool masked pos
										self.assertFalse('''bool_masked_pos''' in encoded_images     )

										__SCREAMING_SNAKE_CASE      ,      __SCREAMING_SNAKE_CASE						:					List[Any]		      =		self.image_processor_tester.get_expected_image_size()

										self.assertEqual(
										    encoded_images.pixel_values.shape      ,      (1, self.image_processor_tester.num_channels, expected_height, expected_width)      ,      )

										# Test batched
										__SCREAMING_SNAKE_CASE						:					List[Any]		      =		image_processing(lowerCAmelCase__      ,      return_tensors='''pt'''     )
										__SCREAMING_SNAKE_CASE      ,      __SCREAMING_SNAKE_CASE						:					List[Any]		      =		self.image_processor_tester.get_expected_image_size()

										# Test no bool masked pos
										self.assertFalse('''bool_masked_pos''' in encoded_images     )

										self.assertEqual(
										    encoded_images.pixel_values.shape      ,      (
										        self.image_processor_tester.batch_size,
										        self.image_processor_tester.num_channels,
										        expected_height,
										        expected_width,
										    )      ,      )


				def 		__magic_name__(	self      :Union[str, Any]      ,      lowerCAmelCase__      :int      ,      lowerCAmelCase__      :List[str]     )		->      Dict:
										# Initialize image_processing
										__SCREAMING_SNAKE_CASE						:					Dict		      =		self.image_processing_class(**self.image_processor_dict     )
										# create random tensors
										__SCREAMING_SNAKE_CASE						:					Tuple		      =		prepare_image_inputs(self.image_processor_tester      ,      equal_resolution=lowerCAmelCase__      ,      **lowerCAmelCase__     )
										for image in image_inputs:
																self.assertIsInstance(lowerCAmelCase__      ,      lowerCAmelCase__     )

										# Test not batched input
										__SCREAMING_SNAKE_CASE						:					List[Any]		      =		image_processing(image_inputs[0]      ,      return_tensors='''pt'''     )

										__SCREAMING_SNAKE_CASE      ,      __SCREAMING_SNAKE_CASE						:					Optional[Any]		      =		self.image_processor_tester.get_expected_image_size()
										self.assertEqual(
										    encoded_images.pixel_values.shape      ,      (1, self.image_processor_tester.num_channels, expected_height, expected_width)      ,      )

										__SCREAMING_SNAKE_CASE						:					int		      =		image_processing(lowerCAmelCase__      ,      return_image_mask=lowerCAmelCase__      ,      return_tensors='''pt'''     )

										__SCREAMING_SNAKE_CASE      ,      __SCREAMING_SNAKE_CASE						:					Optional[Any]		      =		self.image_processor_tester.get_expected_image_size()
										self.assertEqual(
										    encoded_images.pixel_values.shape      ,      (
										        self.image_processor_tester.batch_size,
										        self.image_processor_tester.num_channels,
										        expected_height,
										        expected_width,
										    )      ,      )

										__SCREAMING_SNAKE_CASE      ,      __SCREAMING_SNAKE_CASE						:					List[str]		      =		self.image_processor_tester.get_expected_mask_size()
										self.assertEqual(
										    encoded_images.bool_masked_pos.shape      ,      (
										        self.image_processor_tester.batch_size,
										        expected_height,
										        expected_width,
										    )      ,      )

										# Test batched
										__SCREAMING_SNAKE_CASE						:					List[Any]		      =		image_processing(lowerCAmelCase__      ,      return_tensors='''pt'''     ).pixel_values

										__SCREAMING_SNAKE_CASE      ,      __SCREAMING_SNAKE_CASE						:					Any		      =		self.image_processor_tester.get_expected_image_size()
										self.assertEqual(
										    encoded_images.shape      ,      (
										        self.image_processor_tester.batch_size,
										        self.image_processor_tester.num_channels,
										        expected_height,
										        expected_width,
										    )      ,      )

										# Test masking
										__SCREAMING_SNAKE_CASE						:					Tuple		      =		image_processing(lowerCAmelCase__      ,      return_image_mask=lowerCAmelCase__      ,      return_tensors='''pt'''     )

										__SCREAMING_SNAKE_CASE      ,      __SCREAMING_SNAKE_CASE						:					Optional[int]		      =		self.image_processor_tester.get_expected_image_size()
										self.assertEqual(
										    encoded_images.pixel_values.shape      ,      (
										        self.image_processor_tester.batch_size,
										        self.image_processor_tester.num_channels,
										        expected_height,
										        expected_width,
										    )      ,      )

										__SCREAMING_SNAKE_CASE      ,      __SCREAMING_SNAKE_CASE						:					int		      =		self.image_processor_tester.get_expected_mask_size()
										self.assertEqual(
										    encoded_images.bool_masked_pos.shape      ,      (
										        self.image_processor_tester.batch_size,
										        expected_height,
										        expected_width,
										    )      ,      )


				def 		__magic_name__(	self      :Optional[int]     )		->      Optional[Any]:
										self._test_call_framework(np.ndarray      ,      prepare_kwargs={'''numpify''': True}     )


				def 		__magic_name__(	self      :Dict     )		->      List[Any]:
										self._test_call_framework(torch.Tensor      ,      prepare_kwargs={'''torchify''': True}     )


				def 		__magic_name__(	self      :Tuple     )		->      Tuple:
										# Initialize image_processing
										random.seed(1_234     )
										__SCREAMING_SNAKE_CASE						:					Any		      =		self.image_processing_class(**self.image_processor_dict     )
										__SCREAMING_SNAKE_CASE						:					Optional[int]		      =		prepare_image_inputs(self.image_processor_tester      ,      equal_resolution=lowerCAmelCase__      ,      torchify=lowerCAmelCase__     )

										# Test not batched input
										__SCREAMING_SNAKE_CASE						:					Optional[Any]		      =		image_processing(image_inputs[0]      ,      return_image_mask=lowerCAmelCase__      ,      return_tensors='''pt'''     )
										self.assertEqual(encoded_images.bool_masked_pos.sum().item()      ,      75     )



				def 		__magic_name__(	self      :Union[str, Any]     )		->      Dict:
										# Initialize image_processing
										__SCREAMING_SNAKE_CASE						:					Union[str, Any]		      =		self.image_processing_class(**self.image_processor_dict     )
										# create random PIL images
										__SCREAMING_SNAKE_CASE						:					Optional[int]		      =		prepare_image_inputs(self.image_processor_tester      ,      equal_resolution=lowerCAmelCase__     )
										for image in image_inputs:
																self.assertIsInstance(lowerCAmelCase__      ,      PIL.Image.Image     )

										# Test not batched input
										__SCREAMING_SNAKE_CASE						:					List[Any]		      =		image_processing(image_inputs[0]      ,      return_codebook_pixels=lowerCAmelCase__      ,      return_tensors='''pt'''     )
										__SCREAMING_SNAKE_CASE      ,      __SCREAMING_SNAKE_CASE						:					Tuple		      =		self.image_processor_tester.get_expected_codebook_image_size()
										self.assertEqual(
										    encoded_images.codebook_pixel_values.shape      ,      (1, self.image_processor_tester.num_channels, expected_height, expected_width)      ,      )

										# Test batched
										__SCREAMING_SNAKE_CASE						:					Any		      =		image_processing(lowerCAmelCase__      ,      return_codebook_pixels=lowerCAmelCase__      ,      return_tensors='''pt'''     )
										__SCREAMING_SNAKE_CASE      ,      __SCREAMING_SNAKE_CASE						:					int		      =		self.image_processor_tester.get_expected_codebook_image_size()
										self.assertEqual(
										    encoded_images.codebook_pixel_values.shape      ,      (
										        self.image_processor_tester.batch_size,
										        self.image_processor_tester.num_channels,
										        expected_height,
										        expected_width,
										    )      ,      )




from typing import Any, Callable, Dict, List, Optional, Union

import PIL.Image
import torch
from transformers import CLIPImageProcessor, CLIPTextModel, CLIPTokenizer

from diffusers import (
    AutoencoderKL,
    DDIMScheduler,
    DiffusionPipeline,
    LMSDiscreteScheduler,
    PNDMScheduler,
    StableDiffusionImgaImgPipeline,
    StableDiffusionInpaintPipelineLegacy,
    StableDiffusionPipeline,
    UNetaDConditionModel,
)
from diffusers.configuration_utils import FrozenDict
from diffusers.pipelines.stable_diffusion.safety_checker import StableDiffusionSafetyChecker
from diffusers.utils import deprecate, logging


__lowerCAmelCase     :			Tuple      =logging.get_logger(__name__)  # pylint: disable=invalid-name
class 	_lowercase				(      A__	):






				'''simple docstring'''



				SCREAMING_SNAKE_CASE__    :      Union[str, Any]      =		['''safety_checker''', '''feature_extractor''']


				def __init__(	self      :int      ,      lowerCAmelCase__      :AutoencoderKL      ,      lowerCAmelCase__      :CLIPTextModel      ,      lowerCAmelCase__      :CLIPTokenizer      ,      lowerCAmelCase__      :UNetaDConditionModel      ,      lowerCAmelCase__      :Union[DDIMScheduler, PNDMScheduler, LMSDiscreteScheduler]      ,      lowerCAmelCase__      :StableDiffusionSafetyChecker      ,      lowerCAmelCase__      :CLIPImageProcessor      ,      lowerCAmelCase__      :bool = True      ,      )		->      List[Any]:
										super().__init__()
										if hasattr(scheduler.config      ,      '''steps_offset'''     ) and scheduler.config.steps_offset != 1:
																__SCREAMING_SNAKE_CASE						:					Union[str, Any]		      =		(
																    f'''The configuration file of this scheduler: {scheduler} is outdated. `steps_offset`'''
																    f''' should be set to 1 instead of {scheduler.config.steps_offset}. Please make sure '''
																    '''to update the config accordingly as leaving `steps_offset` might led to incorrect results'''
																    ''' in future versions. If you have downloaded this checkpoint from the Hugging Face Hub,'''
																    ''' it would be very nice if you could open a Pull request for the `scheduler/scheduler_config.json`'''
																    ''' file'''
																)
																deprecate('''steps_offset!=1'''      ,      '''1.0.0'''      ,      lowerCAmelCase__      ,      standard_warn=lowerCAmelCase__     )
																__SCREAMING_SNAKE_CASE						:					Dict		      =		dict(scheduler.config     )
																__SCREAMING_SNAKE_CASE						:					Tuple		      =		1
																__SCREAMING_SNAKE_CASE						:					Dict		      =		FrozenDict(lowerCAmelCase__     )

										self.register_modules(
										    vae=lowerCAmelCase__      ,      text_encoder=lowerCAmelCase__      ,      tokenizer=lowerCAmelCase__      ,      unet=lowerCAmelCase__      ,      scheduler=lowerCAmelCase__      ,      safety_checker=lowerCAmelCase__      ,      feature_extractor=lowerCAmelCase__      ,      )
										self.register_to_config(requires_safety_checker=lowerCAmelCase__     )


				@property
				def 		__magic_name__(	self      :Union[str, Any]     )		->      Dict[str, Any]:
										return {k: getattr(self      ,      lowerCAmelCase__     ) for k in self.config.keys() if not k.startswith('''_'''     )}


				def 		__magic_name__(	self      :str      ,      lowerCAmelCase__      :Optional[Union[str, int]] = "auto"     )		->      str:
										if slice_size == "auto":
																# half the attention head size is usually a good trade-off between
																# speed and memory
																__SCREAMING_SNAKE_CASE						:					Union[str, Any]		      =		self.unet.config.attention_head_dim // 2
										self.unet.set_attention_slice(lowerCAmelCase__     )


				def 		__magic_name__(	self      :Optional[int]     )		->      Union[str, Any]:
										self.enable_attention_slicing(lowerCAmelCase__     )


				@torch.no_grad()
				def 		__magic_name__(	self      :str      ,      lowerCAmelCase__      :Union[str, List[str]]      ,      lowerCAmelCase__      :Union[torch.FloatTensor, PIL.Image.Image]      ,      lowerCAmelCase__      :Union[torch.FloatTensor, PIL.Image.Image]      ,      lowerCAmelCase__      :float = 0.8      ,      lowerCAmelCase__      :Optional[int] = 50      ,      lowerCAmelCase__      :Optional[float] = 7.5      ,      lowerCAmelCase__      :Optional[Union[str, List[str]]] = None      ,      lowerCAmelCase__      :Optional[int] = 1      ,      lowerCAmelCase__      :Optional[float] = 0.0      ,      lowerCAmelCase__      :Optional[torch.Generator] = None      ,      lowerCAmelCase__      :Optional[str] = "pil"      ,      lowerCAmelCase__      :bool = True      ,      lowerCAmelCase__      :Optional[Callable[[int, int, torch.FloatTensor], None]] = None      ,      lowerCAmelCase__      :int = 1      ,      )		->      Any:
										# For more information on how this function works, please see: https://huggingface.co/docs/diffusers/api/pipelines/stable_diffusion#diffusers.StableDiffusionImg2ImgPipeline
										return StableDiffusionInpaintPipelineLegacy(**self.components     )(
										    prompt=lowerCAmelCase__      ,      image=lowerCAmelCase__      ,      mask_image=lowerCAmelCase__      ,      strength=lowerCAmelCase__      ,      num_inference_steps=lowerCAmelCase__      ,      guidance_scale=lowerCAmelCase__      ,      negative_prompt=lowerCAmelCase__      ,      num_images_per_prompt=lowerCAmelCase__      ,      eta=lowerCAmelCase__      ,      generator=lowerCAmelCase__      ,      output_type=lowerCAmelCase__      ,      return_dict=lowerCAmelCase__      ,      callback=lowerCAmelCase__      ,      )


				@torch.no_grad()
				def 		__magic_name__(	self      :Dict      ,      lowerCAmelCase__      :Union[str, List[str]]      ,      lowerCAmelCase__      :Union[torch.FloatTensor, PIL.Image.Image]      ,      lowerCAmelCase__      :float = 0.8      ,      lowerCAmelCase__      :Optional[int] = 50      ,      lowerCAmelCase__      :Optional[float] = 7.5      ,      lowerCAmelCase__      :Optional[Union[str, List[str]]] = None      ,      lowerCAmelCase__      :Optional[int] = 1      ,      lowerCAmelCase__      :Optional[float] = 0.0      ,      lowerCAmelCase__      :Optional[torch.Generator] = None      ,      lowerCAmelCase__      :Optional[str] = "pil"      ,      lowerCAmelCase__      :bool = True      ,      lowerCAmelCase__      :Optional[Callable[[int, int, torch.FloatTensor], None]] = None      ,      lowerCAmelCase__      :int = 1      ,      **lowerCAmelCase__      :Optional[Any]      ,      )		->      Dict:
										# For more information on how this function works, please see: https://huggingface.co/docs/diffusers/api/pipelines/stable_diffusion#diffusers.StableDiffusionImg2ImgPipeline
										return StableDiffusionImgaImgPipeline(**self.components     )(
										    prompt=lowerCAmelCase__      ,      image=lowerCAmelCase__      ,      strength=lowerCAmelCase__      ,      num_inference_steps=lowerCAmelCase__      ,      guidance_scale=lowerCAmelCase__      ,      negative_prompt=lowerCAmelCase__      ,      num_images_per_prompt=lowerCAmelCase__      ,      eta=lowerCAmelCase__      ,      generator=lowerCAmelCase__      ,      output_type=lowerCAmelCase__      ,      return_dict=lowerCAmelCase__      ,      callback=lowerCAmelCase__      ,      callback_steps=lowerCAmelCase__      ,      )



				@torch.no_grad()
				def 		__magic_name__(	self      :Tuple      ,      lowerCAmelCase__      :Union[str, List[str]]      ,      lowerCAmelCase__      :int = 512      ,      lowerCAmelCase__      :int = 512      ,      lowerCAmelCase__      :int = 50      ,      lowerCAmelCase__      :float = 7.5      ,      lowerCAmelCase__      :Optional[Union[str, List[str]]] = None      ,      lowerCAmelCase__      :Optional[int] = 1      ,      lowerCAmelCase__      :float = 0.0      ,      lowerCAmelCase__      :Optional[torch.Generator] = None      ,      lowerCAmelCase__      :Optional[torch.FloatTensor] = None      ,      lowerCAmelCase__      :Optional[str] = "pil"      ,      lowerCAmelCase__      :bool = True      ,      lowerCAmelCase__      :Optional[Callable[[int, int, torch.FloatTensor], None]] = None      ,      lowerCAmelCase__      :int = 1      ,      )		->      Optional[int]:
										# For more information on how this function https://huggingface.co/docs/diffusers/api/pipelines/stable_diffusion#diffusers.StableDiffusionPipeline
										return StableDiffusionPipeline(**self.components     )(
										    prompt=lowerCAmelCase__      ,      height=lowerCAmelCase__      ,      width=lowerCAmelCase__      ,      num_inference_steps=lowerCAmelCase__      ,      guidance_scale=lowerCAmelCase__      ,      negative_prompt=lowerCAmelCase__      ,      num_images_per_prompt=lowerCAmelCase__      ,      eta=lowerCAmelCase__      ,      generator=lowerCAmelCase__      ,      latents=lowerCAmelCase__      ,      output_type=lowerCAmelCase__      ,      return_dict=lowerCAmelCase__      ,      callback=lowerCAmelCase__      ,      callback_steps=lowerCAmelCase__      ,      )
