code: def merge_words(segments, separator="|"):
      words = []
      i1, i2 = 0, 0
      while i1 < len(segments):
          if i2 >= len(segments) or segments[i2].label == separator:
              if i1 != i2:
                  segs = segments[i1:i2]
                  word = "".join([seg.label for seg in segs])
                  score = sum(
                      seg.score * seg.length for seg in segs
                  ) / sum(seg.length for seg in segs)
                  words.append(
                      Segment(
                          word,
                          segments[i1].start,
                          segments[i2 - 1].end,
                          score,
                      )
                  )
              i1 = i2 + 1
              i2 = i1
          else:
              i2 += 1
      return words
  
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 8 for calling a global function with example usage: merge_words(segments, separator) and returns: words