code: def merge_ssegs_same_speaker(lol):
      """Merge adjacent sub-segs from the same speaker.
  
      Arguments
      ---------
      lol : list of list
          Each list contains [rec_id, sseg_start, sseg_end, spkr_id].
  
      Returns
      -------
      new_lol : list of list
          new_lol contains adjacent segments merged from the same speaker ID.
  
      Example
      -------
      >>> from speechbrain.processing import diarization as diar
      >>> lol=[['r1', 5.5, 7.0, 's1'],
      ... ['r1', 6.5, 9.0, 's1'],
      ... ['r1', 8.0, 11.0, 's1'],
      ... ['r1', 11.5, 13.0, 's2'],
      ... ['r1', 14.0, 15.0, 's2'],
      ... ['r1', 14.5, 15.0, 's1']]
      >>> diar.merge_ssegs_same_speaker(lol)
      [['r1', 5.5, 11.0, 's1'], ['r1', 11.5, 13.0, 's2'], ['r1', 14.0, 15.0, 's2'], ['r1', 14.5, 15.0, 's1']]
      """
  
      new_lol = []
  
      # Start from the first sub-seg
      sseg = lol[0]
      flag = False
      for i in range(1, len(lol)):
          next_sseg = lol[i]
  
          # IF sub-segments overlap AND has same speaker THEN merge
          if (
              is_overlapped(sseg[2], next_sseg[1])
              and sseg[3] == next_sseg[3]
          ):
              sseg[2] = next_sseg[2]  # just update the end time
              # This is important. For the last sseg, if it is the same speaker the merge
              # Make sure we don't append the last segment once more. Hence, set FLAG=True
              if i == len(lol) - 1:
                  flag = True
                  new_lol.append(sseg)
          else:
              new_lol.append(sseg)
              sseg = next_sseg
  
      # Add last segment only when it was skipped earlier.
      if flag is False:
          new_lol.append(lol[-1])
  
      return new_lol
  
imports: import csv
  import numbers
  import warnings
  import scipy
  import pytest
  import numpy
  from scipy import sparse
  from scipy.sparse.linalg import eigsh
  from scipy.sparse.csgraph import connected_components
  from scipy.sparse.csgraph import laplacian
label_desc: Use image node_id 5 for calling a global function with example usage: merge_ssegs_same_speaker(lol) and returns: new_lol