code: def calculate_rms_without_silence(samples, sample_rate):
      """
      This function returns the rms of a given noise whose silent periods have been removed. This ensures
      that the rms of the noise is not underestimated. Is most useful for short non-stationary noises.
      """
  
      window = int(0.025 * sample_rate)
  
      if samples.shape[-1] < window:
          return calculate_rms(samples)
  
      rms_all_windows = np.zeros(samples.shape[-1] // window)
      current_time = 0
  
      while current_time < samples.shape[-1] - window:
          rms_all_windows[current_time // window] += calculate_rms(
              samples[current_time : current_time + window]
          )
          current_time += window
  
      rms_threshold = np.max(rms_all_windows) / 25
  
      # The segments with a too low rms are identified and discarded
      rms_all_windows = rms_all_windows[rms_all_windows > rms_threshold]
      # Beware that each window must have the same number of samples so that this calculation of the rms is valid.
      return calculate_rms(rms_all_windows)
  
file_path: audiomentations/audiomentations/core/utils.py
imports: import os
  from functools import lru_cache
  from pathlib import Path
  from typing import List, Union, Tuple
  import math
  import numpy
  from numpy.typing import NDArray
label_desc: Use image node_id 4 for calling a global function with example usage: calculate_rms_without_silence(samples, sample_rate) and returns: calculate_rms, calculate_rms