class_docstr: Pipeline for text-to-audio generation using AudioLDM2.
  
  This model inherits from [`DiffusionPipeline`]. Check the superclass documentation for the generic methods
  implemented for all pipelines (downloading, saving, running on a particular device, etc.).
  
  Args:
      vae ([`AutoencoderKL`]):
          Variational Auto-Encoder (VAE) model to encode and decode images to and from latent representations.
      text_encoder ([`~transformers.ClapModel`]):
          First frozen text-encoder. AudioLDM2 uses the joint audio-text embedding model
          [CLAP](https://huggingface.co/docs/transformers/model_doc/clap#transformers.CLAPTextModelWithProjection),
          specifically the [laion/clap-htsat-unfused](https://huggingface.co/laion/clap-htsat-unfused) variant. The
          text branch is used to encode the text prompt to a prompt embedding. The full audio-text model is used to
          rank generated waveforms against the text prompt by computing similarity scores.
      text_encoder_2 ([`~transformers.T5EncoderModel`]):
          Second frozen text-encoder. AudioLDM2 uses the encoder of
          [T5](https://huggingface.co/docs/transformers/model_doc/t5#transformers.T5EncoderModel), specifically the
          [google/flan-t5-large](https://huggingface.co/google/flan-t5-large) variant.
      projection_model ([`AudioLDM2ProjectionModel`]):
          A trained model used to linearly project the hidden-states from the first and second text encoder models
          and insert learned SOS and EOS token embeddings. The projected hidden-states from the two text encoders are
          concatenated to give the input to the language model.
      language_model ([`~transformers.GPT2Model`]):
          An auto-regressive language model used to generate a sequence of hidden-states conditioned on the projected
          outputs from the two text encoders.
      tokenizer ([`~transformers.RobertaTokenizer`]):
          Tokenizer to tokenize text for the first frozen text-encoder.
      tokenizer_2 ([`~transformers.T5Tokenizer`]):
          Tokenizer to tokenize text for the second frozen text-encoder.
      feature_extractor ([`~transformers.ClapFeatureExtractor`]):
          Feature extractor to pre-process generated audio waveforms to log-mel spectrograms for automatic scoring.
      unet ([`UNet2DConditionModel`]):
          A `UNet2DConditionModel` to denoise the encoded audio latents.
      scheduler ([`SchedulerMixin`]):
          A scheduler to be used in combination with `unet` to denoise the encoded audio latents. Can be one of
          [`DDIMScheduler`], [`LMSDiscreteScheduler`], or [`PNDMScheduler`].
      vocoder ([`~transformers.SpeechT5HifiGan`]):
          Vocoder of class `SpeechT5HifiGan` to convert the mel-spectrogram latents to the final audio waveform.
class_docstr_tok: ["Pipeline","for","text-to-audio","generation","using","AudioLDM2",".","This","model","inherits","from","[","`","DiffusionPipeline","`","]",".","Check","the","superclass","documentation","for","the","generic","methods","implemented","for","all","pipelines","(","downloading",",","saving",",","running","on","a","particular","device",",","etc.",")",".","Args",":","vae","(","[","`","AutoencoderKL","`","]",")",":","Variational","Auto-Encoder","(","VAE",")","model","to","encode","and","decode","images","to","and","from","latent","representations",".","text_encoder","(","[","`","~transformers.ClapModel","`","]",")",":","First","frozen","text-encoder",".","AudioLDM2","uses","the","joint","audio-text","embedding","model","[","CLAP","]","(","https",":","\/\/huggingface.co\/docs\/transformers\/model_doc\/clap","#","transformers.CLAPTextModelWithProjection",")",",","specifically","the","[","laion\/clap-htsat-unfused","]","(","https",":","\/\/huggingface.co\/laion\/clap-htsat-unfused",")","variant",".","The","text","branch","is","used","to","encode","the","text","prompt","to","a","prompt","embedding",".","The","full","audio-text","model","is","used","to","rank","generated","waveforms","against","the","text","prompt","by","computing","similarity","scores",".","text_encoder_2","(","[","`","~transformers.T5EncoderModel","`","]",")",":","Second","frozen","text-encoder",".","AudioLDM2","uses","the","encoder","of","[","T5","]","(","https",":","\/\/huggingface.co\/docs\/transformers\/model_doc\/t5","#","transformers.T5EncoderModel",")",",","specifically","the","[","google\/flan-t5-large","]","(","https",":","\/\/huggingface.co\/google\/flan-t5-large",")","variant",".","projection_model","(","[","`","AudioLDM2ProjectionModel","`","]",")",":","A","trained","model","used","to","linearly","project","the","hidden-states","from","the","first","and","second","text","encoder","models","and","insert","learned","SOS","and","EOS","token","embeddings",".","The","projected","hidden-states","from","the","two","text","encoders","are","concatenated","to","give","the","input","to","the","language","model",".","language_model","(","[","`","~transformers.GPT2Model","`","]",")",":","An","auto-regressive","language","model","used","to","generate","a","sequence","of","hidden-states","conditioned","on","the","projected","outputs","from","the","two","text","encoders",".","tokenizer","(","[","`","~transformers.RobertaTokenizer","`","]",")",":","Tokenizer","to","tokenize","text","for","the","first","frozen","text-encoder",".","tokenizer_2","(","[","`","~transformers.T5Tokenizer","`","]",")",":","Tokenizer","to","tokenize","text","for","the","second","frozen","text-encoder",".","feature_extractor","(","[","`","~transformers.ClapFeatureExtractor","`","]",")",":","Feature","extractor","to","pre-process","generated","audio","waveforms","to","log-mel","spectrograms","for","automatic","scoring",".","unet","(","[","`","UNet2DConditionModel","`","]",")",":","A","`","UNet2DConditionModel","`","to","denoise","the","encoded","audio","latents",".","scheduler","(","[","`","SchedulerMixin","`","]",")",":","A","scheduler","to","be","used","in","combination","with","`","unet","`","to","denoise","the","encoded","audio","latents",".","Can","be","one","of","[","`","DDIMScheduler","`","]",",","[","`","LMSDiscreteScheduler","`","]",",","or","[","`","PNDMScheduler","`","]",".","vocoder","(","[","`","~transformers.SpeechT5HifiGan","`","]",")",":","Vocoder","of","class","`","SpeechT5HifiGan","`","to","convert","the","mel-spectrogram","latents","to","the","final","audio","waveform","."]
code: def prepare_extra_step_kwargs(self, generator, eta):
      # prepare extra kwargs for the scheduler step, since not all schedulers have the same signature
      # eta (η) is only used with the DDIMScheduler, it will be ignored for other schedulers.
      # eta corresponds to η in DDIM paper: https://arxiv.org/abs/2010.02502
      # and should be between [0, 1]
  
      accepts_eta = "eta" in set(
          inspect.signature(self.scheduler.step).parameters.keys()
      )
      extra_step_kwargs = {}
      if accepts_eta:
          extra_step_kwargs["eta"] = eta
  
      # check if the scheduler accepts generator
      accepts_generator = "generator" in set(
          inspect.signature(self.scheduler.step).parameters.keys()
      )
      if accepts_generator:
          extra_step_kwargs["generator"] = generator
      return extra_step_kwargs
  
imports: import inspect
  from typing import Any, Callable, Dict, List, Optional, Union
  import numpy
  import torch
  from transformers import ClapFeatureExtractor, ClapModel, GPT2Model, RobertaTokenizer, RobertaTokenizerFast, SpeechT5HifiGan, T5EncoderModel, T5Tokenizer, T5TokenizerFast
  from ...models import AutoencoderKL
  from ...schedulers import KarrasDiffusionSchedulers
  from ...utils import is_accelerate_available, is_accelerate_version, is_librosa_available, logging, replace_example_docstring
  from ...utils.torch_utils import randn_tensor
  from ..pipeline_utils import AudioPipelineOutput, DiffusionPipeline
  from .modeling_audioldm2 import AudioLDM2ProjectionModel, AudioLDM2UNet2DConditionModel
label_desc: Use image node_id 9 for calling the AudioLDM2Pipeline obj's underlying member method code with example usage: obj.prepare_extra_step_kwargs(generator, eta) and returns: extra_step_kwargs