class_docstr: Dataset class that loads a json file containing paths to audio files,
  RTTM files and number of speakers. This Dataset class is built for diarization inference and
  evaluation. Speaker embedding sequences, segment timestamps, cluster-average speaker embeddings
  are loaded from memory and fed into the dataloader.
  
  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.
      emb_dict (dict):
          Dictionary containing cluster-average embeddings and speaker mapping information.
      emb_seq (dict):
          Dictionary containing multiscale speaker embedding sequence, scale mapping and corresponding segment timestamps.
      clus_label_dict (dict):
          Subsegment-level (from base-scale) speaker labels from clustering results.
      soft_label_thres (float):
          A threshold that determines the label of each segment based on RTTM file information.
      featurizer:
          Featurizer instance for generating features from raw waveform.
      seq_eval_mode (bool):
          If True, F1 score will be calculated for each speaker pair during inference mode.
      window_stride (float):
          Window stride for acoustic feature. This value is used for calculating the numbers of feature-level frames.
      use_single_scale_clus (bool):
          Use only one scale for clustering instead of using multiple scales of embeddings for clustering.
      pairwise_infer (bool):
          This variable should be True if dataloader is created for an inference task.
docstr: Generate base-scale level binary diarization label from frame-level target matrix. For the given frame-level
  speaker target matrix fr_level_target, we count the number of frames that belong to each speaker and calculate
  ratios for each speaker into the `soft_label_vec` variable. Finally, `soft_label_vec` variable is compared with `soft_label_thres`
  to determine whether a label vector should contain 0 or 1 for each speaker bin. Note that seg_target variable has
  dimension of (number of base-scale segments x 2) dimension.
  
  Example of seg_target:
      [[0., 1.], [0., 1.], [1., 1.], [1., 0.], [1., 0.], ..., [0., 1.]]
  
  Args:
      uniq_id (str):
          Unique file ID that refers to an input audio file and corresponding RTTM (Annotation) file.
      fr_level_target (torch.tensor):
          frame-level binary speaker annotation (1: exist 0: non-exist) generated from RTTM file.
  
  Returns:
      seg_target (torch.tensor):
          Tensor variable containing binary hard-labels of speaker activity in each base-scale segment.
docstr_tok: ["Generate","base-scale","level","binary","diarization","label","from","frame-level","target","matrix",".","For","the","given","frame-level","speaker","target","matrix","fr_level_target",",","we","count","the","number","of","frames","that","belong","to","each","speaker","and","calculate","ratios","for","each","speaker","into","the","`","soft_label_vec","`","variable",".","Finally",",","`","soft_label_vec","`","variable","is","compared","with","`","soft_label_thres","`","to","determine","whether","a","label","vector","should","contain","0","or","1","for","each","speaker","bin",".","Note","that","seg_target","variable","has","dimension","of","(","number","of","base-scale","segments","x","2",")","dimension",".","Example","of","seg_target",":","[","[","0.",",","1",".","]",",","[","0.",",","1",".","]",",","[","1.",",","1",".","]",",","[","1.",",","0",".","]",",","[","1.",",","0",".","]",",","...",",","[","0.",",","1",".","]","]","Args",":","uniq_id","(","str",")",":","Unique","file","ID","that","refers","to","an","input","audio","file","and","corresponding","RTTM","(","Annotation",")","file",".","fr_level_target","(","torch.tensor",")",":","frame-level","binary","speaker","annotation","(","1",":","exist","0",":","non-exist",")","generated","from","RTTM","file",".","Returns",":","seg_target","(","torch.tensor",")",":","Tensor","variable","containing","binary","hard-labels","of","speaker","activity","in","each","base-scale","segment","."]
code: def get_diar_target_labels_from_fr_target(
      self, uniq_id, fr_level_target
  ):
      """
      Generate base-scale level binary diarization label from frame-level target matrix. For the given frame-level
      speaker target matrix fr_level_target, we count the number of frames that belong to each speaker and calculate
      ratios for each speaker into the `soft_label_vec` variable. Finally, `soft_label_vec` variable is compared with `soft_label_thres`
      to determine whether a label vector should contain 0 or 1 for each speaker bin. Note that seg_target variable has
      dimension of (number of base-scale segments x 2) dimension.
  
      Example of seg_target:
          [[0., 1.], [0., 1.], [1., 1.], [1., 0.], [1., 0.], ..., [0., 1.]]
  
      Args:
          uniq_id (str):
              Unique file ID that refers to an input audio file and corresponding RTTM (Annotation) file.
          fr_level_target (torch.tensor):
              frame-level binary speaker annotation (1: exist 0: non-exist) generated from RTTM file.
  
      Returns:
          seg_target (torch.tensor):
              Tensor variable containing binary hard-labels of speaker activity in each base-scale segment.
  
      """
      if fr_level_target is None:
          return None
      else:
          seg_target_list = []
          for seg_stt, seg_end, label_int in self.clus_label_dict[
              uniq_id
          ]:
              seg_stt_fr, seg_end_fr = int(
                  seg_stt * self.frame_per_sec
              ), int(seg_end * self.frame_per_sec)
              soft_label_vec = torch.sum(
                  fr_level_target[seg_stt_fr:seg_end_fr, :], axis=0
              ) / (seg_end_fr - seg_stt_fr)
              label_vec = (soft_label_vec > self.soft_label_thres).int()
              seg_target_list.append(label_vec)
          seg_target = torch.stack(seg_target_list)
          return seg_target
  
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 5 for calling the _AudioMSDDInferDataset obj's underlying member method code with example usage: obj.get_diar_target_labels_from_fr_target(uniq_id, fr_level_target) and returns: None, seg_target