class_docstr: Dataset class that loads a json file containing paths to audio files,
  RTTM files and number of speakers. This Dataset class is designed for
  training or fine-tuning speaker embedding extractor and diarization decoder
  at the same time.
  
  Example:
  {"audio_filepath": "/path/to/audio_0.wav", "num_speakers": 2,
  "rttm_filepath": "/path/to/diar_label_0.rttm}
  ...
  {"audio_filepath": "/path/to/audio_n.wav", "num_speakers": 2,
  "rttm_filepath": "/path/to/diar_label_n.rttm}
  
  Args:
      manifest_filepath (str):
          Path to input manifest json files.
      multiscale_args_dict (dict):
          Dictionary containing the parameters for multiscale segmentation and clustering.
      emb_dir (str):
          Path to a temporary folder where segmentation information for embedding extraction is saved.
      soft_label_thres (float):
          Threshold that determines the label of each segment based on RTTM file information.
      featurizer:
          Featurizer instance for generating features from the raw waveform.
      window_stride (float):
          Window stride for acoustic feature. This value is used for calculating the numbers of feature-level frames.
      emb_batch_size (int):
          Number of embedding vectors that are trained with attached computational graphs.
      pairwise_infer (bool):
          This variable should be True if dataloader is created for an inference task.
      random_flip (bool):
          If True, the two labels and input signals are randomly flipped per every epoch while training.
docstr: Generate target tensor variable by extracting groundtruth diarization labels from an RTTM file.
  This function converts (start, end, speaker_id) format into base-scale (the finest scale) segment level
  diarization label in a matrix form.
  
  Example of seg_target:
      [[0., 1.], [0., 1.], [1., 1.], [1., 0.], [1., 0.], ..., [0., 1.]]
  
  Args:
      sample:
          `DiarizationSpeechLabel` instance containing sample information such as audio filepath and RTTM filepath.
      target_spks (tuple):
          Speaker indices that are generated from combinations. If there are only one or two speakers,
          only a single target_spks tuple is generated.
  
  Returns:
      clus_label_index (torch.tensor):
          Groundtruth clustering label (cluster index for each segment) from RTTM files for training purpose.
      seg_target  (torch.tensor):
          Tensor variable containing hard-labels of speaker activity in each base-scale segment.
      scale_mapping (torch.tensor):
          Matrix containing the segment indices of each scale. scale_mapping is necessary for reshaping the
          multiscale embeddings to form an input matrix for the MSDD model.
docstr_tok: ["Generate","target","tensor","variable","by","extracting","groundtruth","diarization","labels","from","an","RTTM","file",".","This","function","converts","(","start",",","end",",","speaker_id",")","format","into","base-scale","(","the","finest","scale",")","segment","level","diarization","label","in","a","matrix","form",".","Example","of","seg_target",":","[","[","0.",",","1",".","]",",","[","0.",",","1",".","]",",","[","1.",",","1",".","]",",","[","1.",",","0",".","]",",","[","1.",",","0",".","]",",","...",",","[","0.",",","1",".","]","]","Args",":","sample",":","`","DiarizationSpeechLabel","`","instance","containing","sample","information","such","as","audio","filepath","and","RTTM","filepath",".","target_spks","(","tuple",")",":","Speaker","indices","that","are","generated","from","combinations",".","If","there","are","only","one","or","two","speakers",",","only","a","single","target_spks","tuple","is","generated",".","Returns",":","clus_label_index","(","torch.tensor",")",":","Groundtruth","clustering","label","(","cluster","index","for","each","segment",")","from","RTTM","files","for","training","purpose",".","seg_target","(","torch.tensor",")",":","Tensor","variable","containing","hard-labels","of","speaker","activity","in","each","base-scale","segment",".","scale_mapping","(","torch.tensor",")",":","Matrix","containing","the","segment","indices","of","each","scale",".","scale_mapping","is","necessary","for","reshaping","the","multiscale","embeddings","to","form","an","input","matrix","for","the","MSDD","model","."]
code: def parse_rttm_for_ms_targets(self, sample):
      """
      Generate target tensor variable by extracting groundtruth diarization labels from an RTTM file.
      This function converts (start, end, speaker_id) format into base-scale (the finest scale) segment level
      diarization label in a matrix form.
  
      Example of seg_target:
          [[0., 1.], [0., 1.], [1., 1.], [1., 0.], [1., 0.], ..., [0., 1.]]
  
      Args:
          sample:
              `DiarizationSpeechLabel` instance containing sample information such as audio filepath and RTTM filepath.
          target_spks (tuple):
              Speaker indices that are generated from combinations. If there are only one or two speakers,
              only a single target_spks tuple is generated.
  
      Returns:
          clus_label_index (torch.tensor):
              Groundtruth clustering label (cluster index for each segment) from RTTM files for training purpose.
          seg_target  (torch.tensor):
              Tensor variable containing hard-labels of speaker activity in each base-scale segment.
          scale_mapping (torch.tensor):
              Matrix containing the segment indices of each scale. scale_mapping is necessary for reshaping the
              multiscale embeddings to form an input matrix for the MSDD model.
  
      """
      rttm_lines = open(sample.rttm_file).readlines()
      uniq_id = self.get_uniq_id_with_range(sample)
      rttm_timestamps = extract_seg_info_from_rttm(uniq_id, rttm_lines)
      fr_level_target = assign_frame_level_spk_vector(
          rttm_timestamps,
          self.round_digits,
          self.frame_per_sec,
          target_spks=sample.target_spks,
      )
      seg_target, base_clus_label = self.get_diar_target_labels(
          uniq_id, sample, fr_level_target
      )
      (
          clus_label_index,
          scale_mapping,
      ) = self.assign_labels_to_longer_segs(uniq_id, base_clus_label)
      return clus_label_index, seg_target, scale_mapping
  
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 6 for calling the _AudioMSDDTrainDataset obj's underlying member method code with example usage: obj.parse_rttm_for_ms_targets(sample) and returns: clus_label_index,  seg_target,  scale_mapping