code: def plot_alignments(
      waveform, emission, tokens, timesteps, sample_rate
  ):
      t = torch.arange(waveform.size(0)) / sample_rate
      ratio = waveform.size(0) / emission.size(1) / sample_rate
  
      chars = []
      words = []
      word_start = None
      for token, timestep in zip(tokens, timesteps * ratio):
          if token == "|":
              if word_start is not None:
                  words.append((word_start, timestep))
              word_start = None
          else:
              chars.append((token, timestep))
              if word_start is None:
                  word_start = timestep
  
      fig, axes = plt.subplots(3, 1)
  
      def _plot(ax, xlim):
          ax.plot(t, waveform)
          for token, timestep in chars:
              ax.annotate(token.upper(), (timestep, 0.5))
          for word_start, word_end in words:
              ax.axvspan(word_start, word_end, alpha=0.1, color="red")
          ax.set_ylim(-0.6, 0.7)
          ax.set_yticks([0])
          ax.grid(True, axis="y")
          ax.set_xlim(xlim)
  
      _plot(axes[0], (0.3, 2.5))
      _plot(axes[1], (2.5, 4.7))
      _plot(axes[2], (4.7, 6.9))
      axes[2].set_xlabel("time (sec)")
      fig.tight_layout()
  
imports: import torch
  import torchaudio
  import time
  from typing import List
  import IPython
  import matplotlib.pyplot
  from torchaudio.models.decoder import ctc_decoder
  from torchaudio.utils import download_asset
  from torchaudio.models.decoder import CTCDecoderLM, CTCDecoderLMState
  from torchaudio.models.decoder import download_pretrained_files
label_desc: Use image node_id 1 for calling a global function with example usage: plot_alignments(waveform, emission, tokens, timesteps, sample_rate) without return types