code: def plot_waveform(magnitudes, filtered, sample_rate):
      nyquist = sample_rate / 2
      num_samples = filtered.size(-1)
      duration = num_samples / sample_rate
  
      # Re-organize magnitudes for overlay
      N = 10  # number of overlays
      interval = torch.linspace(0.05, 0.95, N)
      offsets = duration * interval
      # Select N magnitudes for overlays
      mags = torch.stack(
          [magnitudes for _ in range(N)]
          if magnitudes.ndim == 1
          else [
              magnitudes[int(i * magnitudes.size(0))] for i in interval
          ]
      )
      mag_x = offsets.unsqueeze(-1) + 0.1 * mags
      mag_y = torch.linspace(0, nyquist, magnitudes.size(-1)).tile(
          (N, 1)
      )
  
      _, ax = plt.subplots(1, 1, sharex=True)
      ax.vlines(
          offsets,
          0,
          nyquist,
          color="gray",
          linestyle="--",
          linewidth=0.8,
      )
      ax.plot(
          mag_x.T.numpy(), mag_y.T.numpy(), color="gray", linewidth=0.8
      )
      ax.specgram(filtered, Fs=sample_rate)
      return Audio(filtered, rate=sample_rate)
  
imports: import torch
  import torchaudio
  import matplotlib.pyplot
  from IPython.display import Audio
label_desc: Use image node_id 3 for calling a global function with example usage: plot_waveform(magnitudes, filtered, sample_rate) and returns: Audio