code: def generate_speaker_timestamps(
      clus_labels: List[Union[float, int]],
      msdd_preds: List[torch.Tensor],
      **params,
  ) -> Tuple[List[str], List[str]]:
      """
      Generate speaker timestamps from the segmentation information. If `use_clus_as_main=True`, use clustering result for main speaker
      labels and use timestamps from the predicted sigmoid values. In this function, the main speaker labels in `maj_labels` exist for
      every subsegment steps while overlap speaker labels in `ovl_labels` only exist for segments where overlap-speech is occuring.
  
      Args:
          clus_labels (list):
              List containing integer-valued speaker clustering results.
          msdd_preds (list):
              List containing tensors of the predicted sigmoid values.
              Each tensor has shape of: (Session length, estimated number of speakers).
          params:
              Parameters for generating RTTM output and evaluation. Parameters include:
                  infer_overlap (bool): If False, overlap-speech will not be detected.
                  use_clus_as_main (bool): Add overlap-speech detection from MSDD to clustering results. If False, only MSDD output
                                           is used for constructing output RTTM files.
                  overlap_infer_spk_limit (int): Above this limit, overlap-speech detection is bypassed.
                  use_adaptive_thres (bool): Boolean that determines whehther to use adaptive_threshold depending on the estimated
                                             number of speakers.
                  max_overlap_spks (int): Maximum number of overlap speakers detected. Default is 2.
                  threshold (float): Sigmoid threshold for MSDD output.
  
      Returns:
          maj_labels (list):
              List containing string-formated single-speaker speech segment timestamps and corresponding speaker labels.
              Example: [..., '551.685 552.77 speaker_1', '552.99 554.43 speaker_0', '554.97 558.19 speaker_0', ...]
          ovl_labels (list):
              List containing string-formated additional overlapping speech segment timestamps and corresponding speaker labels.
              Note that `ovl_labels` includes only overlapping speech that is not included in `maj_labels`.
              Example: [..., '152.495 152.745 speaker_1', '372.71 373.085 speaker_0', '554.97 555.885 speaker_1', ...]
      """
      msdd_preds.squeeze(0)
      estimated_num_of_spks = msdd_preds.shape[-1]
      overlap_speaker_list = [[] for _ in range(estimated_num_of_spks)]
      infer_overlap = estimated_num_of_spks < int(
          params["overlap_infer_spk_limit"]
      )
      main_speaker_lines = []
      if params["use_adaptive_thres"]:
          threshold = get_adaptive_threshold(
              estimated_num_of_spks,
              params["threshold"],
              params["overlap_infer_spk_limit"],
          )
      else:
          threshold = params["threshold"]
      for seg_idx, cluster_label in enumerate(clus_labels):
          msdd_preds.squeeze(0)
          spk_for_seg = (
              (msdd_preds[0, seg_idx] > threshold)
              .int()
              .cpu()
              .numpy()
              .tolist()
          )
          sm_for_seg = msdd_preds[0, seg_idx].cpu().numpy()
  
          if params["use_clus_as_main"]:
              main_spk_idx = int(cluster_label[2])
          else:
              main_spk_idx = np.argsort(
                  msdd_preds[0, seg_idx].cpu().numpy()
              )[::-1][0]
  
          if sum(spk_for_seg) > 1 and infer_overlap:
              idx_arr = np.argsort(sm_for_seg)[::-1]
              for ovl_spk_idx in idx_arr[
                  : params["max_overlap_spks"]
              ].tolist():
                  if ovl_spk_idx != int(main_spk_idx):
                      overlap_speaker_list[ovl_spk_idx].append(seg_idx)
          main_speaker_lines.append(
              f"{cluster_label[0]} {cluster_label[1]} speaker_{main_spk_idx}"
          )
      cont_stamps = get_contiguous_stamps(main_speaker_lines)
      maj_labels = merge_stamps(cont_stamps)
      ovl_labels = get_overlap_stamps(cont_stamps, overlap_speaker_list)
      return maj_labels, ovl_labels
  
imports: import gc
  import json
  import math
  import os
  import shutil
  from copy import deepcopy
  from typing import Dict, List, Tuple, Union
  import numpy
  import omegaconf
  import soundfile
  import torch
  from pyannote.core import Annotation, Segment
  from tqdm import tqdm
  from nemo.collections.asr.data.audio_to_label import repeat_signal
  from nemo.collections.asr.parts.utils.longform_clustering import LongFormSpeakerClustering
  from nemo.collections.asr.parts.utils.offline_clustering import SpeakerClustering, get_argmin_mat, split_input_data
  from nemo.utils import logging
label_desc: Use image node_id 43 for calling a global function with example usage: generate_speaker_timestamps(clus_labels, msdd_preds) and returns: maj_labels,  ovl_labels