

import itertools
import random
import unittest

import numpy as np

from transformers import BatchFeature, SpeechTaFeatureExtractor
from transformers.testing_utils import require_torch
from transformers.utils.import_utils import is_torch_available

from ...test_sequence_feature_extraction_common import SequenceFeatureExtractionTestMixin


if is_torch_available():
			import torch


a__				=		random.Random()



def    __UpperCAmelCase (	__a      :			Tuple		,__a      :			Optional[Any]=1.0		,__a      :			int=None		,__a      :			List[str]=None	)			->     Union[str, Any]:

					"""simple docstring"""

					if rng is None:
										_a	:    Optional[Any]         =		global_rng

					_a	:    str         =		[]
					for batch_idx in range(shape[0]	):
										values.append([]	)
										for _ in range(shape[1]	):
															values[-1].append(rng.random() * scale	)

					return values

@require_torch
class 				UpperCAmelCase_		(			unittest.TestCase   ):
							"""simple docstring"""







							def __init__(			self       ,							_a       ,							_a=7       ,							_a=4_0_0       ,							_a=2_0_0_0       ,							_a=1       ,							_a=0.0       ,							_a=1_6_0_0_0       ,							_a=True       ,							_a=8_0       ,							_a=1_6       ,							_a=6_4       ,							_a="hann_window"       ,							_a=8_0       ,							_a=7_6_0_0       ,							_a=1e-1_0       ,							_a=True       ,							)    ->    Tuple:
												_a	:    Tuple         =		parent
												_a	:    Tuple         =		batch_size
												_a	:    Dict         =		min_seq_length
												_a	:    Tuple         =		max_seq_length
												_a	:    Union[str, Any]         =		(self.max_seq_length - self.min_seq_length) // (self.batch_size - 1)
												_a	:    List[str]         =		feature_size
												_a	:    Optional[int]         =		padding_value
												_a	:    int         =		sampling_rate
												_a	:    Optional[int]         =		do_normalize
												_a	:    Any         =		num_mel_bins
												_a	:    Optional[Any]         =		hop_length
												_a	:    List[str]         =		win_length
												_a	:    int         =		win_function
												_a	:    str         =		fmin
												_a	:    int         =		fmax
												_a	:    Optional[int]         =		mel_floor
												_a	:    str         =		return_attention_mask


							def 				__lowercase				(			self       )    ->    Union[str, Any]:
												return {
												    "feature_size": self.feature_size,
												    "padding_value": self.padding_value,
												    "sampling_rate": self.sampling_rate,
												    "do_normalize": self.do_normalize,
												    "num_mel_bins": self.num_mel_bins,
												    "hop_length": self.hop_length,
												    "win_length": self.win_length,
												    "win_function": self.win_function,
												    "fmin": self.fmin,
												    "fmax": self.fmax,
												    "mel_floor": self.mel_floor,
												    "return_attention_mask": self.return_attention_mask,
												}


							def 				__lowercase				(			self       ,							_a=False       ,							_a=False       )    ->    Union[str, Any]:
												def _flatten(_a       ):
																	return list(itertools.chain(*_a       )       )

												if equal_length:
																	_a	:    Optional[int]         =		floats_list((self.batch_size, self.max_seq_length)       )
												else:
																	# make sure that inputs increase in size
																	_a	:    Union[str, Any]         =		[
																	    _flatten(floats_list((x, self.feature_size)       )       )
																	    for x in range(self.min_seq_length       ,							self.max_seq_length       ,							self.seq_length_diff       )
																	]

												if numpify:
																	_a	:    Optional[int]         =		[np.asarray(_a       ) for x in speech_inputs]

												return speech_inputs




							def 				__lowercase				(			self       ,							_a=False       ,							_a=False       )    ->    int:
												if equal_length:
																	_a	:    Union[str, Any]         =		[floats_list((self.max_seq_length, self.num_mel_bins)       ) for _ in range(self.batch_size       )]
												else:
																	# make sure that inputs increase in size
																	_a	:    Optional[int]         =		[
																	    floats_list((x, self.num_mel_bins)       )
																	    for x in range(self.min_seq_length       ,							self.max_seq_length       ,							self.seq_length_diff       )
																	]

												if numpify:
																	_a	:    Tuple         =		[np.asarray(_a       ) for x in speech_inputs]

												return speech_inputs



@require_torch
class 				UpperCAmelCase_		(			__lowercase				,       unittest.TestCase   ):
							"""simple docstring"""







							UpperCAmelCase__       :						int	    =    SpeechTaFeatureExtractor


							def 				__lowercase				(			self       )    ->    Any:
												_a	:    Optional[int]         =		SpeechTaFeatureExtractionTester(self       )


							def 				__lowercase				(			self       ,							_a       )    ->    List[Any]:
												self.assertTrue(np.all(np.mean(_a       ,							axis=0       ) < 1e-3       )       )
												self.assertTrue(np.all(np.abs(np.var(_a       ,							axis=0       ) - 1       ) < 1e-3       )       )


							def 				__lowercase				(			self       )    ->    str:
												# Tests that all call wrap to encode_plus and batch_encode_plus
												_a	:    Tuple         =		self.feature_extraction_class(**self.feat_extract_tester.prepare_feat_extract_dict()       )
												# create three inputs of length 800, 1000, and 1200
												_a	:    str         =		[floats_list((1, x)       )[0] for x in range(8_0_0       ,							1_4_0_0       ,							2_0_0       )]
												_a	:    List[Any]         =		[np.asarray(_a       ) for speech_input in speech_inputs]

												# Test not batched input
												_a	:    str         =		feat_extract(speech_inputs[0]       ,							return_tensors='''np'''       ).input_values
												_a	:    List[str]         =		feat_extract(np_speech_inputs[0]       ,							return_tensors='''np'''       ).input_values
												self.assertTrue(np.allclose(_a       ,							_a       ,							atol=1e-3       )       )

												# Test batched
												_a	:    int         =		feat_extract(_a       ,							return_tensors='''np'''       ).input_values
												_a	:    List[str]         =		feat_extract(_a       ,							return_tensors='''np'''       ).input_values
												for enc_seq_a, enc_seq_a in zip(_a       ,							_a       ):
																	self.assertTrue(np.allclose(_a       ,							_a       ,							atol=1e-3       )       )


							def 				__lowercase				(			self       )    ->    Tuple:
												_a	:    int         =		self.feature_extraction_class(**self.feat_extract_tester.prepare_feat_extract_dict()       )
												_a	:    Tuple         =		[floats_list((1, x)       )[0] for x in range(8_0_0       ,							1_4_0_0       ,							2_0_0       )]

												_a	:    Optional[int]         =		['''longest''', '''max_length''', '''do_not_pad''']
												_a	:    List[str]         =		[None, 1_6_0_0, None]
												for max_length, padding in zip(_a       ,							_a       ):
																	_a	:    Optional[Any]         =		feat_extract(_a       ,							padding=_a       ,							max_length=_a       ,							return_tensors='''np'''       )
																	_a	:    Dict         =		processed.input_values

																	self._check_zero_mean_unit_variance(input_values[0][:8_0_0]       )
																	self.assertTrue(input_values[0][8_0_0:].sum() < 1e-6       )
																	self._check_zero_mean_unit_variance(input_values[1][:1_0_0_0]       )
																	self.assertTrue(input_values[0][1_0_0_0:].sum() < 1e-6       )
																	self._check_zero_mean_unit_variance(input_values[2][:1_2_0_0]       )


							def 				__lowercase				(			self       )    ->    Any:
												_a	:    Optional[Any]         =		self.feature_extraction_class(**self.feat_extract_tester.prepare_feat_extract_dict()       )
												_a	:    str         =		range(8_0_0       ,							1_4_0_0       ,							2_0_0       )
												_a	:    List[Any]         =		[floats_list((1, x)       )[0] for x in lengths]

												_a	:    str         =		['''longest''', '''max_length''', '''do_not_pad''']
												_a	:    str         =		[None, 1_6_0_0, None]

												for max_length, padding in zip(_a       ,							_a       ):
																	_a	:    List[Any]         =		feat_extract(_a       ,							max_length=_a       ,							padding=_a       )
																	_a	:    Union[str, Any]         =		processed.input_values

																	self._check_zero_mean_unit_variance(input_values[0][:8_0_0]       )
																	self._check_zero_mean_unit_variance(input_values[1][:1_0_0_0]       )
																	self._check_zero_mean_unit_variance(input_values[2][:1_2_0_0]       )


							def 				__lowercase				(			self       )    ->    Dict:
												_a	:    List[Any]         =		self.feature_extraction_class(**self.feat_extract_tester.prepare_feat_extract_dict()       )
												_a	:    Optional[int]         =		[floats_list((1, x)       )[0] for x in range(8_0_0       ,							1_4_0_0       ,							2_0_0       )]
												_a	:    str         =		feat_extract(
												    _a       ,							truncation=_a       ,							max_length=1_0_0_0       ,							padding='''max_length'''       ,							return_tensors='''np'''       )
												_a	:    Optional[int]         =		processed.input_values

												self._check_zero_mean_unit_variance(input_values[0, :8_0_0]       )
												self._check_zero_mean_unit_variance(input_values[1]       )
												self._check_zero_mean_unit_variance(input_values[2]       )


							def 				__lowercase				(			self       )    ->    Union[str, Any]:
												_a	:    str         =		self.feature_extraction_class(**self.feat_extract_tester.prepare_feat_extract_dict()       )
												_a	:    Dict         =		[floats_list((1, x)       )[0] for x in range(8_0_0       ,							1_4_0_0       ,							2_0_0       )]
												_a	:    Dict         =		feat_extract(
												    _a       ,							truncation=_a       ,							max_length=1_0_0_0       ,							padding='''longest'''       ,							return_tensors='''np'''       )
												_a	:    str         =		processed.input_values

												self._check_zero_mean_unit_variance(input_values[0, :8_0_0]       )
												self._check_zero_mean_unit_variance(input_values[1, :1_0_0_0]       )
												self._check_zero_mean_unit_variance(input_values[2]       )

												# make sure that if max_length < longest -> then pad to max_length
												self.assertTrue(input_values.shape == (3, 1_0_0_0)       )

												_a	:    Dict         =		[floats_list((1, x)       )[0] for x in range(8_0_0       ,							1_4_0_0       ,							2_0_0       )]
												_a	:    List[Any]         =		feat_extract(
												    _a       ,							truncation=_a       ,							max_length=2_0_0_0       ,							padding='''longest'''       ,							return_tensors='''np'''       )
												_a	:    Union[str, Any]         =		processed.input_values

												self._check_zero_mean_unit_variance(input_values[0, :8_0_0]       )
												self._check_zero_mean_unit_variance(input_values[1, :1_0_0_0]       )
												self._check_zero_mean_unit_variance(input_values[2]       )

												# make sure that if max_length > longest -> then pad to longest
												self.assertTrue(input_values.shape == (3, 1_2_0_0)       )


							def 				__lowercase				(			self       )    ->    Optional[Any]:
												_a	:    str         =		self.feature_extraction_class(**self.feat_extract_tester.prepare_feat_extract_dict()       )
												_a	:    List[str]         =		np.random.rand(1_0_0       ).astype(np.floataa       )
												_a	:    str         =		np_speech_inputs.tolist()

												for inputs in [py_speech_inputs, np_speech_inputs]:
																	_a	:    Optional[int]         =		feature_extractor.pad([{'''input_values''': inputs}]       ,							return_tensors='''np'''       )
																	self.assertTrue(np_processed.input_values.dtype == np.floataa       )
																	_a	:    str         =		feature_extractor.pad([{'''input_values''': inputs}]       ,							return_tensors='''pt'''       )
																	self.assertTrue(pt_processed.input_values.dtype == torch.floataa       )


							def 				__lowercase				(			self       )    ->    Optional[Any]:
												# Tests that all call wrap to encode_plus and batch_encode_plus
												_a	:    Any         =		self.feature_extraction_class(**self.feat_extract_tester.prepare_feat_extract_dict()       )
												# create three inputs of length 800, 1000, and 1200
												_a	:    Union[str, Any]         =		[floats_list((1, x)       )[0] for x in range(8_0_0       ,							1_4_0_0       ,							2_0_0       )]
												_a	:    Tuple         =		[np.asarray(_a       ) for speech_input in speech_inputs]

												# Test feature size
												_a	:    List[Any]         =		feature_extractor(audio_target=_a       ,							padding=_a       ,							return_tensors='''np'''       ).input_values
												self.assertTrue(input_values.ndim == 3       )
												self.assertTrue(input_values.shape[-1] == feature_extractor.num_mel_bins       )

												# Test not batched input
												_a	:    str         =		feature_extractor(speech_inputs[0]       ,							return_tensors='''np'''       ).input_values
												_a	:    Dict         =		feature_extractor(np_speech_inputs[0]       ,							return_tensors='''np'''       ).input_values
												self.assertTrue(np.allclose(_a       ,							_a       ,							atol=1e-3       )       )

												# Test batched
												_a	:    Tuple         =		feature_extractor(_a       ,							return_tensors='''np'''       ).input_values
												_a	:    Any         =		feature_extractor(_a       ,							return_tensors='''np'''       ).input_values
												for enc_seq_a, enc_seq_a in zip(_a       ,							_a       ):
																	self.assertTrue(np.allclose(_a       ,							_a       ,							atol=1e-3       )       )

												# Test 2-D numpy arrays are batched.
												_a	:    Union[str, Any]         =		[floats_list((1, x)       )[0] for x in (8_0_0, 8_0_0, 8_0_0)]
												_a	:    int         =		np.asarray(_a       )
												_a	:    Union[str, Any]         =		feature_extractor(_a       ,							return_tensors='''np'''       ).input_values
												_a	:    Optional[int]         =		feature_extractor(_a       ,							return_tensors='''np'''       ).input_values
												for enc_seq_a, enc_seq_a in zip(_a       ,							_a       ):
																	self.assertTrue(np.allclose(_a       ,							_a       ,							atol=1e-3       )       )


							def 				__lowercase				(			self       )    ->    str:
												_a	:    List[Any]         =		self.feat_extract_tester.prepare_inputs_for_target()
												_a	:    Tuple         =		self.feature_extraction_class(**self.feat_extract_dict       )
												_a	:    Any         =		feat_extract.model_input_names[0]

												_a	:    str         =		BatchFeature({input_name: speech_inputs}       )

												self.assertTrue(all(len(_a       ) == len(_a       ) for x, y in zip(_a       ,							processed_features[input_name]       )       )       )

												_a	:    Any         =		self.feat_extract_tester.prepare_inputs_for_target(equal_length=_a       )
												_a	:    List[str]         =		BatchFeature({input_name: speech_inputs}       ,							tensor_type='''np'''       )

												_a	:    Union[str, Any]         =		processed_features[input_name]

												if len(batch_features_input.shape       ) < 3:
																	_a	:    str         =		batch_features_input[:, :, None]

												self.assertTrue(
												    batch_features_input.shape
												    == (self.feat_extract_tester.batch_size, len(speech_inputs[0]       ), self.feat_extract_tester.num_mel_bins)       )


							@require_torch
							def 				__lowercase				(			self       )    ->    Any:
												_a	:    Optional[int]         =		self.feat_extract_tester.prepare_inputs_for_target(equal_length=_a       )
												_a	:    Optional[int]         =		self.feature_extraction_class(**self.feat_extract_dict       )
												_a	:    Optional[int]         =		feat_extract.model_input_names[0]

												_a	:    str         =		BatchFeature({input_name: speech_inputs}       ,							tensor_type='''pt'''       )

												_a	:    Dict         =		processed_features[input_name]

												if len(batch_features_input.shape       ) < 3:
																	_a	:    int         =		batch_features_input[:, :, None]

												self.assertTrue(
												    batch_features_input.shape
												    == (self.feat_extract_tester.batch_size, len(speech_inputs[0]       ), self.feat_extract_tester.num_mel_bins)       )


							@require_torch
							def 				__lowercase				(			self       )    ->    int:
												_a	:    Any         =		self.feature_extraction_class(**self.feat_extract_dict       )
												_a	:    Optional[int]         =		self.feat_extract_tester.prepare_inputs_for_target()
												_a	:    Tuple         =		feat_extract.model_input_names[0]

												_a	:    List[str]         =		BatchFeature({input_name: speech_inputs}       )

												_a	:    List[str]         =		feat_extract.num_mel_bins  # hack!

												_a	:    str         =		feat_extract.pad(_a       ,							padding='''longest'''       ,							return_tensors='''np'''       )[input_name]
												_a	:    int         =		feat_extract.pad(_a       ,							padding='''longest'''       ,							return_tensors='''pt'''       )[input_name]

												self.assertTrue(abs(input_np.astype(np.floataa       ).sum() - input_pt.numpy().astype(np.floataa       ).sum()       ) < 1e-2       )


							def 				__lowercase				(			self       )    ->    Tuple:
												_a	:    Optional[int]         =		self.feat_extract_dict
												_a	:    int         =		True
												_a	:    List[Any]         =		self.feature_extraction_class(**_a       )
												_a	:    int         =		self.feat_extract_tester.prepare_inputs_for_target()
												_a	:    Dict         =		[len(_a       ) for x in speech_inputs]
												_a	:    Optional[int]         =		feat_extract.model_input_names[0]

												_a	:    Optional[Any]         =		BatchFeature({input_name: speech_inputs}       )

												_a	:    Optional[Any]         =		feat_extract.num_mel_bins  # hack!

												_a	:    str         =		feat_extract.pad(_a       ,							padding='''longest'''       ,							return_tensors='''np'''       )
												self.assertIn('''attention_mask'''       ,							_a       )
												self.assertListEqual(list(processed.attention_mask.shape       )       ,							list(processed[input_name].shape[:2]       )       )
												self.assertListEqual(processed.attention_mask.sum(-1       ).tolist()       ,							_a       )


							def 				__lowercase				(			self       )    ->    Union[str, Any]:
												_a	:    Union[str, Any]         =		self.feat_extract_dict
												_a	:    List[str]         =		True
												_a	:    List[str]         =		self.feature_extraction_class(**_a       )
												_a	:    List[Any]         =		self.feat_extract_tester.prepare_inputs_for_target()
												_a	:    List[str]         =		[len(_a       ) for x in speech_inputs]
												_a	:    Optional[int]         =		feat_extract.model_input_names[0]

												_a	:    Dict         =		BatchFeature({input_name: speech_inputs}       )
												_a	:    Optional[int]         =		min(_a       )

												_a	:    Dict         =		feat_extract.num_mel_bins  # hack!

												_a	:    Any         =		feat_extract.pad(
												    _a       ,							padding='''max_length'''       ,							max_length=_a       ,							truncation=_a       ,							return_tensors='''np'''       )
												self.assertIn('''attention_mask'''       ,							_a       )
												self.assertListEqual(
												    list(processed_pad.attention_mask.shape       )       ,							[processed_pad[input_name].shape[0], max_length]       )
												self.assertListEqual(
												    processed_pad.attention_mask[:, :max_length].sum(-1       ).tolist()       ,							[max_length for x in speech_inputs]       )


							def 				__lowercase				(			self       ,							_a       )    ->    List[Any]:
												from datasets import load_dataset

												_a	:    List[str]         =		load_dataset('''hf-internal-testing/librispeech_asr_dummy'''       ,							'''clean'''       ,							split='''validation'''       )
												# automatic decoding with librispeech
												_a	:    Optional[Any]         =		ds.sort('''id'''       ).select(range(_a       )       )[:num_samples]['''audio''']

												return [x["array"] for x in speech_samples]


							def 				__lowercase				(			self       )    ->    List[str]:
												# fmt: off
												_a	:    int         =		torch.tensor(
												    [2.3_8_0_4e-0_3, 2.0_7_5_2e-0_3, 1.9_8_3_6e-0_3, 2.1_0_5_7e-0_3, 1.6_1_7_4e-0_3,
												     3.0_5_1_8e-0_4, 9.1_5_5_3e-0_5, 3.3_5_6_9e-0_4, 9.7_6_5_6e-0_4, 1.8_3_1_1e-0_3,
												     2.0_1_4_2e-0_3, 2.1_0_5_7e-0_3, 1.7_3_9_5e-0_3, 4.5_7_7_6e-0_4, -3.9_6_7_3e-0_4,
												     4.5_7_7_6e-0_4, 1.0_0_7_1e-0_3, 9.1_5_5_3e-0_5, 4.8_8_2_8e-0_4, 1.1_5_9_7e-0_3,
												     7.3_2_4_2e-0_4, 9.4_6_0_4e-0_4, 1.8_0_0_5e-0_3, 1.8_3_1_1e-0_3, 8.8_5_0_1e-0_4,
												     4.2_7_2_5e-0_4, 4.8_8_2_8e-0_4, 7.3_2_4_2e-0_4, 1.0_9_8_6e-0_3, 2.1_0_5_7e-0_3]       )
												# fmt: on

												_a	:    Optional[Any]         =		self._load_datasamples(1       )
												_a	:    Optional[Any]         =		SpeechTaFeatureExtractor()
												_a	:    Optional[Any]         =		feature_extractor(_a       ,							return_tensors='''pt'''       ).input_values
												self.assertEquals(input_values.shape       ,							(1, 9_3_6_8_0)       )
												self.assertTrue(torch.allclose(input_values[0, :3_0]       ,							_a       ,							atol=1e-6       )       )




							def 				__lowercase				(			self       )    ->    Dict:
												# fmt: off
												_a	:    Optional[int]         =		torch.tensor(
												    [-2.6870, -3.0104, -3.1356, -3.5352, -3.0044, -3.0353, -3.4719, -3.6777,
												     -3.1520, -2.9435, -2.6553, -2.8795, -2.9944, -2.5921, -3.0279, -3.0386,
												     -3.0864, -3.1291, -3.2353, -2.7444, -2.6831, -2.7287, -3.1761, -3.1571,
												     -3.2726, -3.0582, -3.1007, -3.4533, -3.4695, -3.0998]       )
												# fmt: on

												_a	:    Dict         =		self._load_datasamples(1       )
												_a	:    List[str]         =		SpeechTaFeatureExtractor()
												_a	:    Union[str, Any]         =		feature_extractor(audio_target=_a       ,							return_tensors='''pt'''       ).input_values
												self.assertEquals(input_values.shape       ,							(1, 3_6_6, 8_0)       )
												self.assertTrue(torch.allclose(input_values[0, 0, :3_0]       ,							_a       ,							atol=1e-4       )       )






a__				=		'''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



