code: def main():
      args = get_args()
      manifest_path = args.manifest_path
      sup_data_path = args.sup_data_path
      pitch_stats_path = args.pitch_stats_path
  
      pitch_data_path = Path(os.path.join(sup_data_path, Pitch.name))
      if not os.path.exists(pitch_data_path):
          raise ValueError(
              f"Pitch directory {pitch_data_path} does not exist. Make sure 'sup_data_path' is correct "
              f"and that you have computed the pitch using extract_sup_data.py"
          )
  
      entries = read_manifest(manifest_path)
  
      audio_paths = [entry["audio_filepath"] for entry in entries]
      base_dir = get_base_dir(audio_paths)
  
      global_pitch_values = []
      speaker_pitch_values = defaultdict(list)
      for entry in tqdm(entries):
          pitch_path = _get_sup_data_filepath(
              manifest_entry=entry,
              audio_dir=base_dir,
              sup_data_dir=pitch_data_path,
          )
          if not os.path.exists(pitch_path):
              logging.warning(f"Unable to find pitch file for {entry}")
              continue
  
          pitch = torch.load(pitch_path)
          # Filter out non-speech frames
          pitch = pitch[pitch != 0]
          global_pitch_values.append(pitch)
          if "speaker" in entry:
              speaker_id = entry["speaker"]
              speaker_pitch_values[speaker_id].append(pitch)
  
      global_pitch_mean, global_pitch_std = _compute_stats(
          global_pitch_values
      )
      pitch_stats = {
          "default": {
              "pitch_mean": global_pitch_mean,
              "pitch_std": global_pitch_std,
          }
      }
      for speaker_id, pitch_values in speaker_pitch_values.items():
          pitch_mean, pitch_std = _compute_stats(pitch_values)
          pitch_stats[speaker_id] = {
              "pitch_mean": pitch_mean,
              "pitch_std": pitch_std,
          }
  
      with open(pitch_stats_path, "w", encoding="utf-8") as stats_f:
          json.dump(pitch_stats, stats_f, indent=4)
  
file_path: NeMo/scripts/dataset_processing/tts/compute_speaker_stats.py
imports: import argparse
  import json
  import os
  from collections import defaultdict
  from pathlib import Path
  from typing import List, Tuple
  import torch
  from tqdm import tqdm
  from nemo.collections.asr.parts.utils.manifest_utils import read_manifest
  from nemo.collections.tts.parts.utils.tts_dataset_utils import get_base_dir
  from nemo.collections.tts.torch.tts_data_types import Pitch
  from nemo.utils import logging
label_desc: Use image node_id 4 for calling a global function with example usage: main() without return types