code: def merge_rttm_intervals(rttm_segs):
      """Merges adjacent segments in rttm if they overlap."""
      # For one recording
      # rec_id = rttm_segs[0][1]
      rttm_segs.sort(key=lambda x: float(x[3]))
  
      # first_seg = rttm_segs[0] # first interval.. as it is
      merged_segs = [rttm_segs[0]]
      strt = float(rttm_segs[0][3])
      end = float(rttm_segs[0][3]) + float(rttm_segs[0][4])
  
      for row in rttm_segs[1:]:
          s = float(row[3])
          e = float(row[3]) + float(row[4])
  
          if is_overlapped(end, s):
              # Update only end. The strt will be same as in last segment
              # Just update last row in the merged_segs
              end = max(end, e)
              merged_segs[-1][3] = str(round(strt, 4))
              merged_segs[-1][4] = str(round((end - strt), 4))
              merged_segs[-1][
                  7
              ] = "overlap"  # previous_row[7] + '-'+ row[7]
          else:
              # Add a new disjoint segment
              strt = s
              end = e
              merged_segs.append(row)  # this will have 1 spkr ID
  
      return merged_segs
  
file_path: speechbrain/recipes/AMI/ami_prepare.py
imports: import os
  import logging
  import xml.etree.ElementTree
  import glob
  import json
  from ami_splits import get_AMI_split
  from speechbrain.dataio.dataio import load_pkl, save_pkl
label_desc: Use image node_id 5 for calling a global function with example usage: merge_rttm_intervals(rttm_segs) and returns: merged_segs