code: def run_multispeaker_data_analysis(
      input_dir,
      session_dur=None,
      silence_mean=None,
      silence_var=None,
      overlap_mean=None,
      overlap_var=None,
      precise=False,
      save_path=None,
      num_workers=1,
  ) -> Dict:
      rttm_list = list(Path(input_dir).glob("*.rttm"))
      """
      Analyze the multispeaker data and plot the distribution of silence and overlap durations.
  
      Args:
          input_dir (str): path to the directory containing the rttm files
          session_dur (float): duration of the session (specified by argument)
          silence_mean (float): mean of the silence duration distribution
          silence_var (float): variance of the silence duration distribution
          overlap_mean (float): mean of the overlap duration distribution
          overlap_var (float): variance of the overlap duration distribution
          precise (bool): whether to measure the precise duration of the session using sox
          save_path (str): path to save the plots
  
      Returns:
          stats (dict): dictionary containing the statistics of the analyzed data
      """
  
      print(f"Found {len(rttm_list)} files to be processed")
      if len(rttm_list) == 0:
          raise ValueError(f"No rttm files found in {input_dir}")
  
      silence_duration = 0.0
      total_duration = 0.0
      overlap_duration = 0.0
  
      silence_ratio_all = []
      overlap_ratio_all = []
      silence_length_all = []
      overlap_length_all = []
  
      queue = []
      for rttm_file in tqdm(rttm_list):
          queue.append(
              {
                  "rttm_file": rttm_file,
                  "session_dur": session_dur,
                  "precise": precise,
              }
          )
  
      if num_workers <= 1:
          results = [
              process_sample(sess_dict) for sess_dict in tqdm(queue)
          ]
      else:
          with multiprocessing.Pool(processes=num_workers) as p:
              results = list(
                  tqdm(
                      p.imap(process_sample, queue),
                      total=len(queue),
                      desc="Processing",
                      leave=True,
                  )
              )
  
      for item in results:
          total_duration += item["session_dur"]
          silence_duration += item["silence_dur"]
          overlap_duration += item["overlap_dur"]
  
          silence_length_all += item["silence_len_list"]
          overlap_length_all += item["overlap_len_list"]
  
          silence_ratio_all.append(item["silence_ratio"])
          overlap_ratio_all.append(item["overlap_ratio"])
  
      actual_silence_mean = silence_duration / total_duration
      actual_silence_var = np.var(silence_ratio_all)
      actual_overlap_mean = overlap_duration / (
          total_duration - silence_duration
      )
      actual_overlap_var = np.var(overlap_ratio_all)
  
      stats = OrderedDict()
      stats["total duration (hours)"] = f"{total_duration / 3600:.2f}"
      stats["number of sessions"] = len(rttm_list)
      stats[
          "average session duration (seconds)"
      ] = f"{total_duration / len(rttm_list):.2f}"
      stats[
          "actual silence ratio mean/var"
      ] = f"{actual_silence_mean:.4f}/{actual_silence_var:.4f}"
      stats[
          "actual overlap ratio mean/var"
      ] = f"{actual_overlap_mean:.4f}/{actual_overlap_var:.4f}"
      stats[
          "expected silence ratio mean/var"
      ] = f"{silence_mean}/{silence_var}"
      stats[
          "expected overlap ratio mean/var"
      ] = f"{overlap_mean}/{overlap_var}"
      stats["save_path"] = save_path
  
      print("-----------------------------------------------")
      print("                    Results                    ")
      print("-----------------------------------------------")
      for k, v in stats.items():
          print(k, ": ", v)
      print("-----------------------------------------------")
  
      fig, ((ax1, ax2), (ax3, ax4)) = plt.subplots(
          2, 2, figsize=(14, 14)
      )
      fig.suptitle(
          f"Average session={total_duration/len(rttm_list):.2f} seconds, num sessions={len(rttm_list)}, total={total_duration/3600:.2f} hours"
      )
      sns.histplot(silence_ratio_all, ax=ax1)
      ax1.set_xlabel("Silence ratio in a session")
      ax1.set_title(
          f"Target silence mean={silence_mean}, var={silence_var}. \nActual silence ratio={actual_silence_mean:.4f}, var={actual_silence_var:.4f}"
      )
  
      _, scale = expon.fit(silence_length_all, floc=0)
      sns.histplot(silence_length_all, ax=ax2)
      ax2.set_xlabel("Per-silence length in seconds")
      ax2.set_title(
          f"Per-silence length histogram, \nfitted exponential distribution with mean={scale:.4f}"
      )
  
      sns.histplot(overlap_ratio_all, ax=ax3)
      ax3.set_title(
          f"Target overlap mean={overlap_mean}, var={overlap_var}. \nActual ratio={actual_overlap_mean:.4f}, var={actual_overlap_var:.4f}"
      )
      ax3.set_xlabel("Overlap ratio in a session")
      _, scale2 = expon.fit(overlap_length_all, floc=0)
      sns.histplot(overlap_length_all, ax=ax4)
      ax4.set_title(
          f"Per overlap length histogram, \nfitted exponential distribution with mean={scale2:.4f}"
      )
      ax4.set_xlabel("Duration in seconds")
  
      if save_path:
          fig.savefig(save_path)
          print(f"Figure saved at: {save_path}")
  
      return stats
  
file_path: NeMo/scripts/speaker_tasks/multispeaker_data_analysis.py
imports: import argparse
  import multiprocessing
  import shutil
  from collections import OrderedDict
  from pathlib import Path
  from pprint import pprint
  from typing import Dict
  import matplotlib.pyplot
  import numpy
  import seaborn
  import sox
  from scipy.stats import expon
  from tqdm import tqdm
  from nemo.collections.asr.parts.utils.vad_utils import get_nonspeech_segments, load_speech_overlap_segments_from_rttm, plot_sample_from_rttm
label_desc: Use image node_id 2 for calling a global function with example usage: run_multispeaker_data_analysis(input_dir, session_dur, silence_mean, silence_var, overlap_mean, overlap_var, precise, save_path, num_workers) and returns: stats