code: def extract_seg_info_from_rttm(
      uniq_id, rttm_lines, mapping_dict=None, target_spks=None
  ):
      """
      Get RTTM lines containing speaker labels, start time and end time. target_spks contains two targeted
      speaker indices for creating groundtruth label files. Only speakers in target_spks variable will be
      included in the output lists.
  
      Args:
          uniq_id (str):
              Unique file ID that refers to an input audio file and corresponding RTTM (Annotation) file.
          rttm_lines (list):
              List containing RTTM lines in str format.
          mapping_dict (dict):
              Mapping between the estimated speakers and the speakers in the ground-truth annotation.
              `mapping_dict` variable is only provided when the inference mode is running in sequence-eval mode.
              Sequence eval mode uses the mapping between the estimated speakers and the speakers in ground-truth annotation.
      Returns:
          rttm_tup (tuple):
              Tuple containing lists of start time, end time and speaker labels.
  
      """
      stt_list, end_list, speaker_list, pairwise_infer_spks = (
          [],
          [],
          [],
          [],
      )
      if target_spks:
          inv_map = {v: k for k, v in mapping_dict.items()}
          for spk_idx in target_spks:
              spk_str = f"speaker_{spk_idx}"
              if spk_str in inv_map:
                  pairwise_infer_spks.append(inv_map[spk_str])
      for rttm_line in rttm_lines:
          start, end, speaker = convert_rttm_line(rttm_line)
          if target_spks is None or speaker in pairwise_infer_spks:
              end_list.append(end)
              stt_list.append(start)
              speaker_list.append(speaker)
      rttm_tup = (stt_list, end_list, speaker_list)
      return rttm_tup
  
imports: import os
  from collections import OrderedDict
  from statistics import mode
  from typing import Dict, Optional
  import torch
  from nemo.collections.asr.parts.utils.offline_clustering import get_argmin_mat
  from nemo.collections.asr.parts.utils.speaker_utils import convert_rttm_line, prepare_split_data
  from nemo.collections.common.parts.preprocessing.collections import DiarizationSpeechLabel
  from nemo.core.classes import Dataset
  from nemo.core.neural_types import AudioSignal, EncodedRepresentation, LengthsType, NeuralType, ProbsType
label_desc: Use image node_id 2 for calling a global function with example usage: extract_seg_info_from_rttm(uniq_id, rttm_lines, mapping_dict, target_spks) and returns: rttm_tup