import unittest

from transformers import AlbertConfig, is_torch_available
from transformers.models.auto import get_values
from transformers.testing_utils import 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,
          AlbertForMaskedLM,
          AlbertForMultipleChoice,
          AlbertForPreTraining,
          AlbertForQuestionAnswering,
          AlbertForSequenceClassification,
          AlbertForTokenClassification,
          AlbertModel,
      )
      from transformers.models.albert.modeling_albert import ALBERT_PRETRAINED_MODEL_ARCHIVE_LIST






class 		_lowerCamelCase		:
    def __init__(  self , lowerCAmelCase , lowerCAmelCase=13 , lowerCAmelCase=7 , lowerCAmelCase=True , lowerCAmelCase=True , lowerCAmelCase=True , lowerCAmelCase=True , lowerCAmelCase=99 , lowerCAmelCase=16 , lowerCAmelCase=36 , lowerCAmelCase=6 , lowerCAmelCase=6 , lowerCAmelCase=6 , lowerCAmelCase=37 , lowerCAmelCase="gelu" , lowerCAmelCase=0.1 , lowerCAmelCase=0.1 , lowerCAmelCase=512 , lowerCAmelCase=16 , lowerCAmelCase=2 , lowerCAmelCase=0.02 , lowerCAmelCase=3 , lowerCAmelCase=4 , lowerCAmelCase=None , )       ->					List[Any]:
     SCREAMING_SNAKE_CASE__:   Dict=      parent
     SCREAMING_SNAKE_CASE__:   List[Any]=      batch_size
     SCREAMING_SNAKE_CASE__:   Any=      seq_length
     SCREAMING_SNAKE_CASE__:   List[str]=      is_training
     SCREAMING_SNAKE_CASE__:   int=      use_input_mask
     SCREAMING_SNAKE_CASE__:   List[str]=      use_token_type_ids
     SCREAMING_SNAKE_CASE__:   int=      use_labels
     SCREAMING_SNAKE_CASE__:   Dict=      vocab_size
     SCREAMING_SNAKE_CASE__:   List[Any]=      embedding_size
     SCREAMING_SNAKE_CASE__:   Dict=      hidden_size
     SCREAMING_SNAKE_CASE__:   Any=      num_hidden_layers
     SCREAMING_SNAKE_CASE__:   Optional[Any]=      num_hidden_groups
     SCREAMING_SNAKE_CASE__:   Optional[int]=      num_attention_heads
     SCREAMING_SNAKE_CASE__:   List[str]=      intermediate_size
     SCREAMING_SNAKE_CASE__:   Optional[Any]=      hidden_act
     SCREAMING_SNAKE_CASE__:   str=      hidden_dropout_prob
     SCREAMING_SNAKE_CASE__:   Union[str, Any]=      attention_probs_dropout_prob
     SCREAMING_SNAKE_CASE__:   Optional[int]=      max_position_embeddings
     SCREAMING_SNAKE_CASE__:   List[Any]=      type_vocab_size
     SCREAMING_SNAKE_CASE__:   Optional[Any]=      type_sequence_label_size
     SCREAMING_SNAKE_CASE__:   Optional[int]=      initializer_range
     SCREAMING_SNAKE_CASE__:   str=      num_labels
     SCREAMING_SNAKE_CASE__:   List[Any]=      num_choices
     SCREAMING_SNAKE_CASE__:   Any=      scope
    def 						UpperCamelCase_				(  self   )       ->					Optional[Any]:
     SCREAMING_SNAKE_CASE__:   Optional[Any]=      ids_tensor([self.batch_size, self.seq_length] , self.vocab_size   )

     SCREAMING_SNAKE_CASE__:   Optional[int]=      None
     if self.use_input_mask:
      SCREAMING_SNAKE_CASE__:   Any=      random_attention_mask([self.batch_size, self.seq_length]   )

     SCREAMING_SNAKE_CASE__:   Optional[Any]=      None
     if self.use_token_type_ids:
      SCREAMING_SNAKE_CASE__:   Union[str, Any]=      ids_tensor([self.batch_size, self.seq_length] , self.type_vocab_size   )

     SCREAMING_SNAKE_CASE__:   Tuple=      None
     SCREAMING_SNAKE_CASE__:   List[str]=      None
     SCREAMING_SNAKE_CASE__:   int=      None
     if self.use_labels:
      SCREAMING_SNAKE_CASE__:   Tuple=      ids_tensor([self.batch_size] , self.type_sequence_label_size   )
      SCREAMING_SNAKE_CASE__:   Union[str, Any]=      ids_tensor([self.batch_size, self.seq_length] , self.num_labels   )
      SCREAMING_SNAKE_CASE__:   str=      ids_tensor([self.batch_size] , self.num_choices   )

     SCREAMING_SNAKE_CASE__:   Union[str, Any]=      self.get_config()

     return config, input_ids, token_type_ids, input_mask, sequence_labels, token_labels, choice_labels
    def 						UpperCamelCase_				(  self   )       ->					str:
     return AlbertConfig(
         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 , 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 , initializer_range=self.initializer_range , num_hidden_groups=self.num_hidden_groups , )
    def 						UpperCamelCase_				(  self , lowerCAmelCase , lowerCAmelCase , lowerCAmelCase , lowerCAmelCase , lowerCAmelCase , lowerCAmelCase , lowerCAmelCase   )       ->					Optional[Any]:
     SCREAMING_SNAKE_CASE__:   int=      AlbertModel(config=__lowerCamelCase   )
     model.to(__lowerCamelCase   )
     model.eval()
     SCREAMING_SNAKE_CASE__:   Any=      model(__lowerCamelCase , attention_mask=__lowerCamelCase , token_type_ids=__lowerCamelCase   )
     SCREAMING_SNAKE_CASE__:   Any=      model(__lowerCamelCase , token_type_ids=__lowerCamelCase   )
     SCREAMING_SNAKE_CASE__:   Optional[int]=      model(__lowerCamelCase   )
     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 , lowerCAmelCase , lowerCAmelCase , lowerCAmelCase , lowerCAmelCase , lowerCAmelCase , lowerCAmelCase , lowerCAmelCase   )       ->					Tuple:
     SCREAMING_SNAKE_CASE__:   Any=      AlbertForPreTraining(config=__lowerCamelCase   )
     model.to(__lowerCamelCase   )
     model.eval()
     SCREAMING_SNAKE_CASE__:   Union[str, Any]=      model(
         __lowerCamelCase , attention_mask=__lowerCamelCase , token_type_ids=__lowerCamelCase , labels=__lowerCamelCase , sentence_order_label=__lowerCamelCase , )
     self.parent.assertEqual(result.prediction_logits.shape , (self.batch_size, self.seq_length, self.vocab_size)   )
     self.parent.assertEqual(result.sop_logits.shape , (self.batch_size, config.num_labels)   )
    def 						UpperCamelCase_				(  self , lowerCAmelCase , lowerCAmelCase , lowerCAmelCase , lowerCAmelCase , lowerCAmelCase , lowerCAmelCase , lowerCAmelCase   )       ->					List[str]:
     SCREAMING_SNAKE_CASE__:   Dict=      AlbertForMaskedLM(config=__lowerCamelCase   )
     model.to(__lowerCamelCase   )
     model.eval()
     SCREAMING_SNAKE_CASE__:   Tuple=      model(__lowerCamelCase , attention_mask=__lowerCamelCase , token_type_ids=__lowerCamelCase , labels=__lowerCamelCase   )
     self.parent.assertEqual(result.logits.shape , (self.batch_size, self.seq_length, self.vocab_size)   )
    def 						UpperCamelCase_				(  self , lowerCAmelCase , lowerCAmelCase , lowerCAmelCase , lowerCAmelCase , lowerCAmelCase , lowerCAmelCase , lowerCAmelCase   )       ->					Optional[Any]:
     SCREAMING_SNAKE_CASE__:   str=      AlbertForQuestionAnswering(config=__lowerCamelCase   )
     model.to(__lowerCamelCase   )
     model.eval()
     SCREAMING_SNAKE_CASE__:   str=      model(
         __lowerCamelCase , attention_mask=__lowerCamelCase , token_type_ids=__lowerCamelCase , start_positions=__lowerCamelCase , end_positions=__lowerCamelCase , )
     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 , lowerCAmelCase , lowerCAmelCase , lowerCAmelCase , lowerCAmelCase , lowerCAmelCase , lowerCAmelCase , lowerCAmelCase   )       ->					Optional[int]:
     SCREAMING_SNAKE_CASE__:   int=      self.num_labels
     SCREAMING_SNAKE_CASE__:   Optional[int]=      AlbertForSequenceClassification(__lowerCamelCase   )
     model.to(__lowerCamelCase   )
     model.eval()
     SCREAMING_SNAKE_CASE__:   Any=      model(__lowerCamelCase , attention_mask=__lowerCamelCase , token_type_ids=__lowerCamelCase , labels=__lowerCamelCase   )
     self.parent.assertEqual(result.logits.shape , (self.batch_size, self.num_labels)   )
    def 						UpperCamelCase_				(  self , lowerCAmelCase , lowerCAmelCase , lowerCAmelCase , lowerCAmelCase , lowerCAmelCase , lowerCAmelCase , lowerCAmelCase   )       ->					Tuple:
     SCREAMING_SNAKE_CASE__:   Optional[int]=      self.num_labels
     SCREAMING_SNAKE_CASE__:   List[str]=      AlbertForTokenClassification(config=__lowerCamelCase   )
     model.to(__lowerCamelCase   )
     model.eval()
     SCREAMING_SNAKE_CASE__:   Tuple=      model(__lowerCamelCase , attention_mask=__lowerCamelCase , token_type_ids=__lowerCamelCase , labels=__lowerCamelCase   )
     self.parent.assertEqual(result.logits.shape , (self.batch_size, self.seq_length, self.num_labels)   )
    def 						UpperCamelCase_				(  self , lowerCAmelCase , lowerCAmelCase , lowerCAmelCase , lowerCAmelCase , lowerCAmelCase , lowerCAmelCase , lowerCAmelCase   )       ->					List[str]:
     SCREAMING_SNAKE_CASE__:   Union[str, Any]=      self.num_choices
     SCREAMING_SNAKE_CASE__:   Optional[int]=      AlbertForMultipleChoice(config=__lowerCamelCase   )
     model.to(__lowerCamelCase   )
     model.eval()
     SCREAMING_SNAKE_CASE__:   Any=      input_ids.unsqueeze(1   ).expand(-1 , self.num_choices , -1   ).contiguous()
     SCREAMING_SNAKE_CASE__:   Optional[int]=      token_type_ids.unsqueeze(1   ).expand(-1 , self.num_choices , -1   ).contiguous()
     SCREAMING_SNAKE_CASE__:   Dict=      input_mask.unsqueeze(1   ).expand(-1 , self.num_choices , -1   ).contiguous()
     SCREAMING_SNAKE_CASE__:   int=      model(
         __lowerCamelCase , attention_mask=__lowerCamelCase , token_type_ids=__lowerCamelCase , labels=__lowerCamelCase , )
     self.parent.assertEqual(result.logits.shape , (self.batch_size, self.num_choices)   )



    def 						UpperCamelCase_				(  self   )       ->					str:
     SCREAMING_SNAKE_CASE__:   int=      self.prepare_config_and_inputs()
     (
         SCREAMING_SNAKE_CASE__     
     ):   Union[str, Any]=      config_and_inputs
     SCREAMING_SNAKE_CASE__:   str=      {"input_ids": input_ids, "token_type_ids": token_type_ids, "attention_mask": input_mask}
     return config, inputs_dict






@require_torch
class 		_lowerCamelCase		(   lowercase__    ,     lowercase__    ,     unittest.TestCase    ):
    __a  =      (
        (
            AlbertModel,
            AlbertForPreTraining,
            AlbertForMaskedLM,
            AlbertForMultipleChoice,
            AlbertForSequenceClassification,
            AlbertForTokenClassification,
            AlbertForQuestionAnswering,
        )
        if is_torch_available()
        else ()
    )
    __a  =      (
        {
            "feature-extraction": AlbertModel,
            "fill-mask": AlbertForMaskedLM,
            "question-answering": AlbertForQuestionAnswering,
            "text-classification": AlbertForSequenceClassification,
            "token-classification": AlbertForTokenClassification,
            "zero-shot": AlbertForSequenceClassification,
        }
        if is_torch_available()
        else {}
    )
    __a  =      True
    def 						UpperCamelCase_				(  self , lowerCAmelCase , lowerCAmelCase , lowerCAmelCase=False   )       ->					Optional[int]:
     SCREAMING_SNAKE_CASE__:   Any=      super()._prepare_for_class(__lowerCamelCase , __lowerCamelCase , return_labels=__lowerCamelCase   )

     if return_labels:
      if model_class in get_values(__lowerCamelCase   ):
       SCREAMING_SNAKE_CASE__:   Union[str, Any]=      torch.zeros(
           (self.model_tester.batch_size, self.model_tester.seq_length) , dtype=torch.long , device=__lowerCamelCase   )
       SCREAMING_SNAKE_CASE__:   List[str]=      torch.zeros(
           self.model_tester.batch_size , dtype=torch.long , device=__lowerCamelCase   )
     return inputs_dict
    def 						UpperCamelCase_				(  self   )       ->					Tuple:
     SCREAMING_SNAKE_CASE__:   Optional[int]=      AlbertModelTester(self   )
     SCREAMING_SNAKE_CASE__:   Optional[Any]=      ConfigTester(self , config_class=__lowerCamelCase , hidden_size=37   )
    def 						UpperCamelCase_				(  self   )       ->					Tuple:
     self.config_tester.run_common_tests()
    def 						UpperCamelCase_				(  self   )       ->					Tuple:
     SCREAMING_SNAKE_CASE__:   Optional[Any]=      self.model_tester.prepare_config_and_inputs()
     self.model_tester.create_and_check_model(*__lowerCamelCase   )
    def 						UpperCamelCase_				(  self   )       ->					Dict:
     SCREAMING_SNAKE_CASE__:   Union[str, Any]=      self.model_tester.prepare_config_and_inputs()
     self.model_tester.create_and_check_for_pretraining(*__lowerCamelCase   )
    def 						UpperCamelCase_				(  self   )       ->					str:
     SCREAMING_SNAKE_CASE__:   int=      self.model_tester.prepare_config_and_inputs()
     self.model_tester.create_and_check_for_masked_lm(*__lowerCamelCase   )
    def 						UpperCamelCase_				(  self   )       ->					Dict:
     SCREAMING_SNAKE_CASE__:   List[Any]=      self.model_tester.prepare_config_and_inputs()
     self.model_tester.create_and_check_for_multiple_choice(*__lowerCamelCase   )
    def 						UpperCamelCase_				(  self   )       ->					int:
     SCREAMING_SNAKE_CASE__:   Optional[Any]=      self.model_tester.prepare_config_and_inputs()
     self.model_tester.create_and_check_for_question_answering(*__lowerCamelCase   )
    def 						UpperCamelCase_				(  self   )       ->					List[Any]:
     SCREAMING_SNAKE_CASE__:   List[str]=      self.model_tester.prepare_config_and_inputs()
     self.model_tester.create_and_check_for_sequence_classification(*__lowerCamelCase   )
    def 						UpperCamelCase_				(  self   )       ->					int:
     SCREAMING_SNAKE_CASE__:   List[str]=      self.model_tester.prepare_config_and_inputs()
     for type in ["absolute", "relative_key", "relative_key_query"]:
      SCREAMING_SNAKE_CASE__:   Dict=      type
      self.model_tester.create_and_check_model(*__lowerCamelCase   )



    @slow
    def 						UpperCamelCase_				(  self   )       ->					Optional[Any]:



     for model_name in ALBERT_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
      SCREAMING_SNAKE_CASE__:   List[str]=      AlbertModel.from_pretrained(__lowerCamelCase   )
      self.assertIsNotNone(__lowerCamelCase   )






@require_torch
class 		_lowerCamelCase		(   unittest.TestCase    ):
    @slow
    def 						UpperCamelCase_				(  self   )       ->					Optional[Any]:
     SCREAMING_SNAKE_CASE__:   List[Any]=      AlbertModel.from_pretrained('''albert-base-v2'''   )
     SCREAMING_SNAKE_CASE__:   Any=      torch.tensor([[0, 345, 232, 328, 740, 140, 1695, 69, 6078, 1588, 2]]   )
     SCREAMING_SNAKE_CASE__:   int=      torch.tensor([[0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]   )
     with torch.no_grad():
      SCREAMING_SNAKE_CASE__:   List[Any]=      model(__lowerCamelCase , attention_mask=__lowerCamelCase   )[0]
     SCREAMING_SNAKE_CASE__:   Tuple=      torch.Size((1, 11, 768)   )
     self.assertEqual(output.shape , __lowerCamelCase   )
     SCREAMING_SNAKE_CASE__:   Dict=      torch.tensor(
         [[[-0.6513, 1.5035, -0.2766], [-0.6515, 1.5046, -0.2780], [-0.6512, 1.5049, -0.2784]]]   )

     self.assertTrue(torch.allclose(output[:, 1:4, 1:4] , __lowerCamelCase , atol=1e-4   )   )


lowercase_     :   Optional[int] 				=				'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

