code: def merge_repeats(path):
      i1, i2 = 0, 0
      segments = []
      while i1 < len(path):
          while (
              i2 < len(path)
              and path[i1].token_index == path[i2].token_index
          ):
              i2 += 1
          score = sum(path[k].score for k in range(i1, i2)) / (i2 - i1)
          segments.append(
              Segment(
                  transcript[path[i1].token_index],
                  path[i1].time_index,
                  path[i2 - 1].time_index + 1,
                  score,
              )
          )
          i1 = i2
      return segments
  
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 6 for calling a global function with example usage: merge_repeats(path) and returns: segments