code: def audio_rttm_map(manifest, attach_dur=False):
      """
      This function creates AUDIO_RTTM_MAP which is used by all diarization components to extract embeddings,
      cluster and unify time stamps
      Args: manifest file that contains keys audio_filepath, rttm_filepath if exists, text, num_speakers if known and uem_filepath if exists
  
      returns:
      AUDIO_RTTM_MAP (dict) : A dictionary with keys of uniq id, which is being used to map audio files and corresponding rttm files
      """
  
      AUDIO_RTTM_MAP = {}
      with open(manifest, "r") as inp_file:
          lines = inp_file.readlines()
          logging.info(
              "Number of files to diarize: {}".format(len(lines))
          )
          for line in lines:
              line = line.strip()
              dic = json.loads(line)
  
              meta = {
                  "audio_filepath": dic["audio_filepath"],
                  "rttm_filepath": dic.get("rttm_filepath", None),
                  "offset": dic.get("offset", None),
                  "duration": dic.get("duration", None),
                  "text": dic.get("text", None),
                  "num_speakers": dic.get("num_speakers", None),
                  "uem_filepath": dic.get("uem_filepath", None),
                  "ctm_filepath": dic.get("ctm_filepath", None),
              }
              if attach_dur:
                  uniqname = get_uniq_id_with_dur(meta)
              else:
                  uniqname = get_uniqname_from_filepath(
                      filepath=meta["audio_filepath"]
                  )
  
              if uniqname not in AUDIO_RTTM_MAP:
                  AUDIO_RTTM_MAP[uniqname] = meta
              else:
                  raise KeyError(
                      "file {} is already part of AUDIO_RTTM_MAP, it might be duplicated, Note: file basename must be unique".format(
                          meta["audio_filepath"]
                      )
                  )
  
      return AUDIO_RTTM_MAP
  
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 4 for calling a global function with example usage: audio_rttm_map(manifest, attach_dur) and returns: AUDIO_RTTM_MAP