




import gc
import random
import tempfile
import unittest

import numpy as np
import torch
from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer

from diffusers import AutoencoderKL, DDIMScheduler, LMSDiscreteScheduler, PNDMScheduler, UNetaDConditionModel
from diffusers.pipelines.semantic_stable_diffusion import SemanticStableDiffusionPipeline as StableDiffusionPipeline
from diffusers.utils import floats_tensor, nightly, torch_device
from diffusers.utils.testing_utils import enable_full_determinism, require_torch_gpu


enable_full_determinism()





class  __lowerCamelCase       (    unittest.TestCase    ):




    """simple docstring"""

    def    a      (       self     :     str   )      ->       Tuple:
         # clean up the VRAM after each test
         super().tearDown()
         gc.collect()
         torch.cuda.empty_cache()


    @property
    def    a      (       self     :     Any   )      ->       Any:
         lowerCAmelCase__		= 1
         lowerCAmelCase__		= 3
         lowerCAmelCase__		= (32, 32)

         lowerCAmelCase__		= floats_tensor((batch_size, num_channels) + sizes   ,	rng=random.Random(0   )   ).to(SCREAMING_SNAKE_CASE__   )
         return image


    @property
    def    a      (       self     :     int   )      ->       Dict:
         torch.manual_seed(0   )
         lowerCAmelCase__		= UNetaDConditionModel(
             block_out_channels=(32, 64)   ,	layers_per_block=2   ,	sample_size=32   ,	in_channels=4   ,	out_channels=4   ,	down_block_types=("DownBlock2D", "CrossAttnDownBlock2D")   ,	up_block_types=("CrossAttnUpBlock2D", "UpBlock2D")   ,	cross_attention_dim=32   ,	)
         return model


    @property
    def    a      (       self     :     List[Any]   )      ->       Tuple:
         torch.manual_seed(0   )
         lowerCAmelCase__		= AutoencoderKL(
             block_out_channels=[32, 64]   ,	in_channels=3   ,	out_channels=3   ,	down_block_types=["DownEncoderBlock2D", "DownEncoderBlock2D"]   ,	up_block_types=["UpDecoderBlock2D", "UpDecoderBlock2D"]   ,	latent_channels=4   ,	)
         return model


    @property
    def    a      (       self     :     Any   )      ->       Union[str, Any]:
         torch.manual_seed(0   )
         lowerCAmelCase__		= CLIPTextConfig(
             bos_token_id=0   ,	eos_token_id=2   ,	hidden_size=32   ,	intermediate_size=37   ,	layer_norm_eps=1e-0_5   ,	num_attention_heads=4   ,	num_hidden_layers=5   ,	pad_token_id=1   ,	vocab_size=1_000   ,	)
         return CLIPTextModel(SCREAMING_SNAKE_CASE__   )


    @property
    def    a      (       self     :     str   )      ->       str:
         def extract(*SCREAMING_SNAKE_CASE__     :     List[str]   ,	**SCREAMING_SNAKE_CASE__     :     Dict   ):





              class  __lowerCamelCase       :




                  """simple docstring"""

                  def __init__(       self     :     int   )      ->       str:
                       lowerCAmelCase__		= torch.ones([0]   )


                  def    a      (       self     :     Any   ,	SCREAMING_SNAKE_CASE__     :     int   )      ->       Union[str, Any]:
                       self.pixel_values.to(SCREAMING_SNAKE_CASE__   )
                       return self






              return Out()

         return extract


    def    a      (       self     :     int   )      ->       int:
         lowerCAmelCase__		= "cpu"  # ensure determinism for the device-dependent torch.Generator
         lowerCAmelCase__		= self.dummy_cond_unet
         lowerCAmelCase__		= DDIMScheduler(
             beta_start=0.00_085   ,	beta_end=0.012   ,	beta_schedule="scaled_linear"   ,	clip_sample=SCREAMING_SNAKE_CASE__   ,	set_alpha_to_one=SCREAMING_SNAKE_CASE__   ,	)

         lowerCAmelCase__		= self.dummy_vae
         lowerCAmelCase__		= self.dummy_text_encoder
         lowerCAmelCase__		= CLIPTokenizer.from_pretrained("hf-internal-testing/tiny-random-clip"   )

         # make sure here that pndm scheduler skips prk
         lowerCAmelCase__		= StableDiffusionPipeline(
             unet=SCREAMING_SNAKE_CASE__   ,	scheduler=SCREAMING_SNAKE_CASE__   ,	vae=SCREAMING_SNAKE_CASE__   ,	text_encoder=SCREAMING_SNAKE_CASE__   ,	tokenizer=SCREAMING_SNAKE_CASE__   ,	safety_checker=SCREAMING_SNAKE_CASE__   ,	feature_extractor=self.dummy_extractor   ,	)
         lowerCAmelCase__		= sd_pipe.to(SCREAMING_SNAKE_CASE__   )
         sd_pipe.set_progress_bar_config(disable=SCREAMING_SNAKE_CASE__   )

         lowerCAmelCase__		= "A painting of a squirrel eating a burger"

         lowerCAmelCase__		= torch.Generator(device=SCREAMING_SNAKE_CASE__   ).manual_seed(0   )
         lowerCAmelCase__		= sd_pipe([prompt]   ,	generator=SCREAMING_SNAKE_CASE__   ,	guidance_scale=6.0   ,	num_inference_steps=2   ,	output_type="np"   )
         lowerCAmelCase__		= output.images

         lowerCAmelCase__		= torch.Generator(device=SCREAMING_SNAKE_CASE__   ).manual_seed(0   )
         lowerCAmelCase__		= sd_pipe(
             [prompt]   ,	generator=SCREAMING_SNAKE_CASE__   ,	guidance_scale=6.0   ,	num_inference_steps=2   ,	output_type="np"   ,	return_dict=SCREAMING_SNAKE_CASE__   ,	)[0]

         lowerCAmelCase__		= image[0, -3:, -3:, -1]
         lowerCAmelCase__		= image_from_tuple[0, -3:, -3:, -1]

         assert image.shape == (1, 64, 64, 3)
         lowerCAmelCase__		= np.array([0.5_753, 0.6_114, 0.5_001, 0.5_034, 0.5_470, 0.4_729, 0.4_971, 0.4_867, 0.4_867]   )

         assert np.abs(image_slice.flatten() - expected_slice   ).max() < 1e-2
         assert np.abs(image_from_tuple_slice.flatten() - expected_slice   ).max() < 1e-2


    def    a      (       self     :     Any   )      ->       str:
         lowerCAmelCase__		= "cpu"  # ensure determinism for the device-dependent torch.Generator
         lowerCAmelCase__		= self.dummy_cond_unet
         lowerCAmelCase__		= PNDMScheduler(skip_prk_steps=SCREAMING_SNAKE_CASE__   )
         lowerCAmelCase__		= self.dummy_vae
         lowerCAmelCase__		= self.dummy_text_encoder
         lowerCAmelCase__		= CLIPTokenizer.from_pretrained("hf-internal-testing/tiny-random-clip"   )

         # make sure here that pndm scheduler skips prk
         lowerCAmelCase__		= StableDiffusionPipeline(
             unet=SCREAMING_SNAKE_CASE__   ,	scheduler=SCREAMING_SNAKE_CASE__   ,	vae=SCREAMING_SNAKE_CASE__   ,	text_encoder=SCREAMING_SNAKE_CASE__   ,	tokenizer=SCREAMING_SNAKE_CASE__   ,	safety_checker=SCREAMING_SNAKE_CASE__   ,	feature_extractor=self.dummy_extractor   ,	)
         lowerCAmelCase__		= sd_pipe.to(SCREAMING_SNAKE_CASE__   )
         sd_pipe.set_progress_bar_config(disable=SCREAMING_SNAKE_CASE__   )

         lowerCAmelCase__		= "A painting of a squirrel eating a burger"
         lowerCAmelCase__		= torch.Generator(device=SCREAMING_SNAKE_CASE__   ).manual_seed(0   )
         lowerCAmelCase__		= sd_pipe([prompt]   ,	generator=SCREAMING_SNAKE_CASE__   ,	guidance_scale=6.0   ,	num_inference_steps=2   ,	output_type="np"   )

         lowerCAmelCase__		= output.images

         lowerCAmelCase__		= torch.Generator(device=SCREAMING_SNAKE_CASE__   ).manual_seed(0   )
         lowerCAmelCase__		= sd_pipe(
             [prompt]   ,	generator=SCREAMING_SNAKE_CASE__   ,	guidance_scale=6.0   ,	num_inference_steps=2   ,	output_type="np"   ,	return_dict=SCREAMING_SNAKE_CASE__   ,	)[0]

         lowerCAmelCase__		= image[0, -3:, -3:, -1]
         lowerCAmelCase__		= image_from_tuple[0, -3:, -3:, -1]

         assert image.shape == (1, 64, 64, 3)
         lowerCAmelCase__		= np.array([0.5_122, 0.5_712, 0.4_825, 0.5_053, 0.5_646, 0.4_769, 0.5_179, 0.4_894, 0.4_994]   )

         assert np.abs(image_slice.flatten() - expected_slice   ).max() < 1e-2
         assert np.abs(image_from_tuple_slice.flatten() - expected_slice   ).max() < 1e-2


    def    a      (       self     :     Dict   )      ->       int:
         lowerCAmelCase__		= StableDiffusionPipeline.from_pretrained(
             "hf-internal-testing/tiny-stable-diffusion-lms-pipe"   ,	safety_checker=SCREAMING_SNAKE_CASE__   )
         assert isinstance(SCREAMING_SNAKE_CASE__   ,	SCREAMING_SNAKE_CASE__   )
         assert isinstance(pipe.scheduler   ,	SCREAMING_SNAKE_CASE__   )
         assert pipe.safety_checker is None

         lowerCAmelCase__		= pipe("example prompt"   ,	num_inference_steps=2   ).images[0]
         assert image is not None

         # check that there's no error when saving a pipeline with one of the models being None
         with tempfile.TemporaryDirectory() as tmpdirname:
              pipe.save_pretrained(SCREAMING_SNAKE_CASE__   )
              lowerCAmelCase__		= StableDiffusionPipeline.from_pretrained(SCREAMING_SNAKE_CASE__   )

         # sanity check that the pipeline still works
         assert pipe.safety_checker is None
         lowerCAmelCase__		= pipe("example prompt"   ,	num_inference_steps=2   ).images[0]
         assert image is not None


    @unittest.skipIf(torch_device != "cuda"   ,	"This test requires a GPU"   )
    def    a      (       self     :     Optional[Any]   )      ->       Optional[Any]:
         lowerCAmelCase__		= self.dummy_cond_unet
         lowerCAmelCase__		= PNDMScheduler(skip_prk_steps=SCREAMING_SNAKE_CASE__   )
         lowerCAmelCase__		= self.dummy_vae
         lowerCAmelCase__		= self.dummy_text_encoder
         lowerCAmelCase__		= CLIPTokenizer.from_pretrained("hf-internal-testing/tiny-random-clip"   )

         # put models in fp16
         lowerCAmelCase__		= unet.half()
         lowerCAmelCase__		= vae.half()
         lowerCAmelCase__		= bert.half()

         # make sure here that pndm scheduler skips prk
         lowerCAmelCase__		= StableDiffusionPipeline(
             unet=SCREAMING_SNAKE_CASE__   ,	scheduler=SCREAMING_SNAKE_CASE__   ,	vae=SCREAMING_SNAKE_CASE__   ,	text_encoder=SCREAMING_SNAKE_CASE__   ,	tokenizer=SCREAMING_SNAKE_CASE__   ,	safety_checker=SCREAMING_SNAKE_CASE__   ,	feature_extractor=self.dummy_extractor   ,	)
         lowerCAmelCase__		= sd_pipe.to(SCREAMING_SNAKE_CASE__   )
         sd_pipe.set_progress_bar_config(disable=SCREAMING_SNAKE_CASE__   )

         lowerCAmelCase__		= "A painting of a squirrel eating a burger"
         lowerCAmelCase__		= sd_pipe([prompt]   ,	num_inference_steps=2   ,	output_type="np"   ).images

         assert image.shape == (1, 64, 64, 3)






@nightly
@require_torch_gpu
class  __lowerCamelCase       (    unittest.TestCase    ):




    """simple docstring"""

    def    a      (       self     :     Union[str, Any]   )      ->       List[str]:
         # clean up the VRAM after each test
         super().tearDown()
         gc.collect()
         torch.cuda.empty_cache()


    def    a      (       self     :     str   )      ->       Tuple:
         lowerCAmelCase__		= "cuda"
         lowerCAmelCase__		= StableDiffusionPipeline.from_pretrained("runwayml/stable-diffusion-v1-5"   )
         lowerCAmelCase__		= pipe.to(SCREAMING_SNAKE_CASE__   )
         pipe.set_progress_bar_config(disable=SCREAMING_SNAKE_CASE__   )

         lowerCAmelCase__		= "a photo of a cat"
         lowerCAmelCase__		= {
             "editing_prompt": ["sunglasses"],
             "reverse_editing_direction": [False],
             "edit_warmup_steps": 10,
             "edit_guidance_scale": 6,
             "edit_threshold": 0.95,
             "edit_momentum_scale": 0.5,
             "edit_mom_beta": 0.6,
         }

         lowerCAmelCase__		= 3
         lowerCAmelCase__		= 7

         # no sega enabled
         lowerCAmelCase__		= torch.Generator(SCREAMING_SNAKE_CASE__   )
         generator.manual_seed(SCREAMING_SNAKE_CASE__   )
         lowerCAmelCase__		= pipe(
             [prompt]   ,	generator=SCREAMING_SNAKE_CASE__   ,	guidance_scale=SCREAMING_SNAKE_CASE__   ,	num_inference_steps=50   ,	output_type="np"   ,	width=512   ,	height=512   ,	)

         lowerCAmelCase__		= output.images
         lowerCAmelCase__		= image[0, -3:, -3:, -1]
         lowerCAmelCase__		= [
             0.34_673_113,
             0.38_492_733,
             0.37_597_352,
             0.34_086_335,
             0.35_650_748,
             0.35_579_205,
             0.3_384_763,
             0.34_340_236,
             0.3_573_271,
         ]

         assert image.shape == (1, 512, 512, 3)

         assert np.abs(image_slice.flatten() - expected_slice   ).max() < 1e-2

         # with sega enabled
         # generator = torch.manual_seed(seed)
         generator.manual_seed(SCREAMING_SNAKE_CASE__   )
         lowerCAmelCase__		= pipe(
             [prompt]   ,	generator=SCREAMING_SNAKE_CASE__   ,	guidance_scale=SCREAMING_SNAKE_CASE__   ,	num_inference_steps=50   ,	output_type="np"   ,	width=512   ,	height=512   ,	**SCREAMING_SNAKE_CASE__   ,	)

         lowerCAmelCase__		= output.images
         lowerCAmelCase__		= image[0, -3:, -3:, -1]
         lowerCAmelCase__		= [
             0.41_887_826,
             0.37_728_766,
             0.30_138_272,
             0.41_416_335,
             0.41_664_985,
             0.36_283_392,
             0.36_191_246,
             0.43_364_465,
             0.43_001_732,
         ]

         assert image.shape == (1, 512, 512, 3)

         assert np.abs(image_slice.flatten() - expected_slice   ).max() < 1e-2


    def    a      (       self     :     int   )      ->       str:
         lowerCAmelCase__		= "cuda"
         lowerCAmelCase__		= StableDiffusionPipeline.from_pretrained("runwayml/stable-diffusion-v1-5"   )
         lowerCAmelCase__		= pipe.to(SCREAMING_SNAKE_CASE__   )
         pipe.set_progress_bar_config(disable=SCREAMING_SNAKE_CASE__   )

         lowerCAmelCase__		= "an image of a crowded boulevard, realistic, 4k"
         lowerCAmelCase__		= {
             "editing_prompt": "crowd, crowded, people",
             "reverse_editing_direction": True,
             "edit_warmup_steps": 10,
             "edit_guidance_scale": 8.3,
             "edit_threshold": 0.9,
             "edit_momentum_scale": 0.5,
             "edit_mom_beta": 0.6,
         }

         lowerCAmelCase__		= 9
         lowerCAmelCase__		= 7

         # no sega enabled
         lowerCAmelCase__		= torch.Generator(SCREAMING_SNAKE_CASE__   )
         generator.manual_seed(SCREAMING_SNAKE_CASE__   )
         lowerCAmelCase__		= pipe(
             [prompt]   ,	generator=SCREAMING_SNAKE_CASE__   ,	guidance_scale=SCREAMING_SNAKE_CASE__   ,	num_inference_steps=50   ,	output_type="np"   ,	width=512   ,	height=512   ,	)

         lowerCAmelCase__		= output.images
         lowerCAmelCase__		= image[0, -3:, -3:, -1]
         lowerCAmelCase__		= [
             0.43_497_998,
             0.91_814_065,
             0.7_540_739,
             0.55_580_205,
             0.8_467_265,
             0.5_389_691,
             0.62_574_506,
             0.58_897_763,
             0.50_926_757,
         ]

         assert image.shape == (1, 512, 512, 3)

         assert np.abs(image_slice.flatten() - expected_slice   ).max() < 1e-2

         # with sega enabled
         # generator = torch.manual_seed(seed)
         generator.manual_seed(SCREAMING_SNAKE_CASE__   )
         lowerCAmelCase__		= pipe(
             [prompt]   ,	generator=SCREAMING_SNAKE_CASE__   ,	guidance_scale=SCREAMING_SNAKE_CASE__   ,	num_inference_steps=50   ,	output_type="np"   ,	width=512   ,	height=512   ,	**SCREAMING_SNAKE_CASE__   ,	)

         lowerCAmelCase__		= output.images
         lowerCAmelCase__		= image[0, -3:, -3:, -1]
         lowerCAmelCase__		= [
             0.3_089_719,
             0.30_500_144,
             0.29_016_042,
             0.30_630_964,
             0.325_687,
             0.29_419_225,
             0.2_908_091,
             0.28_723_598,
             0.27_696_294,
         ]

         assert image.shape == (1, 512, 512, 3)

         assert np.abs(image_slice.flatten() - expected_slice   ).max() < 1e-2


    def    a      (       self     :     int   )      ->       List[str]:
         lowerCAmelCase__		= "cuda"
         lowerCAmelCase__		= StableDiffusionPipeline.from_pretrained("runwayml/stable-diffusion-v1-5"   )
         lowerCAmelCase__		= pipe.to(SCREAMING_SNAKE_CASE__   )
         pipe.set_progress_bar_config(disable=SCREAMING_SNAKE_CASE__   )

         lowerCAmelCase__		= "a castle next to a river"
         lowerCAmelCase__		= {
             "editing_prompt": ["boat on a river, boat", "monet, impression, sunrise"],
             "reverse_editing_direction": False,
             "edit_warmup_steps": [15, 18],
             "edit_guidance_scale": 6,
             "edit_threshold": [0.9, 0.8],
             "edit_momentum_scale": 0.5,
             "edit_mom_beta": 0.6,
         }

         lowerCAmelCase__		= 48
         lowerCAmelCase__		= 7

         # no sega enabled
         lowerCAmelCase__		= torch.Generator(SCREAMING_SNAKE_CASE__   )
         generator.manual_seed(SCREAMING_SNAKE_CASE__   )
         lowerCAmelCase__		= pipe(
             [prompt]   ,	generator=SCREAMING_SNAKE_CASE__   ,	guidance_scale=SCREAMING_SNAKE_CASE__   ,	num_inference_steps=50   ,	output_type="np"   ,	width=512   ,	height=512   ,	)

         lowerCAmelCase__		= output.images
         lowerCAmelCase__		= image[0, -3:, -3:, -1]
         lowerCAmelCase__		= [
             0.75_163_555,
             0.76_037_145,
             0.61_785,
             0.9_189_673,
             0.8_627_701,
             0.85_189_694,
             0.8_512_813,
             0.87_012_076,
             0.8_312_857,
         ]

         assert image.shape == (1, 512, 512, 3)

         assert np.abs(image_slice.flatten() - expected_slice   ).max() < 1e-2

         # with sega enabled
         # generator = torch.manual_seed(seed)
         generator.manual_seed(SCREAMING_SNAKE_CASE__   )
         lowerCAmelCase__		= pipe(
             [prompt]   ,	generator=SCREAMING_SNAKE_CASE__   ,	guidance_scale=SCREAMING_SNAKE_CASE__   ,	num_inference_steps=50   ,	output_type="np"   ,	width=512   ,	height=512   ,	**SCREAMING_SNAKE_CASE__   ,	)

         lowerCAmelCase__		= output.images
         lowerCAmelCase__		= image[0, -3:, -3:, -1]
         lowerCAmelCase__		= [
             0.73_553_365,
             0.7_537_271,
             0.74_341_905,
             0.66_480_356,
             0.6_472_925,
             0.63_039_416,
             0.64_812_905,
             0.6_749_717,
             0.6_517_102,
         ]

         assert image.shape == (1, 512, 512, 3)

         assert np.abs(image_slice.flatten() - expected_slice   ).max() < 1e-2


    def    a      (       self     :     Optional[Any]   )      ->       Any:
         lowerCAmelCase__		= "cuda"
         lowerCAmelCase__		= StableDiffusionPipeline.from_pretrained("runwayml/stable-diffusion-v1-5"   ,	torch_dtype=torch.floataa   )
         lowerCAmelCase__		= pipe.to(SCREAMING_SNAKE_CASE__   )
         pipe.set_progress_bar_config(disable=SCREAMING_SNAKE_CASE__   )

         lowerCAmelCase__		= "a photo of a cat"
         lowerCAmelCase__		= {
             "editing_prompt": ["sunglasses"],
             "reverse_editing_direction": [False],
             "edit_warmup_steps": 10,
             "edit_guidance_scale": 6,
             "edit_threshold": 0.95,
             "edit_momentum_scale": 0.5,
             "edit_mom_beta": 0.6,
         }

         lowerCAmelCase__		= 3
         lowerCAmelCase__		= 7

         # no sega enabled
         lowerCAmelCase__		= torch.Generator(SCREAMING_SNAKE_CASE__   )
         generator.manual_seed(SCREAMING_SNAKE_CASE__   )
         lowerCAmelCase__		= pipe(
             [prompt]   ,	generator=SCREAMING_SNAKE_CASE__   ,	guidance_scale=SCREAMING_SNAKE_CASE__   ,	num_inference_steps=50   ,	output_type="np"   ,	width=512   ,	height=512   ,	)

         lowerCAmelCase__		= output.images
         lowerCAmelCase__		= image[0, -3:, -3:, -1]
         lowerCAmelCase__		= [
             0.34_887_695,
             0.3_876_953,
             0.375,
             0.34_423_828,
             0.3_581_543,
             0.35_717_773,
             0.3_383_789,
             0.34_570_312,
             0.359_375,
         ]

         assert image.shape == (1, 512, 512, 3)

         assert np.abs(image_slice.flatten() - expected_slice   ).max() < 1e-2

         # with sega enabled
         # generator = torch.manual_seed(seed)
         generator.manual_seed(SCREAMING_SNAKE_CASE__   )
         lowerCAmelCase__		= pipe(
             [prompt]   ,	generator=SCREAMING_SNAKE_CASE__   ,	guidance_scale=SCREAMING_SNAKE_CASE__   ,	num_inference_steps=50   ,	output_type="np"   ,	width=512   ,	height=512   ,	**SCREAMING_SNAKE_CASE__   ,	)

         lowerCAmelCase__		= output.images
         lowerCAmelCase__		= image[0, -3:, -3:, -1]
         lowerCAmelCase__		= [
             0.42_285_156,
             0.36_914_062,
             0.29_077_148,
             0.42_041_016,
             0.41_918_945,
             0.35_498_047,
             0.3_618_164,
             0.4_423_828,
             0.43_115_234,
         ]

         assert image.shape == (1, 512, 512, 3)

         assert np.abs(image_slice.flatten() - expected_slice   ).max() < 1e-2






from ..utils import (
    OptionalDependencyNotAvailable,
    is_flax_available,
    is_invisible_watermark_available,
    is_k_diffusion_available,
    is_librosa_available,
    is_note_seq_available,
    is_onnx_available,
    is_torch_available,
    is_transformers_available,
)


try:
     if not is_torch_available():
          raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
     from ..utils.dummy_pt_objects import *  # noqa F403
else:
     from .consistency_models import ConsistencyModelPipeline
     from .dance_diffusion import DanceDiffusionPipeline
     from .ddim import DDIMPipeline
     from .ddpm import DDPMPipeline
     from .dit import DiTPipeline
     from .latent_diffusion import LDMSuperResolutionPipeline
     from .latent_diffusion_uncond import LDMPipeline
     from .pipeline_utils import AudioPipelineOutput, DiffusionPipeline, ImagePipelineOutput
     from .pndm import PNDMPipeline
     from .repaint import RePaintPipeline
     from .score_sde_ve import ScoreSdeVePipeline
     from .stochastic_karras_ve import KarrasVePipeline

try:
     if not (is_torch_available() and is_librosa_available()):
          raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
     from ..utils.dummy_torch_and_librosa_objects import *  # noqa F403
else:
     from .audio_diffusion import AudioDiffusionPipeline, Mel

try:
     if not (is_torch_available() and is_transformers_available()):
          raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
     from ..utils.dummy_torch_and_transformers_objects import *  # noqa F403
else:
     from .alt_diffusion import AltDiffusionImgaImgPipeline, AltDiffusionPipeline
     from .audioldm import AudioLDMPipeline
     from .controlnet import (
         StableDiffusionControlNetImgaImgPipeline,
         StableDiffusionControlNetInpaintPipeline,
         StableDiffusionControlNetPipeline,
     )
     from .deepfloyd_if import (
         IFImgaImgPipeline,
         IFImgaImgSuperResolutionPipeline,
         IFInpaintingPipeline,
         IFInpaintingSuperResolutionPipeline,
         IFPipeline,
         IFSuperResolutionPipeline,
     )
     from .kandinsky import (
         KandinskyImgaImgPipeline,
         KandinskyInpaintPipeline,
         KandinskyPipeline,
         KandinskyPriorPipeline,
     )
     from .kandinskya_a import (
         KandinskyVaaControlnetImgaImgPipeline,
         KandinskyVaaControlnetPipeline,
         KandinskyVaaImgaImgPipeline,
         KandinskyVaaInpaintPipeline,
         KandinskyVaaPipeline,
         KandinskyVaaPriorEmbaEmbPipeline,
         KandinskyVaaPriorPipeline,
     )
     from .latent_diffusion import LDMTextToImagePipeline
     from .paint_by_example import PaintByExamplePipeline
     from .semantic_stable_diffusion import SemanticStableDiffusionPipeline
     from .shap_e import ShapEImgaImgPipeline, ShapEPipeline
     from .stable_diffusion import (
         CycleDiffusionPipeline,
         StableDiffusionAttendAndExcitePipeline,
         StableDiffusionDepthaImgPipeline,
         StableDiffusionDiffEditPipeline,
         StableDiffusionImageVariationPipeline,
         StableDiffusionImgaImgPipeline,
         StableDiffusionInpaintPipeline,
         StableDiffusionInpaintPipelineLegacy,
         StableDiffusionInstructPixaPixPipeline,
         StableDiffusionLatentUpscalePipeline,
         StableDiffusionLDMaDPipeline,
         StableDiffusionModelEditingPipeline,
         StableDiffusionPanoramaPipeline,
         StableDiffusionParadigmsPipeline,
         StableDiffusionPipeline,
         StableDiffusionPixaPixZeroPipeline,
         StableDiffusionSAGPipeline,
         StableDiffusionUpscalePipeline,
         StableUnCLIPImgaImgPipeline,
         StableUnCLIPPipeline,
     )
     from .stable_diffusion_safe import StableDiffusionPipelineSafe
     from .text_to_video_synthesis import TextToVideoSDPipeline, TextToVideoZeroPipeline, VideoToVideoSDPipeline
     from .unclip import UnCLIPImageVariationPipeline, UnCLIPPipeline
     from .unidiffuser import ImageTextPipelineOutput, UniDiffuserModel, UniDiffuserPipeline, UniDiffuserTextDecoder
     from .versatile_diffusion import (
         VersatileDiffusionDualGuidedPipeline,
         VersatileDiffusionImageVariationPipeline,
         VersatileDiffusionPipeline,
         VersatileDiffusionTextToImagePipeline,
     )
     from .vq_diffusion import VQDiffusionPipeline


try:
     if not (is_torch_available() and is_transformers_available() and is_invisible_watermark_available()):
          raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
     from ..utils.dummy_torch_and_transformers_and_invisible_watermark_objects import *  # noqa F403
else:
     from .stable_diffusion_xl import StableDiffusionXLImgaImgPipeline, StableDiffusionXLPipeline

try:
     if not is_onnx_available():
          raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
     from ..utils.dummy_onnx_objects import *  # noqa F403
else:
     from .onnx_utils import OnnxRuntimeModel

try:
     if not (is_torch_available() and is_transformers_available() and is_onnx_available()):
          raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
     from ..utils.dummy_torch_and_transformers_and_onnx_objects import *  # noqa F403
else:
     from .stable_diffusion import (
         OnnxStableDiffusionImgaImgPipeline,
         OnnxStableDiffusionInpaintPipeline,
         OnnxStableDiffusionInpaintPipelineLegacy,
         OnnxStableDiffusionPipeline,
         OnnxStableDiffusionUpscalePipeline,
         StableDiffusionOnnxPipeline,
     )

try:
     if not (is_torch_available() and is_transformers_available() and is_k_diffusion_available()):
          raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
     from ..utils.dummy_torch_and_transformers_and_k_diffusion_objects import *  # noqa F403
else:
     from .stable_diffusion import StableDiffusionKDiffusionPipeline

try:
     if not is_flax_available():
          raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
     from ..utils.dummy_flax_objects import *  # noqa F403
else:
     from .pipeline_flax_utils import FlaxDiffusionPipeline


try:
     if not (is_flax_available() and is_transformers_available()):
          raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
     from ..utils.dummy_flax_and_transformers_objects import *  # noqa F403
else:
     from .controlnet import FlaxStableDiffusionControlNetPipeline
     from .stable_diffusion import (
         FlaxStableDiffusionImgaImgPipeline,
         FlaxStableDiffusionInpaintPipeline,
         FlaxStableDiffusionPipeline,
     )
try:
     if not (is_transformers_available() and is_torch_available() and is_note_seq_available()):
          raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
     from ..utils.dummy_transformers_and_torch_and_note_seq_objects import *  # noqa F403
else:
     from .spectrogram_diffusion import MidiProcessor, SpectrogramDiffusionPipeline
