




# This model implementation is heavily inspired by https://github.com/haofanwang/ControlNet-for-Diffusers/

import gc
import random
import tempfile
import unittest

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

from diffusers import (
    AutoencoderKL,
    ControlNetModel,
    DDIMScheduler,
    StableDiffusionControlNetImgaImgPipeline,
    UNetaDConditionModel,
)
from diffusers.pipelines.stable_diffusion.pipeline_stable_diffusion_controlnet import MultiControlNetModel
from diffusers.utils import floats_tensor, load_image, load_numpy, randn_tensor, slow, torch_device
from diffusers.utils.import_utils import is_xformers_available
from diffusers.utils.testing_utils import enable_full_determinism, require_torch_gpu

from ..pipeline_params import (
    IMAGE_TO_IMAGE_IMAGE_PARAMS,
    TEXT_GUIDED_IMAGE_VARIATION_BATCH_PARAMS,
    TEXT_GUIDED_IMAGE_VARIATION_PARAMS,
)
from ..test_pipelines_common import (
    PipelineKarrasSchedulerTesterMixin,
    PipelineLatentTesterMixin,
    PipelineTesterMixin,
)


enable_full_determinism()
class       a__   ( snake_case__			,    snake_case__			,    snake_case__			,    unittest.TestCase				):
						_a							:   Tuple =   StableDiffusionControlNetImgaImgPipeline
						_a							:   List[Any] =   TEXT_GUIDED_IMAGE_VARIATION_PARAMS - {"""height""", """width"""}
						_a							:   str =   TEXT_GUIDED_IMAGE_VARIATION_BATCH_PARAMS
						_a							:   Union[str, Any] =   IMAGE_TO_IMAGE_IMAGE_PARAMS.union({"""control_image"""}				)
						_a							:   int =   IMAGE_TO_IMAGE_IMAGE_PARAMS






						def     __SCREAMING_SNAKE_CASE(       self      ):




											"""simple docstring"""



											torch.manual_seed(0      )
											__lowerCAmelCase           =	UNetaDConditionModel(
											    block_out_channels=(3_2, 6_4)		,      layers_per_block=2		,      sample_size=3_2		,      in_channels=4		,      out_channels=4		,      down_block_types=("DownBlock2D", "CrossAttnDownBlock2D")		,      up_block_types=("CrossAttnUpBlock2D", "UpBlock2D")		,      cross_attention_dim=3_2		,      )
											torch.manual_seed(0      )
											__lowerCAmelCase           =	ControlNetModel(
											    block_out_channels=(3_2, 6_4)		,      layers_per_block=2		,      in_channels=4		,      down_block_types=("DownBlock2D", "CrossAttnDownBlock2D")		,      cross_attention_dim=3_2		,      conditioning_embedding_out_channels=(1_6, 3_2)		,      )
											torch.manual_seed(0      )
											__lowerCAmelCase           =	DDIMScheduler(
											    beta_start=0.0_00_85		,      beta_end=0.0_12		,      beta_schedule="scaled_linear"		,      clip_sample=_A		,      set_alpha_to_one=_A		,      )
											torch.manual_seed(0      )
											__lowerCAmelCase           =	AutoencoderKL(
											    block_out_channels=[3_2, 6_4]		,      in_channels=3		,      out_channels=3		,      down_block_types=["DownEncoderBlock2D", "DownEncoderBlock2D"]		,      up_block_types=["UpDecoderBlock2D", "UpDecoderBlock2D"]		,      latent_channels=4		,      )
											torch.manual_seed(0      )
											__lowerCAmelCase           =	CLIPTextConfig(
											    bos_token_id=0		,      eos_token_id=2		,      hidden_size=3_2		,      intermediate_size=3_7		,      layer_norm_eps=1E-0_5		,      num_attention_heads=4		,      num_hidden_layers=5		,      pad_token_id=1		,      vocab_size=1_0_0_0		,      )
											__lowerCAmelCase           =	CLIPTextModel(_A      )
											__lowerCAmelCase           =	CLIPTokenizer.from_pretrained("hf-internal-testing/tiny-random-clip"      )

											__lowerCAmelCase           =	{
											    "unet": unet,
											    "controlnet": controlnet,
											    "scheduler": scheduler,
											    "vae": vae,
											    "text_encoder": text_encoder,
											    "tokenizer": tokenizer,
											    "safety_checker": None,
											    "feature_extractor": None,
											}
											return components






						def     __SCREAMING_SNAKE_CASE(       self		,      _A		,      _A=0      ):




											"""simple docstring"""



											if str(_A      ).startswith("mps"      ):
																__lowerCAmelCase           =	torch.manual_seed(_A      )
											else:
																__lowerCAmelCase           =	torch.Generator(device=_A      ).manual_seed(_A      )

											__lowerCAmelCase           =	2
											__lowerCAmelCase           =	randn_tensor(
											    (1, 3, 3_2 * controlnet_embedder_scale_factor, 3_2 * controlnet_embedder_scale_factor)		,      generator=_A		,      device=torch.device(_A      )		,      )
											__lowerCAmelCase           =	floats_tensor(control_image.shape		,      rng=random.Random(_A      )      ).to(_A      )
											__lowerCAmelCase           =	image.cpu().permute(0		,      2		,      3		,      1      )[0]
											__lowerCAmelCase           =	Image.fromarray(np.uinta(_A      )      ).convert("RGB"      ).resize((6_4, 6_4)      )
											__lowerCAmelCase           =	{
											    "prompt": "A painting of a squirrel eating a burger",
											    "generator": generator,
											    "num_inference_steps": 2,
											    "guidance_scale": 6.0,
											    "output_type": "numpy",
											    "image": image,
											    "control_image": control_image,
											}

											return inputs






						def     __SCREAMING_SNAKE_CASE(       self      ):




											"""simple docstring"""



											return self._test_attention_slicing_forward_pass(expected_max_diff=2E-3      )






						@unittest.skipIf(
						    torch_device != "cuda" or not is_xformers_available()		,      reason="XFormers attention is only available with CUDA and `xformers` installed"		,      )
						def     __SCREAMING_SNAKE_CASE(       self      ):




											"""simple docstring"""



											self._test_xformers_attention_forwardGenerator_pass(expected_max_diff=2E-3      )






						def     __SCREAMING_SNAKE_CASE(       self      ):




											"""simple docstring"""



											self._test_inference_batch_single_identical(expected_max_diff=2E-3      )






class       a__   ( snake_case__			,    snake_case__			,    unittest.TestCase				):
						_a							:   Union[str, Any] =   StableDiffusionControlNetImgaImgPipeline
						_a							:   Any =   TEXT_GUIDED_IMAGE_VARIATION_PARAMS - {"""height""", """width"""}
						_a							:   Optional[Any] =   TEXT_GUIDED_IMAGE_VARIATION_BATCH_PARAMS
						_a							:   Any =   frozenset([]				)  # TO_DO: add image_params once refactored VaeImageProcessor.preprocess






						def     __SCREAMING_SNAKE_CASE(       self      ):




											"""simple docstring"""



											torch.manual_seed(0      )
											__lowerCAmelCase           =	UNetaDConditionModel(
											    block_out_channels=(3_2, 6_4)		,      layers_per_block=2		,      sample_size=3_2		,      in_channels=4		,      out_channels=4		,      down_block_types=("DownBlock2D", "CrossAttnDownBlock2D")		,      up_block_types=("CrossAttnUpBlock2D", "UpBlock2D")		,      cross_attention_dim=3_2		,      )
											torch.manual_seed(0      )

											def init_weights(_A      ):
																if isinstance(_A		,      torch.nn.Convad      ):
																					torch.nn.init.normal(m.weight      )
																					m.bias.data.fill_(1.0      )

											__lowerCAmelCase           =	ControlNetModel(
											    block_out_channels=(3_2, 6_4)		,      layers_per_block=2		,      in_channels=4		,      down_block_types=("DownBlock2D", "CrossAttnDownBlock2D")		,      cross_attention_dim=3_2		,      conditioning_embedding_out_channels=(1_6, 3_2)		,      )
											controlneta.controlnet_down_blocks.apply(_A      )

											torch.manual_seed(0      )
											__lowerCAmelCase           =	ControlNetModel(
											    block_out_channels=(3_2, 6_4)		,      layers_per_block=2		,      in_channels=4		,      down_block_types=("DownBlock2D", "CrossAttnDownBlock2D")		,      cross_attention_dim=3_2		,      conditioning_embedding_out_channels=(1_6, 3_2)		,      )
											controlneta.controlnet_down_blocks.apply(_A      )

											torch.manual_seed(0      )
											__lowerCAmelCase           =	DDIMScheduler(
											    beta_start=0.0_00_85		,      beta_end=0.0_12		,      beta_schedule="scaled_linear"		,      clip_sample=_A		,      set_alpha_to_one=_A		,      )
											torch.manual_seed(0      )
											__lowerCAmelCase           =	AutoencoderKL(
											    block_out_channels=[3_2, 6_4]		,      in_channels=3		,      out_channels=3		,      down_block_types=["DownEncoderBlock2D", "DownEncoderBlock2D"]		,      up_block_types=["UpDecoderBlock2D", "UpDecoderBlock2D"]		,      latent_channels=4		,      )
											torch.manual_seed(0      )
											__lowerCAmelCase           =	CLIPTextConfig(
											    bos_token_id=0		,      eos_token_id=2		,      hidden_size=3_2		,      intermediate_size=3_7		,      layer_norm_eps=1E-0_5		,      num_attention_heads=4		,      num_hidden_layers=5		,      pad_token_id=1		,      vocab_size=1_0_0_0		,      )
											__lowerCAmelCase           =	CLIPTextModel(_A      )
											__lowerCAmelCase           =	CLIPTokenizer.from_pretrained("hf-internal-testing/tiny-random-clip"      )

											__lowerCAmelCase           =	MultiControlNetModel([controlneta, controlneta]      )

											__lowerCAmelCase           =	{
											    "unet": unet,
											    "controlnet": controlnet,
											    "scheduler": scheduler,
											    "vae": vae,
											    "text_encoder": text_encoder,
											    "tokenizer": tokenizer,
											    "safety_checker": None,
											    "feature_extractor": None,
											}
											return components






						def     __SCREAMING_SNAKE_CASE(       self		,      _A		,      _A=0      ):




											"""simple docstring"""



											if str(_A      ).startswith("mps"      ):
																__lowerCAmelCase           =	torch.manual_seed(_A      )
											else:
																__lowerCAmelCase           =	torch.Generator(device=_A      ).manual_seed(_A      )

											__lowerCAmelCase           =	2

											__lowerCAmelCase           =	[
											    randn_tensor(
											        (1, 3, 3_2 * controlnet_embedder_scale_factor, 3_2 * controlnet_embedder_scale_factor)		,      generator=_A		,      device=torch.device(_A      )		,      ),
											    randn_tensor(
											        (1, 3, 3_2 * controlnet_embedder_scale_factor, 3_2 * controlnet_embedder_scale_factor)		,      generator=_A		,      device=torch.device(_A      )		,      ),
											]

											__lowerCAmelCase           =	floats_tensor(control_image[0].shape		,      rng=random.Random(_A      )      ).to(_A      )
											__lowerCAmelCase           =	image.cpu().permute(0		,      2		,      3		,      1      )[0]
											__lowerCAmelCase           =	Image.fromarray(np.uinta(_A      )      ).convert("RGB"      ).resize((6_4, 6_4)      )
											__lowerCAmelCase           =	{
											    "prompt": "A painting of a squirrel eating a burger",
											    "generator": generator,
											    "num_inference_steps": 2,
											    "guidance_scale": 6.0,
											    "output_type": "numpy",
											    "image": image,
											    "control_image": control_image,
											}

											return inputs






						def     __SCREAMING_SNAKE_CASE(       self      ):




											"""simple docstring"""



											__lowerCAmelCase           =	self.get_dummy_components()
											__lowerCAmelCase           =	self.pipeline_class(**_A      )
											pipe.to(_A      )

											__lowerCAmelCase           =	10.0
											__lowerCAmelCase           =	4

											__lowerCAmelCase           =	self.get_dummy_inputs(_A      )
											__lowerCAmelCase           =	steps
											__lowerCAmelCase           =	scale
											__lowerCAmelCase           =	pipe(**_A      )[0]

											__lowerCAmelCase           =	self.get_dummy_inputs(_A      )
											__lowerCAmelCase           =	steps
											__lowerCAmelCase           =	scale
											__lowerCAmelCase           =	pipe(**_A		,      control_guidance_start=0.1		,      control_guidance_end=0.2      )[0]

											__lowerCAmelCase           =	self.get_dummy_inputs(_A      )
											__lowerCAmelCase           =	steps
											__lowerCAmelCase           =	scale
											__lowerCAmelCase           =	pipe(**_A		,      control_guidance_start=[0.1, 0.3]		,      control_guidance_end=[0.2, 0.7]      )[0]

											__lowerCAmelCase           =	self.get_dummy_inputs(_A      )
											__lowerCAmelCase           =	steps
											__lowerCAmelCase           =	scale
											__lowerCAmelCase           =	pipe(**_A		,      control_guidance_start=0.4		,      control_guidance_end=[0.5, 0.8]      )[0]

											# make sure that all outputs are different
											assert np.sum(np.abs(output_a - output_a      )      ) > 1E-3
											assert np.sum(np.abs(output_a - output_a      )      ) > 1E-3
											assert np.sum(np.abs(output_a - output_a      )      ) > 1E-3






						def     __SCREAMING_SNAKE_CASE(       self      ):




											"""simple docstring"""



											return self._test_attention_slicing_forward_pass(expected_max_diff=2E-3      )






						@unittest.skipIf(
						    torch_device != "cuda" or not is_xformers_available()		,      reason="XFormers attention is only available with CUDA and `xformers` installed"		,      )
						def     __SCREAMING_SNAKE_CASE(       self      ):




											"""simple docstring"""



											self._test_xformers_attention_forwardGenerator_pass(expected_max_diff=2E-3      )






						def     __SCREAMING_SNAKE_CASE(       self      ):




											"""simple docstring"""



											self._test_inference_batch_single_identical(expected_max_diff=2E-3      )






						def     __SCREAMING_SNAKE_CASE(       self      ):




											"""simple docstring"""



											__lowerCAmelCase           =	self.get_dummy_components()
											__lowerCAmelCase           =	self.pipeline_class(**_A      )
											pipe.to(_A      )
											pipe.set_progress_bar_config(disable=_A      )
											with tempfile.TemporaryDirectory() as tmpdir:
																try:
																					# save_pretrained is not implemented for Multi-ControlNet
																					pipe.save_pretrained(_A      )
																except NotImplementedError:
																					pass






@slow
@require_torch_gpu
class       a__   ( unittest.TestCase				):






						def     __SCREAMING_SNAKE_CASE(       self      ):




											"""simple docstring"""



											super().tearDown()
											gc.collect()
											torch.cuda.empty_cache()






						def     __SCREAMING_SNAKE_CASE(       self      ):




											"""simple docstring"""



											__lowerCAmelCase           =	ControlNetModel.from_pretrained("lllyasviel/sd-controlnet-canny"      )

											__lowerCAmelCase           =	StableDiffusionControlNetImgaImgPipeline.from_pretrained(
											    "runwayml/stable-diffusion-v1-5"		,      safety_checker=_A		,      controlnet=_A      )
											pipe.enable_model_cpu_offload()
											pipe.set_progress_bar_config(disable=_A      )

											__lowerCAmelCase           =	torch.Generator(device="cpu"      ).manual_seed(0      )
											__lowerCAmelCase           =	"evil space-punk bird"
											__lowerCAmelCase           =	load_image(
											    "https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main/sd_controlnet/bird_canny.png"      ).resize((5_1_2, 5_1_2)      )
											__lowerCAmelCase           =	load_image(
											    "https://huggingface.co/lllyasviel/sd-controlnet-canny/resolve/main/images/bird.png"      ).resize((5_1_2, 5_1_2)      )

											__lowerCAmelCase           =	pipe(
											    _A		,      _A		,      control_image=_A		,      generator=_A		,      output_type="np"		,      num_inference_steps=5_0		,      strength=0.6		,      )

											__lowerCAmelCase           =	output.images[0]

											assert image.shape == (5_1_2, 5_1_2, 3)

											__lowerCAmelCase           =	load_numpy(
											    "https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main/sd_controlnet/img2img.npy"      )

											assert np.abs(expected_image - image      ).max() < 9E-2










UpperCamelCase__         =      """0.18.2"""

from .configuration_utils import ConfigMixin
from .utils import (
    OptionalDependencyNotAvailable,
    is_flax_available,
    is_inflect_available,
    is_invisible_watermark_available,
    is_k_diffusion_available,
    is_k_diffusion_version,
    is_librosa_available,
    is_note_seq_available,
    is_onnx_available,
    is_scipy_available,
    is_torch_available,
    is_torchsde_available,
    is_transformers_available,
    is_transformers_version,
    is_unidecode_available,
    logging,
)


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

try:
					if not is_torch_available():
										raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
					from .utils.dummy_pt_objects import *  # noqa F403
else:
					from .models import (
					    AutoencoderKL,
					    ControlNetModel,
					    ModelMixin,
					    PriorTransformer,
					    TaFilmDecoder,
					    TransformeraDModel,
					    UNetaDModel,
					    UNetaDConditionModel,
					    UNetaDModel,
					    UNetaDConditionModel,
					    VQModel,
					)
					from .optimization import (
					    get_constant_schedule,
					    get_constant_schedule_with_warmup,
					    get_cosine_schedule_with_warmup,
					    get_cosine_with_hard_restarts_schedule_with_warmup,
					    get_linear_schedule_with_warmup,
					    get_polynomial_decay_schedule_with_warmup,
					    get_scheduler,
					)
					from .pipelines import (
					    AudioPipelineOutput,
					    ConsistencyModelPipeline,
					    DanceDiffusionPipeline,
					    DDIMPipeline,
					    DDPMPipeline,
					    DiffusionPipeline,
					    DiTPipeline,
					    ImagePipelineOutput,
					    KarrasVePipeline,
					    LDMPipeline,
					    LDMSuperResolutionPipeline,
					    PNDMPipeline,
					    RePaintPipeline,
					    ScoreSdeVePipeline,
					)
					from .schedulers import (
					    CMStochasticIterativeScheduler,
					    DDIMInverseScheduler,
					    DDIMParallelScheduler,
					    DDIMScheduler,
					    DDPMParallelScheduler,
					    DDPMScheduler,
					    DEISMultistepScheduler,
					    DPMSolverMultistepInverseScheduler,
					    DPMSolverMultistepScheduler,
					    DPMSolverSinglestepScheduler,
					    EulerAncestralDiscreteScheduler,
					    EulerDiscreteScheduler,
					    HeunDiscreteScheduler,
					    IPNDMScheduler,
					    KarrasVeScheduler,
					    KDPMaAncestralDiscreteScheduler,
					    KDPMaDiscreteScheduler,
					    PNDMScheduler,
					    RePaintScheduler,
					    SchedulerMixin,
					    ScoreSdeVeScheduler,
					    UnCLIPScheduler,
					    UniPCMultistepScheduler,
					    VQDiffusionScheduler,
					)
					from .training_utils import EMAModel

try:
					if not (is_torch_available() and is_scipy_available()):
										raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
					from .utils.dummy_torch_and_scipy_objects import *  # noqa F403
else:
					from .schedulers import LMSDiscreteScheduler

try:
					if not (is_torch_available() and is_torchsde_available()):
										raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
					from .utils.dummy_torch_and_torchsde_objects import *  # noqa F403
else:
					from .schedulers import DPMSolverSDEScheduler

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 .pipelines import (
					    AltDiffusionImgaImgPipeline,
					    AltDiffusionPipeline,
					    AudioLDMPipeline,
					    CycleDiffusionPipeline,
					    IFImgaImgPipeline,
					    IFImgaImgSuperResolutionPipeline,
					    IFInpaintingPipeline,
					    IFInpaintingSuperResolutionPipeline,
					    IFPipeline,
					    IFSuperResolutionPipeline,
					    ImageTextPipelineOutput,
					    KandinskyImgaImgPipeline,
					    KandinskyInpaintPipeline,
					    KandinskyPipeline,
					    KandinskyPriorPipeline,
					    KandinskyVaaControlnetImgaImgPipeline,
					    KandinskyVaaControlnetPipeline,
					    KandinskyVaaImgaImgPipeline,
					    KandinskyVaaInpaintPipeline,
					    KandinskyVaaPipeline,
					    KandinskyVaaPriorEmbaEmbPipeline,
					    KandinskyVaaPriorPipeline,
					    LDMTextToImagePipeline,
					    PaintByExamplePipeline,
					    SemanticStableDiffusionPipeline,
					    ShapEImgaImgPipeline,
					    ShapEPipeline,
					    StableDiffusionAttendAndExcitePipeline,
					    StableDiffusionControlNetImgaImgPipeline,
					    StableDiffusionControlNetInpaintPipeline,
					    StableDiffusionControlNetPipeline,
					    StableDiffusionDepthaImgPipeline,
					    StableDiffusionDiffEditPipeline,
					    StableDiffusionImageVariationPipeline,
					    StableDiffusionImgaImgPipeline,
					    StableDiffusionInpaintPipeline,
					    StableDiffusionInpaintPipelineLegacy,
					    StableDiffusionInstructPixaPixPipeline,
					    StableDiffusionLatentUpscalePipeline,
					    StableDiffusionLDMaDPipeline,
					    StableDiffusionModelEditingPipeline,
					    StableDiffusionPanoramaPipeline,
					    StableDiffusionParadigmsPipeline,
					    StableDiffusionPipeline,
					    StableDiffusionPipelineSafe,
					    StableDiffusionPixaPixZeroPipeline,
					    StableDiffusionSAGPipeline,
					    StableDiffusionUpscalePipeline,
					    StableUnCLIPImgaImgPipeline,
					    StableUnCLIPPipeline,
					    TextToVideoSDPipeline,
					    TextToVideoZeroPipeline,
					    UnCLIPImageVariationPipeline,
					    UnCLIPPipeline,
					    UniDiffuserModel,
					    UniDiffuserPipeline,
					    UniDiffuserTextDecoder,
					    VersatileDiffusionDualGuidedPipeline,
					    VersatileDiffusionImageVariationPipeline,
					    VersatileDiffusionPipeline,
					    VersatileDiffusionTextToImagePipeline,
					    VideoToVideoSDPipeline,
					    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 .pipelines import StableDiffusionXLImgaImgPipeline, StableDiffusionXLPipeline

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 .pipelines import StableDiffusionKDiffusionPipeline

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 .pipelines import (
					    OnnxStableDiffusionImgaImgPipeline,
					    OnnxStableDiffusionInpaintPipeline,
					    OnnxStableDiffusionInpaintPipelineLegacy,
					    OnnxStableDiffusionPipeline,
					    OnnxStableDiffusionUpscalePipeline,
					    StableDiffusionOnnxPipeline,
					)

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 .pipelines import AudioDiffusionPipeline, Mel

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 .pipelines import SpectrogramDiffusionPipeline

try:
					if not is_flax_available():
										raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
					from .utils.dummy_flax_objects import *  # noqa F403
else:
					from .models.controlnet_flax import FlaxControlNetModel
					from .models.modeling_flax_utils import FlaxModelMixin
					from .models.unet_ad_condition_flax import FlaxUNetaDConditionModel
					from .models.vae_flax import FlaxAutoencoderKL
					from .pipelines import FlaxDiffusionPipeline
					from .schedulers import (
					    FlaxDDIMScheduler,
					    FlaxDDPMScheduler,
					    FlaxDPMSolverMultistepScheduler,
					    FlaxKarrasVeScheduler,
					    FlaxLMSDiscreteScheduler,
					    FlaxPNDMScheduler,
					    FlaxSchedulerMixin,
					    FlaxScoreSdeVeScheduler,
					)


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 .pipelines import (
					    FlaxStableDiffusionControlNetPipeline,
					    FlaxStableDiffusionImgaImgPipeline,
					    FlaxStableDiffusionInpaintPipeline,
					    FlaxStableDiffusionPipeline,
					)

try:
					if not (is_note_seq_available()):
										raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
					from .utils.dummy_note_seq_objects import *  # noqa F403
else:
					from .pipelines import MidiProcessor




