code: def get_global_cmvn(
      feature_root: Path, output_path: Optional[Path] = None
  ):
      mean_x, mean_x2, n_frames = None, None, 0
      feature_paths = feature_root.glob("*.npy")
      for p in tqdm(feature_paths):
          with open(p, "rb") as f:
              frames = np.load(f).squeeze()
  
          n_frames += frames.shape[0]
  
          cur_mean_x = frames.sum(axis=0)
          if mean_x is None:
              mean_x = cur_mean_x
          else:
              mean_x += cur_mean_x
  
          cur_mean_x2 = (frames**2).sum(axis=0)
          if mean_x2 is None:
              mean_x2 = cur_mean_x2
          else:
              mean_x2 += cur_mean_x2
  
      mean_x /= n_frames
      mean_x2 /= n_frames
      var_x = mean_x2 - mean_x**2
      std_x = np.sqrt(np.maximum(var_x, 1e-10))
  
      if output_path is not None:
          with open(output_path, "wb") as f:
              np.savez(f, mean=mean_x, std=std_x)
      else:
          return {"mean": mean_x, "std": std_x}
  
imports: import io
  import os
  from pathlib import Path
  from typing import Optional, List, Dict
  import zipfile
  import tempfile
  from dataclasses import dataclass
  from itertools import groupby
  import torch
  import torch.nn.functional
  import numpy
  from tqdm import tqdm
  from examples.speech_to_text.data_utils import load_tsv_to_dicts
  from fairseq.data.audio.audio_utils import TTSSpectrogram, TTSMelScale, parse_path, read_from_stored_zip, is_npy_data
label_desc: Use image node_id 5 for calling a global function with example usage: get_global_cmvn(feature_root, output_path) and returns: dict