code: def plot_alignments(
      waveform,
      token_spans,
      emission,
      transcript,
      sample_rate=bundle.sample_rate,
  ):
      ratio = waveform.size(1) / emission.size(1) / sample_rate
  
      fig, axes = plt.subplots(2, 1)
      axes[0].imshow(emission[0].detach().cpu().T, aspect="auto")
      axes[0].set_title("Emission")
      axes[0].set_xticks([])
  
      axes[1].specgram(waveform[0], Fs=sample_rate)
      for t_spans, chars in zip(token_spans, transcript):
          t0, t1 = t_spans[0].start + 0.1, t_spans[-1].end - 0.1
          axes[0].axvspan(
              t0 - 0.5,
              t1 - 0.5,
              facecolor="None",
              hatch="/",
              edgecolor="white",
          )
          axes[1].axvspan(
              ratio * t0,
              ratio * t1,
              facecolor="None",
              hatch="/",
              edgecolor="white",
          )
          axes[1].annotate(
              f"{_score(t_spans):.2f}",
              (ratio * t0, sample_rate * 0.51),
              annotation_clip=False,
          )
  
          for span, char in zip(t_spans, chars):
              t0 = span.start * ratio
              axes[1].annotate(
                  char, (t0, sample_rate * 0.55), annotation_clip=False
              )
  
      axes[1].set_xlabel("time [second]")
      axes[1].set_xlim([0, None])
      fig.tight_layout()
  
file_path: audio/examples/tutorials/ctc_forced_alignment_api_tutorial.py
imports: import torch
  import torchaudio
  import IPython
  import matplotlib.pyplot
  import torchaudio.functional
label_desc: Use image node_id 6 for calling a global function with example usage: plot_alignments(waveform, token_spans, emission, transcript, sample_rate) without return types