code: def _spectrogram_to_mel_matrix(
      num_mel_bins=20,
      num_spectrogram_bins=129,
      audio_sample_rate=8000,
      lower_edge_hertz=125.0,
      upper_edge_hertz=3800.0,
  ):
      nyquist_hertz = audio_sample_rate / 2.0
      if lower_edge_hertz < 0.0:
          raise ValueError(
              "lower_edge_hertz %.1f must be >= 0" % lower_edge_hertz
          )
      if lower_edge_hertz >= upper_edge_hertz:
          raise ValueError(
              "lower_edge_hertz %.1f >= upper_edge_hertz %.1f"
              % (lower_edge_hertz, upper_edge_hertz)
          )
  
      if upper_edge_hertz > nyquist_hertz:
          raise ValueError(
              "upper_edge_hertz %.1f is greater than Nyquist %.1f"
              % (upper_edge_hertz, nyquist_hertz)
          )
      spectrogram_bins_hertz = torch.linspace(
          0.0, nyquist_hertz, num_spectrogram_bins
      )
  
      spectrogram_bins_mel = _hertz_to_mel(spectrogram_bins_hertz)
      # The i'th mel band (starting from i=1) has center frequency
      # band_edges_mel[i], lower edge band_edges_mel[i-1], and higher edge
      # band_edges_mel[i+1].  Thus, we need num_mel_bins + 2 values in
      # the band_edges_mel arrays.
      band_edges_mel = torch.linspace(
          _hertz_to_mel(torch.tensor(lower_edge_hertz)),
          _hertz_to_mel(torch.tensor(upper_edge_hertz)),
          num_mel_bins + 2,
      )
      # Matrix to post-multiply feature arrays whose rows are num_spectrogram_bins
      # of spectrogram values.
      mel_weights_matrix = torch.empty(
          (num_spectrogram_bins, num_mel_bins)
      )
      for i in range(num_mel_bins):
          lower_edge_mel, center_mel, upper_edge_mel = band_edges_mel[
              i : i + 3
          ]
          # Calculate lower and upper slopes for every spectrogram bin.
          # Line segments are linear in the *mel* domain, not hertz.
          lower_slope = (spectrogram_bins_mel - lower_edge_mel) / (
              center_mel - lower_edge_mel
          )
          upper_slope = (upper_edge_mel - spectrogram_bins_mel) / (
              upper_edge_mel - center_mel
          )
  
          # .. then intersect them with each other and zero.
          mel_weights_matrix[:, i] = torch.maximum(
              torch.tensor(0.0), torch.minimum(lower_slope, upper_slope)
          )
  
      # HTK excludes the spectrogram DC bin; make sure it always gets a zero
      # coefficient.
      mel_weights_matrix[0, :] = 0.0
      return mel_weights_matrix
  
file_path: audio/src/torchaudio/prototype/pipelines/_vggish/_vggish_impl.py
imports: import math
  import torch
label_desc: Use image node_id 6 for calling a global function with example usage: _spectrogram_to_mel_matrix(num_mel_bins, num_spectrogram_bins, audio_sample_rate, lower_edge_hertz, upper_edge_hertz) and returns: mel_weights_matrix