
'''simple docstring'''





import unittest

from transformers import MraConfig, is_torch_available
from transformers.testing_utils import require_torch, slow, torch_device

from ...test_configuration_common import ConfigTester
from ...test_modeling_common import ModelTesterMixin, floats_tensor, ids_tensor, random_attention_mask


if is_torch_available():
     import torch

     from transformers import (
         MraForMaskedLM,
         MraForMultipleChoice,
         MraForQuestionAnswering,
         MraForSequenceClassification,
         MraForTokenClassification,
         MraModel,
     )
     from transformers.models.mra.modeling_mra import MRA_PRETRAINED_MODEL_ARCHIVE_LIST



class       _snake_case   :


 def __init__(					self					,  SCREAMING_SNAKE_CASE_					,  SCREAMING_SNAKE_CASE_=2					,  SCREAMING_SNAKE_CASE_=8					,  SCREAMING_SNAKE_CASE_=True					,  SCREAMING_SNAKE_CASE_=True					,  SCREAMING_SNAKE_CASE_=True					,  SCREAMING_SNAKE_CASE_=True					,  SCREAMING_SNAKE_CASE_=99					,  SCREAMING_SNAKE_CASE_=16					,  SCREAMING_SNAKE_CASE_=5					,  SCREAMING_SNAKE_CASE_=2					,  SCREAMING_SNAKE_CASE_=36					,  SCREAMING_SNAKE_CASE_="gelu"					,  SCREAMING_SNAKE_CASE_=0.0					,  SCREAMING_SNAKE_CASE_=0.0					,  SCREAMING_SNAKE_CASE_=5_12					,  SCREAMING_SNAKE_CASE_=16					,  SCREAMING_SNAKE_CASE_=2					,  SCREAMING_SNAKE_CASE_=0.0_2					,  SCREAMING_SNAKE_CASE_=3					,  SCREAMING_SNAKE_CASE_=4					,  SCREAMING_SNAKE_CASE_=None					,  ):


   '''simple docstring'''




   lowercase__  :   Any    		=      parent
   lowercase__  :   Optional[Any]    		=      batch_size
   lowercase__  :   Dict    		=      seq_length
   lowercase__  :   Optional[Any]    		=      is_training
   lowercase__  :   List[str]    		=      use_input_mask
   lowercase__  :   List[Any]    		=      use_token_type_ids
   lowercase__  :   Dict    		=      use_labels
   lowercase__  :   Dict    		=      vocab_size
   lowercase__  :   Optional[int]    		=      hidden_size
   lowercase__  :   Tuple    		=      num_hidden_layers
   lowercase__  :   Dict    		=      num_attention_heads
   lowercase__  :   Dict    		=      intermediate_size
   lowercase__  :   Optional[int]    		=      hidden_act
   lowercase__  :   Optional[Any]    		=      hidden_dropout_prob
   lowercase__  :   List[Any]    		=      attention_probs_dropout_prob
   lowercase__  :   Any    		=      max_position_embeddings
   lowercase__  :   str    		=      type_vocab_size
   lowercase__  :   Dict    		=      type_sequence_label_size
   lowercase__  :   Any    		=      initializer_range
   lowercase__  :   Any    		=      num_labels
   lowercase__  :   Optional[Any]    		=      num_choices
   lowercase__  :   int    		=      scope


 def      lowercase__     (					self):


   '''simple docstring'''




   lowercase__  :   Dict    		=      ids_tensor([self.batch_size, self.seq_length]					,  self.vocab_size)

   lowercase__  :   Any    		=      None
   if self.use_input_mask:
     lowercase__  :   Tuple    		=      random_attention_mask([self.batch_size, self.seq_length])

   lowercase__  :   List[str]    		=      None
   if self.use_token_type_ids:
     lowercase__  :   int    		=      ids_tensor([self.batch_size, self.seq_length]					,  self.type_vocab_size)

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

   lowercase__  :   int    		=      self.get_config()

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


 def      lowercase__     (					self):


   '''simple docstring'''




   return MraConfig(
       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					,  is_decoder=SCREAMING_SNAKE_CASE_					,  initializer_range=self.initializer_range					,  )


 def      lowercase__     (					self):


   '''simple docstring'''




   lowercase__  :   List[Any]    		=      self.get_config()
   lowercase__  :   str    		=      3_00
   return config


 def      lowercase__     (					self):


   '''simple docstring'''




   (
       lowercase__    
   )  :   Dict    		=      self.prepare_config_and_inputs()

   lowercase__  :   List[Any]    		=      True
   lowercase__  :   Dict    		=      floats_tensor([self.batch_size, self.seq_length, self.hidden_size])
   lowercase__  :   List[str]    		=      ids_tensor([self.batch_size, self.seq_length]					,  vocab_size=2)

   return (
       config,
       input_ids,
       token_type_ids,
       input_mask,
       sequence_labels,
       token_labels,
       choice_labels,
       encoder_hidden_states,
       encoder_attention_mask,
   )


 def      lowercase__     (					self					,  SCREAMING_SNAKE_CASE_					,  SCREAMING_SNAKE_CASE_					,  SCREAMING_SNAKE_CASE_					,  SCREAMING_SNAKE_CASE_					,  SCREAMING_SNAKE_CASE_					,  SCREAMING_SNAKE_CASE_					,  SCREAMING_SNAKE_CASE_):


   '''simple docstring'''




   lowercase__  :   Tuple    		=      MraModel(config=SCREAMING_SNAKE_CASE_)
   model.to(SCREAMING_SNAKE_CASE_)
   model.eval()
   lowercase__  :   Optional[Any]    		=      model(SCREAMING_SNAKE_CASE_					,  attention_mask=SCREAMING_SNAKE_CASE_					,  token_type_ids=SCREAMING_SNAKE_CASE_)
   lowercase__  :   Any    		=      model(SCREAMING_SNAKE_CASE_					,  token_type_ids=SCREAMING_SNAKE_CASE_)
   lowercase__  :   List[Any]    		=      model(SCREAMING_SNAKE_CASE_)
   self.parent.assertEqual(result.last_hidden_state.shape					,  (self.batch_size, self.seq_length, self.hidden_size))


 def      lowercase__     (					self					,  SCREAMING_SNAKE_CASE_					,  SCREAMING_SNAKE_CASE_					,  SCREAMING_SNAKE_CASE_					,  SCREAMING_SNAKE_CASE_					,  SCREAMING_SNAKE_CASE_					,  SCREAMING_SNAKE_CASE_					,  SCREAMING_SNAKE_CASE_					,  SCREAMING_SNAKE_CASE_					,  SCREAMING_SNAKE_CASE_					,  ):


   '''simple docstring'''




   lowercase__  :   Optional[int]    		=      True
   lowercase__  :   Tuple    		=      MraModel(SCREAMING_SNAKE_CASE_)
   model.to(SCREAMING_SNAKE_CASE_)
   model.eval()
   lowercase__  :   List[Any]    		=      model(
       SCREAMING_SNAKE_CASE_					,  attention_mask=SCREAMING_SNAKE_CASE_					,  token_type_ids=SCREAMING_SNAKE_CASE_					,  encoder_hidden_states=SCREAMING_SNAKE_CASE_					,  encoder_attention_mask=SCREAMING_SNAKE_CASE_					,  )
   lowercase__  :   List[str]    		=      model(
       SCREAMING_SNAKE_CASE_					,  attention_mask=SCREAMING_SNAKE_CASE_					,  token_type_ids=SCREAMING_SNAKE_CASE_					,  encoder_hidden_states=SCREAMING_SNAKE_CASE_					,  )
   lowercase__  :   Union[str, Any]    		=      model(SCREAMING_SNAKE_CASE_					,  attention_mask=SCREAMING_SNAKE_CASE_					,  token_type_ids=SCREAMING_SNAKE_CASE_)
   self.parent.assertEqual(result.last_hidden_state.shape					,  (self.batch_size, self.seq_length, self.hidden_size))


 def      lowercase__     (					self					,  SCREAMING_SNAKE_CASE_					,  SCREAMING_SNAKE_CASE_					,  SCREAMING_SNAKE_CASE_					,  SCREAMING_SNAKE_CASE_					,  SCREAMING_SNAKE_CASE_					,  SCREAMING_SNAKE_CASE_					,  SCREAMING_SNAKE_CASE_):


   '''simple docstring'''




   lowercase__  :   str    		=      MraForMaskedLM(config=SCREAMING_SNAKE_CASE_)
   model.to(SCREAMING_SNAKE_CASE_)
   model.eval()
   lowercase__  :   Dict    		=      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      lowercase__     (					self					,  SCREAMING_SNAKE_CASE_					,  SCREAMING_SNAKE_CASE_					,  SCREAMING_SNAKE_CASE_					,  SCREAMING_SNAKE_CASE_					,  SCREAMING_SNAKE_CASE_					,  SCREAMING_SNAKE_CASE_					,  SCREAMING_SNAKE_CASE_):


   '''simple docstring'''




   lowercase__  :   Optional[int]    		=      MraForQuestionAnswering(config=SCREAMING_SNAKE_CASE_)
   model.to(SCREAMING_SNAKE_CASE_)
   model.eval()
   lowercase__  :   Tuple    		=      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      lowercase__     (					self					,  SCREAMING_SNAKE_CASE_					,  SCREAMING_SNAKE_CASE_					,  SCREAMING_SNAKE_CASE_					,  SCREAMING_SNAKE_CASE_					,  SCREAMING_SNAKE_CASE_					,  SCREAMING_SNAKE_CASE_					,  SCREAMING_SNAKE_CASE_):


   '''simple docstring'''




   lowercase__  :   Dict    		=      self.num_labels
   lowercase__  :   Tuple    		=      MraForSequenceClassification(SCREAMING_SNAKE_CASE_)
   model.to(SCREAMING_SNAKE_CASE_)
   model.eval()
   lowercase__  :   Optional[Any]    		=      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      lowercase__     (					self					,  SCREAMING_SNAKE_CASE_					,  SCREAMING_SNAKE_CASE_					,  SCREAMING_SNAKE_CASE_					,  SCREAMING_SNAKE_CASE_					,  SCREAMING_SNAKE_CASE_					,  SCREAMING_SNAKE_CASE_					,  SCREAMING_SNAKE_CASE_):


   '''simple docstring'''




   lowercase__  :   str    		=      self.num_labels
   lowercase__  :   Tuple    		=      MraForTokenClassification(config=SCREAMING_SNAKE_CASE_)
   model.to(SCREAMING_SNAKE_CASE_)
   model.eval()
   lowercase__  :   Optional[int]    		=      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      lowercase__     (					self					,  SCREAMING_SNAKE_CASE_					,  SCREAMING_SNAKE_CASE_					,  SCREAMING_SNAKE_CASE_					,  SCREAMING_SNAKE_CASE_					,  SCREAMING_SNAKE_CASE_					,  SCREAMING_SNAKE_CASE_					,  SCREAMING_SNAKE_CASE_):


   '''simple docstring'''




   lowercase__  :   Tuple    		=      self.num_choices
   lowercase__  :   Any    		=      MraForMultipleChoice(config=SCREAMING_SNAKE_CASE_)
   model.to(SCREAMING_SNAKE_CASE_)
   model.eval()
   lowercase__  :   Dict    		=      input_ids.unsqueeze(1).expand(-1					,  self.num_choices					,  -1).contiguous()
   lowercase__  :   List[Any]    		=      token_type_ids.unsqueeze(1).expand(-1					,  self.num_choices					,  -1).contiguous()
   lowercase__  :   Union[str, Any]    		=      input_mask.unsqueeze(1).expand(-1					,  self.num_choices					,  -1).contiguous()
   lowercase__  :   str    		=      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      lowercase__     (					self):


   '''simple docstring'''




   lowercase__  :   int    		=      self.prepare_config_and_inputs()
   (
       lowercase__    
   )  :   Tuple    		=      config_and_inputs
   lowercase__  :   str    		=      {"""input_ids""": input_ids, """token_type_ids""": token_type_ids, """attention_mask""": input_mask}
   return config, inputs_dict



@require_torch
class       _snake_case   (	UpperCAmelCase_  ,						unittest.TestCase							):
 __lowerCAmelCase  :     Tuple        =			(
     (
         MraModel,
         MraForMaskedLM,
         MraForMultipleChoice,
         MraForQuestionAnswering,
         MraForSequenceClassification,
         MraForTokenClassification,
     )
     if is_torch_available()
     else ()
 )
 __lowerCAmelCase  :     Any        =			False
 __lowerCAmelCase  :     Tuple        =			False
 __lowerCAmelCase  :     str        =			False
 __lowerCAmelCase  :     Optional[int]        =			False

 __lowerCAmelCase  :     Any        =			()


 def      lowercase__     (					self):


   '''simple docstring'''




   lowercase__  :   Dict    		=      MraModelTester(self)
   lowercase__  :   str    		=      ConfigTester(self					,  config_class=SCREAMING_SNAKE_CASE_					,  hidden_size=37)


 def      lowercase__     (					self):


   '''simple docstring'''




   self.config_tester.run_common_tests()


 def      lowercase__     (					self):


   '''simple docstring'''




   lowercase__  :   List[str]    		=      self.model_tester.prepare_config_and_inputs()
   self.model_tester.create_and_check_model(*SCREAMING_SNAKE_CASE_)


 def      lowercase__     (					self):


   '''simple docstring'''




   lowercase__  :   Optional[Any]    		=      self.model_tester.prepare_config_and_inputs()
   for type in ["absolute", "relative_key", "relative_key_query"]:
     lowercase__  :   Optional[int]    		=      type
     self.model_tester.create_and_check_model(*SCREAMING_SNAKE_CASE_)


 def      lowercase__     (					self):


   '''simple docstring'''




   lowercase__  :   List[Any]    		=      self.model_tester.prepare_config_and_inputs()
   self.model_tester.create_and_check_for_masked_lm(*SCREAMING_SNAKE_CASE_)


 def      lowercase__     (					self):


   '''simple docstring'''




   lowercase__  :   int    		=      self.model_tester.prepare_config_and_inputs()
   self.model_tester.create_and_check_for_multiple_choice(*SCREAMING_SNAKE_CASE_)


 def      lowercase__     (					self):


   '''simple docstring'''




   lowercase__  :   Optional[Any]    		=      self.model_tester.prepare_config_and_inputs()
   self.model_tester.create_and_check_for_question_answering(*SCREAMING_SNAKE_CASE_)


 def      lowercase__     (					self):


   '''simple docstring'''




   lowercase__  :   int    		=      self.model_tester.prepare_config_and_inputs()
   self.model_tester.create_and_check_for_sequence_classification(*SCREAMING_SNAKE_CASE_)


 def      lowercase__     (					self):


   '''simple docstring'''




   lowercase__  :   Any    		=      self.model_tester.prepare_config_and_inputs()
   self.model_tester.create_and_check_for_token_classification(*SCREAMING_SNAKE_CASE_)


 @slow
 def      lowercase__     (					self):


   '''simple docstring'''




   for model_name in MRA_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
     lowercase__  :   Union[str, Any]    		=      MraModel.from_pretrained(SCREAMING_SNAKE_CASE_)
     self.assertIsNotNone(SCREAMING_SNAKE_CASE_)



 @unittest.skip(reason="""MRA does not output attentions""")
 def      lowercase__     (					self):


   '''simple docstring'''




   return



@require_torch
class       _snake_case   (	unittest.TestCase							):


 @slow
 def      lowercase__     (					self):


   '''simple docstring'''




   lowercase__  :   Tuple    		=      MraModel.from_pretrained("""uw-madison/mra-base-512-4""")
   lowercase__  :   Optional[Any]    		=      torch.arange(2_56).unsqueeze(0)

   with torch.no_grad():
     lowercase__  :   int    		=      model(SCREAMING_SNAKE_CASE_)[0]

   lowercase__  :   Any    		=      torch.Size((1, 2_56, 7_68))
   self.assertEqual(output.shape					,  SCREAMING_SNAKE_CASE_)

   lowercase__  :   Union[str, Any]    		=      torch.tensor(
       [[[-0.0_1_4_0, 0.0_8_3_0, -0.0_3_8_1], [0.1_5_4_6, 0.1_4_0_2, 0.0_2_2_0], [0.1_1_6_2, 0.0_8_5_1, 0.0_1_6_5]]])

   self.assertTrue(torch.allclose(output[:, :3, :3]					,  SCREAMING_SNAKE_CASE_					,  atol=1E-4))


 @slow
 def      lowercase__     (					self):


   '''simple docstring'''




   lowercase__  :   Union[str, Any]    		=      MraForMaskedLM.from_pretrained("""uw-madison/mra-base-512-4""")
   lowercase__  :   int    		=      torch.arange(2_56).unsqueeze(0)

   with torch.no_grad():
     lowercase__  :   Optional[int]    		=      model(SCREAMING_SNAKE_CASE_)[0]

   lowercase__  :   str    		=      5_02_65

   lowercase__  :   List[str]    		=      torch.Size((1, 2_56, vocab_size))
   self.assertEqual(output.shape					,  SCREAMING_SNAKE_CASE_)

   lowercase__  :   Dict    		=      torch.tensor(
       [[[9.2_5_9_5, -3.6_0_3_8, 11.88_19], [9.3_8_6_9, -3.2_6_9_3, 11.09_56], [11.85_24, -3.4_9_3_8, 13.12_10]]])

   self.assertTrue(torch.allclose(output[:, :3, :3]					,  SCREAMING_SNAKE_CASE_					,  atol=1E-4))



 @slow
 def      lowercase__     (					self):


   '''simple docstring'''




   lowercase__  :   Tuple    		=      MraForMaskedLM.from_pretrained("""uw-madison/mra-base-4096-8-d3""")
   lowercase__  :   str    		=      torch.arange(40_96).unsqueeze(0)

   with torch.no_grad():
     lowercase__  :   Optional[int]    		=      model(SCREAMING_SNAKE_CASE_)[0]

   lowercase__  :   int    		=      5_02_65

   lowercase__  :   List[Any]    		=      torch.Size((1, 40_96, vocab_size))
   self.assertEqual(output.shape					,  SCREAMING_SNAKE_CASE_)

   lowercase__  :   List[Any]    		=      torch.tensor(
       [[[5.4_7_8_9, -2.3_5_6_4, 7.5_0_6_4], [7.9_0_6_7, -1.3_3_6_9, 9.9_6_6_8], [9.0_7_1_2, -1.8_1_0_6, 7.0_3_8_0]]])

   self.assertTrue(torch.allclose(output[:, :3, :3]					,  SCREAMING_SNAKE_CASE_					,  atol=1E-4))








lowerCamelCase__    :		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






