code: def get_trellis(emission, tokens, blank_id=0):
      num_frame = emission.size(0)
      num_tokens = len(tokens)
  
      trellis = torch.zeros((num_frame, num_tokens))
      trellis[1:, 0] = torch.cumsum(emission[1:, blank_id], 0)
      trellis[0, 1:] = -float("inf")
      trellis[-num_tokens + 1 :, 0] = float("inf")
  
      for t in range(num_frame - 1):
          trellis[t + 1, 1:] = torch.maximum(
              # Score for staying at the same token
              trellis[t, 1:] + emission[t, blank_id],
              # Score for changing to the next token
              trellis[t, :-1] + emission[t, tokens[1:]],
          )
      return trellis
  
file_path: audio/examples/tutorials/forced_alignment_tutorial.py
imports: import torch
  import torchaudio
  from dataclasses import dataclass
  import IPython
  import matplotlib.pyplot
label_desc: Use image node_id 2 for calling a global function with example usage: get_trellis(emission, tokens, blank_id) and returns: trellis