



import math
import os
import unittest

from transformers import MegatronBertConfig, is_torch_available
from transformers.models.auto import get_values
from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow, torch_device

from ...test_configuration_common import ConfigTester
from ...test_modeling_common import ModelTesterMixin, ids_tensor, random_attention_mask
from ...test_pipeline_mixin import PipelineTesterMixin


if is_torch_available():
						import torch

						from transformers import (
						    MODEL_FOR_PRETRAINING_MAPPING,
						    MegatronBertForCausalLM,
						    MegatronBertForMaskedLM,
						    MegatronBertForMultipleChoice,
						    MegatronBertForNextSentencePrediction,
						    MegatronBertForPreTraining,
						    MegatronBertForQuestionAnswering,
						    MegatronBertForSequenceClassification,
						    MegatronBertForTokenClassification,
						    MegatronBertModel,
						)






class  SCREAMING_SNAKE_CASE      :





							def __init__( self		:		Optional[Any]   ,					__lowercase		:		str   ,					__lowercase		:		int=13   ,					__lowercase		:		Optional[Any]=7   ,					__lowercase		:		str=True   ,					__lowercase		:		int=True   ,					__lowercase		:		Optional[Any]=True   ,					__lowercase		:		Optional[Any]=True   ,					__lowercase		:		Optional[Any]=99   ,					__lowercase		:		Dict=64   ,					__lowercase		:		Union[str, Any]=32   ,					__lowercase		:		Optional[Any]=5   ,					__lowercase		:		List[Any]=4   ,					__lowercase		:		int=37   ,					__lowercase		:		List[str]="gelu"   ,					__lowercase		:		int=0.1   ,					__lowercase		:		Tuple=0.1   ,					__lowercase		:		Union[str, Any]=512   ,					__lowercase		:		Optional[int]=16   ,					__lowercase		:		str=2   ,					__lowercase		:		Optional[Any]=0.02   ,					__lowercase		:		List[str]=3   ,					__lowercase		:		int=4   ,					__lowercase		:		int=None   ,					):

											'''simple docstring'''
											__a	  =		parent
											__a	  =		batch_size
											__a	  =		seq_length
											__a	  =		is_training
											__a	  =		use_input_mask
											__a	  =		use_token_type_ids
											__a	  =		use_labels
											__a	  =		vocab_size
											__a	  =		hidden_size
											__a	  =		embedding_size
											__a	  =		num_hidden_layers
											__a	  =		num_attention_heads
											__a	  =		intermediate_size
											__a	  =		hidden_act
											__a	  =		hidden_dropout_prob
											__a	  =		attention_probs_dropout_prob
											__a	  =		max_position_embeddings
											__a	  =		type_vocab_size
											__a	  =		type_sequence_label_size
											__a	  =		initializer_range
											__a	  =		num_labels
											__a	  =		num_choices
											__a	  =		scope





							def     UpperCamelCase_       ( self		:		Optional[int]						):

											'''simple docstring'''
											__a	  =		ids_tensor([self.batch_size, self.seq_length]   ,					self.vocab_size						)

											__a	  =		None
											if self.use_input_mask:
															__a	  =		random_attention_mask([self.batch_size, self.seq_length]						)

											__a	  =		None
											if self.use_token_type_ids:
															__a	  =		ids_tensor([self.batch_size, self.seq_length]   ,					self.type_vocab_size						)

											__a	  =		None
											__a	  =		None
											__a	  =		None
											if self.use_labels:
															__a	  =		ids_tensor([self.batch_size]   ,					self.type_sequence_label_size						)
															__a	  =		ids_tensor([self.batch_size, self.seq_length]   ,					self.num_labels						)
															__a	  =		ids_tensor([self.batch_size]   ,					self.num_choices						)

											__a	  =		self.get_config()

											return config, input_ids, token_type_ids, input_mask, sequence_labels, token_labels, choice_labels





							def     UpperCamelCase_       ( self		:		Optional[int]						):

											'''simple docstring'''
											return MegatronBertConfig(
											    vocab_size=self.vocab_size   ,					hidden_size=self.hidden_size   ,					num_hidden_layers=self.num_hidden_layers   ,					num_attention_heads=self.num_attention_heads   ,					intermediate_size=self.intermediate_size   ,					embedding_size=self.embedding_size   ,					hidden_act=self.hidden_act   ,					hidden_dropout_prob=self.hidden_dropout_prob   ,					attention_probs_dropout_prob=self.attention_probs_dropout_prob   ,					max_position_embeddings=self.max_position_embeddings   ,					type_vocab_size=self.type_vocab_size   ,					is_decoder=_SCREAMING_SNAKE_CASE   ,					initializer_range=self.initializer_range   ,					)





							def     UpperCamelCase_       ( self		:		Any   ,					__lowercase		:		Union[str, Any]   ,					__lowercase		:		Union[str, Any]   ,					__lowercase		:		Optional[Any]   ,					__lowercase		:		Optional[int]   ,					__lowercase		:		Optional[Any]   ,					__lowercase		:		List[Any]   ,					__lowercase		:		Tuple						):

											'''simple docstring'''
											__a	  =		MegatronBertModel(config=_SCREAMING_SNAKE_CASE						)
											model.to(_SCREAMING_SNAKE_CASE						)
											model.eval()
											__a	  =		model(_SCREAMING_SNAKE_CASE   ,					attention_mask=_SCREAMING_SNAKE_CASE   ,					token_type_ids=_SCREAMING_SNAKE_CASE						)
											__a	  =		model(_SCREAMING_SNAKE_CASE   ,					token_type_ids=_SCREAMING_SNAKE_CASE						)
											__a	  =		model(_SCREAMING_SNAKE_CASE						)

											self.parent.assertEqual(result.last_hidden_state.shape   ,					(self.batch_size, self.seq_length, self.hidden_size)						)
											self.parent.assertEqual(result.pooler_output.shape   ,					(self.batch_size, self.hidden_size)						)





							def     UpperCamelCase_       ( self		:		List[Any]   ,					__lowercase		:		Union[str, Any]   ,					__lowercase		:		str   ,					__lowercase		:		str   ,					__lowercase		:		Optional[int]   ,					__lowercase		:		int   ,					__lowercase		:		int   ,					__lowercase		:		List[str]						):

											'''simple docstring'''
											__a	  =		MegatronBertForMaskedLM(config=_SCREAMING_SNAKE_CASE						)
											model.to(_SCREAMING_SNAKE_CASE						)
											model.eval()
											__a	  =		model(_SCREAMING_SNAKE_CASE   ,					attention_mask=_SCREAMING_SNAKE_CASE   ,					token_type_ids=_SCREAMING_SNAKE_CASE   ,					labels=_SCREAMING_SNAKE_CASE						)
											self.parent.assertEqual(result.logits.shape   ,					(self.batch_size, self.seq_length, self.vocab_size)						)





							def     UpperCamelCase_       ( self		:		Optional[Any]   ,					__lowercase		:		Dict   ,					__lowercase		:		Any   ,					__lowercase		:		Union[str, Any]   ,					__lowercase		:		Optional[Any]   ,					__lowercase		:		List[Any]   ,					__lowercase		:		Optional[Any]   ,					__lowercase		:		Dict						):

											'''simple docstring'''
											__a	  =		MegatronBertForCausalLM(config=_SCREAMING_SNAKE_CASE						)
											model.to(_SCREAMING_SNAKE_CASE						)
											model.eval()
											__a	  =		model(_SCREAMING_SNAKE_CASE   ,					attention_mask=_SCREAMING_SNAKE_CASE   ,					token_type_ids=_SCREAMING_SNAKE_CASE   ,					labels=_SCREAMING_SNAKE_CASE						)
											self.parent.assertEqual(result.logits.shape   ,					(self.batch_size, self.seq_length, self.vocab_size)						)





							def     UpperCamelCase_       ( self		:		List[str]   ,					__lowercase		:		Union[str, Any]   ,					__lowercase		:		Optional[Any]   ,					__lowercase		:		Optional[Any]   ,					__lowercase		:		str   ,					__lowercase		:		List[str]   ,					__lowercase		:		Optional[Any]   ,					__lowercase		:		Any						):

											'''simple docstring'''
											__a	  =		MegatronBertForNextSentencePrediction(config=_SCREAMING_SNAKE_CASE						)
											model.to(_SCREAMING_SNAKE_CASE						)
											model.eval()
											__a	  =		model(
											    _SCREAMING_SNAKE_CASE   ,					attention_mask=_SCREAMING_SNAKE_CASE   ,					token_type_ids=_SCREAMING_SNAKE_CASE   ,					labels=_SCREAMING_SNAKE_CASE   ,					)
											self.parent.assertEqual(result.logits.shape   ,					(self.batch_size, 2)						)





							def     UpperCamelCase_       ( self		:		Optional[int]   ,					__lowercase		:		Union[str, Any]   ,					__lowercase		:		Optional[int]   ,					__lowercase		:		List[Any]   ,					__lowercase		:		Dict   ,					__lowercase		:		List[Any]   ,					__lowercase		:		int   ,					__lowercase		:		Optional[int]						):

											'''simple docstring'''
											__a	  =		MegatronBertForPreTraining(config=_SCREAMING_SNAKE_CASE						)
											model.to(_SCREAMING_SNAKE_CASE						)
											model.eval()
											__a	  =		model(
											    _SCREAMING_SNAKE_CASE   ,					attention_mask=_SCREAMING_SNAKE_CASE   ,					token_type_ids=_SCREAMING_SNAKE_CASE   ,					labels=_SCREAMING_SNAKE_CASE   ,					next_sentence_label=_SCREAMING_SNAKE_CASE   ,					)
											self.parent.assertEqual(result.prediction_logits.shape   ,					(self.batch_size, self.seq_length, self.vocab_size)						)
											self.parent.assertEqual(result.seq_relationship_logits.shape   ,					(self.batch_size, 2)						)





							def     UpperCamelCase_       ( self		:		str   ,					__lowercase		:		Dict   ,					__lowercase		:		Dict   ,					__lowercase		:		Union[str, Any]   ,					__lowercase		:		List[str]   ,					__lowercase		:		Optional[Any]   ,					__lowercase		:		Union[str, Any]   ,					__lowercase		:		Any						):

											'''simple docstring'''
											__a	  =		MegatronBertForQuestionAnswering(config=_SCREAMING_SNAKE_CASE						)
											model.to(_SCREAMING_SNAKE_CASE						)
											model.eval()
											__a	  =		model(
											    _SCREAMING_SNAKE_CASE   ,					attention_mask=_SCREAMING_SNAKE_CASE   ,					token_type_ids=_SCREAMING_SNAKE_CASE   ,					start_positions=_SCREAMING_SNAKE_CASE   ,					end_positions=_SCREAMING_SNAKE_CASE   ,					)
											self.parent.assertEqual(result.start_logits.shape   ,					(self.batch_size, self.seq_length)						)
											self.parent.assertEqual(result.end_logits.shape   ,					(self.batch_size, self.seq_length)						)





							def     UpperCamelCase_       ( self		:		List[str]   ,					__lowercase		:		Optional[int]   ,					__lowercase		:		Any   ,					__lowercase		:		Union[str, Any]   ,					__lowercase		:		int   ,					__lowercase		:		Optional[int]   ,					__lowercase		:		str   ,					__lowercase		:		Union[str, Any]						):

											'''simple docstring'''
											__a	  =		self.num_labels
											__a	  =		MegatronBertForSequenceClassification(_SCREAMING_SNAKE_CASE						)
											model.to(_SCREAMING_SNAKE_CASE						)
											model.eval()
											__a	  =		model(_SCREAMING_SNAKE_CASE   ,					attention_mask=_SCREAMING_SNAKE_CASE   ,					token_type_ids=_SCREAMING_SNAKE_CASE   ,					labels=_SCREAMING_SNAKE_CASE						)
											self.parent.assertEqual(result.logits.shape   ,					(self.batch_size, self.num_labels)						)





							def     UpperCamelCase_       ( self		:		Optional[Any]   ,					__lowercase		:		Optional[int]   ,					__lowercase		:		List[Any]   ,					__lowercase		:		Union[str, Any]   ,					__lowercase		:		Optional[Any]   ,					__lowercase		:		Optional[Any]   ,					__lowercase		:		Union[str, Any]   ,					__lowercase		:		str						):

											'''simple docstring'''
											__a	  =		self.num_labels
											__a	  =		MegatronBertForTokenClassification(config=_SCREAMING_SNAKE_CASE						)
											model.to(_SCREAMING_SNAKE_CASE						)
											model.eval()
											__a	  =		model(_SCREAMING_SNAKE_CASE   ,					attention_mask=_SCREAMING_SNAKE_CASE   ,					token_type_ids=_SCREAMING_SNAKE_CASE   ,					labels=_SCREAMING_SNAKE_CASE						)
											self.parent.assertEqual(result.logits.shape   ,					(self.batch_size, self.seq_length, self.num_labels)						)





							def     UpperCamelCase_       ( self		:		List[str]   ,					__lowercase		:		Any   ,					__lowercase		:		Union[str, Any]   ,					__lowercase		:		Any   ,					__lowercase		:		Optional[Any]   ,					__lowercase		:		List[str]   ,					__lowercase		:		Any   ,					__lowercase		:		List[str]						):

											'''simple docstring'''
											__a	  =		self.num_choices
											__a	  =		MegatronBertForMultipleChoice(config=_SCREAMING_SNAKE_CASE						)
											model.to(_SCREAMING_SNAKE_CASE						)
											model.eval()
											__a	  =		input_ids.unsqueeze(1						).expand(-1   ,					self.num_choices   ,					-1						).contiguous()
											__a	  =		token_type_ids.unsqueeze(1						).expand(-1   ,					self.num_choices   ,					-1						).contiguous()
											__a	  =		input_mask.unsqueeze(1						).expand(-1   ,					self.num_choices   ,					-1						).contiguous()
											__a	  =		model(
											    _SCREAMING_SNAKE_CASE   ,					attention_mask=_SCREAMING_SNAKE_CASE   ,					token_type_ids=_SCREAMING_SNAKE_CASE   ,					labels=_SCREAMING_SNAKE_CASE   ,					)
											self.parent.assertEqual(result.logits.shape   ,					(self.batch_size, self.num_choices)						)







							def     UpperCamelCase_       ( self		:		int						):

											'''simple docstring'''
											__a	  =		self.prepare_config_and_inputs()
											(
											    __a						
											)	  =		config_and_inputs
											__a	  =		{'input_ids': input_ids, 'token_type_ids': token_type_ids, 'attention_mask': input_mask}
											return config, inputs_dict






@require_torch
class  SCREAMING_SNAKE_CASE      (				_lowerCamelCase      ,   _lowerCamelCase      ,   unittest.TestCase       ):
							__lowerCamelCase						:						Optional[int]     =(
							    (
							        MegatronBertModel,
							        MegatronBertForMaskedLM,
							        MegatronBertForCausalLM,
							        MegatronBertForMultipleChoice,
							        MegatronBertForNextSentencePrediction,
							        MegatronBertForPreTraining,
							        MegatronBertForQuestionAnswering,
							        MegatronBertForSequenceClassification,
							        MegatronBertForTokenClassification,
							    )
							    if is_torch_available()
							    else ()
							)
							__lowerCamelCase						:						List[str]     =(
							    {
							        '''feature-extraction''': MegatronBertModel,
							        '''fill-mask''': MegatronBertForMaskedLM,
							        '''question-answering''': MegatronBertForQuestionAnswering,
							        '''text-classification''': MegatronBertForSequenceClassification,
							        '''text-generation''': MegatronBertForCausalLM,
							        '''token-classification''': MegatronBertForTokenClassification,
							        '''zero-shot''': MegatronBertForSequenceClassification,
							    }
							    if is_torch_available()
							    else {}
							)
							__lowerCamelCase						:						Union[str, Any]     =True
							# test_resize_embeddings = False
							__lowerCamelCase						:						List[str]     =False





							def     UpperCamelCase_       ( self		:		str   ,					__lowercase		:		str   ,					__lowercase		:		Optional[int]   ,					__lowercase		:		int=False						):

											'''simple docstring'''
											__a	  =		super()._prepare_for_class(_SCREAMING_SNAKE_CASE   ,					_SCREAMING_SNAKE_CASE   ,					return_labels=_SCREAMING_SNAKE_CASE						)

											if return_labels:
															if model_class in get_values(_SCREAMING_SNAKE_CASE						):
																			__a	  =		torch.zeros(
																			    (self.model_tester.batch_size, self.model_tester.seq_length)   ,					dtype=torch.long   ,					device=_SCREAMING_SNAKE_CASE						)
																			__a	  =		torch.zeros(
																			    self.model_tester.batch_size   ,					dtype=torch.long   ,					device=_SCREAMING_SNAKE_CASE						)
											return inputs_dict





							def     UpperCamelCase_       ( self		:		Dict						):

											'''simple docstring'''
											__a	  =		MegatronBertModelTester(self						)
											__a	  =		ConfigTester(self   ,					config_class=_SCREAMING_SNAKE_CASE   ,					hidden_size=37						)





							def     UpperCamelCase_       ( self		:		List[Any]						):

											'''simple docstring'''
											self.config_tester.run_common_tests()





							def     UpperCamelCase_       ( self		:		Optional[int]						):

											'''simple docstring'''
											__a	  =		self.model_tester.prepare_config_and_inputs()
											self.model_tester.create_and_check_megatron_bert_model(*_SCREAMING_SNAKE_CASE						)





							def     UpperCamelCase_       ( self		:		Any						):

											'''simple docstring'''
											__a	  =		self.model_tester.prepare_config_and_inputs()
											self.model_tester.create_and_check_megatron_bert_for_masked_lm(*_SCREAMING_SNAKE_CASE						)





							def     UpperCamelCase_       ( self		:		int						):

											'''simple docstring'''
											__a	  =		self.model_tester.prepare_config_and_inputs()
											self.model_tester.create_and_check_megatron_bert_for_multiple_choice(*_SCREAMING_SNAKE_CASE						)





							def     UpperCamelCase_       ( self		:		str						):

											'''simple docstring'''
											__a	  =		self.model_tester.prepare_config_and_inputs()
											self.model_tester.create_and_check_megatron_bert_for_next_sequence_prediction(*_SCREAMING_SNAKE_CASE						)





							def     UpperCamelCase_       ( self		:		int						):

											'''simple docstring'''
											__a	  =		self.model_tester.prepare_config_and_inputs()
											self.model_tester.create_and_check_megatron_bert_for_pretraining(*_SCREAMING_SNAKE_CASE						)





							def     UpperCamelCase_       ( self		:		Dict						):

											'''simple docstring'''
											__a	  =		self.model_tester.prepare_config_and_inputs()
											self.model_tester.create_and_check_megatron_bert_for_question_answering(*_SCREAMING_SNAKE_CASE						)





							def     UpperCamelCase_       ( self		:		Union[str, Any]						):

											'''simple docstring'''
											__a	  =		self.model_tester.prepare_config_and_inputs()
											self.model_tester.create_and_check_megatron_bert_for_sequence_classification(*_SCREAMING_SNAKE_CASE						)







							def     UpperCamelCase_       ( self		:		Optional[Any]						):

											'''simple docstring'''
											__a	  =		self.model_tester.prepare_config_and_inputs()
											self.model_tester.create_and_check_megatron_bert_for_token_classification(*_SCREAMING_SNAKE_CASE						)



def 	lowerCAmelCase__    (				_SCREAMING_SNAKE_CASE							:      int     ):
				"""simple docstring"""







				return torch.tensor(
				    __A					,  dtype=torch.long					,  device=__A					,  )


lowerCamelCase__      =			1e-4






@require_torch
@require_sentencepiece
@require_tokenizers
class  SCREAMING_SNAKE_CASE      (				unittest.TestCase       ):





							@slow
							@unittest.skip("""Model is not available."""						)
							def     UpperCamelCase_       ( self		:		List[str]						):

											'''simple docstring'''
											__a	  =		'nvidia/megatron-bert-uncased-345m'
											if "MYDIR" in os.environ:
															__a	  =		os.path.join(os.environ["""MYDIR"""]   ,					_SCREAMING_SNAKE_CASE						)
											__a	  =		MegatronBertModel.from_pretrained(_SCREAMING_SNAKE_CASE						)
											model.to(_SCREAMING_SNAKE_CASE						)
											model.half()
											__a	  =		_long_tensor([[101, 7110, 1005, 1056, 2023, 11333, 17413, 1029, 102]]						)
											with torch.no_grad():
															__a	  =		model(_SCREAMING_SNAKE_CASE						)[0]
											__a	  =		torch.Size((1, 9, 1024)						)
											self.assertEqual(output.shape   ,					_SCREAMING_SNAKE_CASE						)

											__a	  =		[-0.6040, -0.2517, -0.1025, 0.3420, -0.6758, -0.0017, -0.1089, -0.1990, 0.5728]
											for ii in range(3						):
															for jj in range(3						):
																			__a	  =		output[0, ii, jj]
																			__a	  =		expected[3 * ii + jj]
																			__a	  =		'ii={} jj={} a={} b={}'.format(_SCREAMING_SNAKE_CASE   ,					_SCREAMING_SNAKE_CASE   ,					_SCREAMING_SNAKE_CASE   ,					_SCREAMING_SNAKE_CASE						)
																			self.assertTrue(math.isclose(_SCREAMING_SNAKE_CASE   ,					_SCREAMING_SNAKE_CASE   ,					rel_tol=_SCREAMING_SNAKE_CASE   ,					abs_tol=_SCREAMING_SNAKE_CASE						)   ,					msg=_SCREAMING_SNAKE_CASE						)





"""simple docstring"""

A_						:    Optional[Any]				=      '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





