class_docstr: Turn a normal STFT into a mel frequency STFT, using a conversion
  matrix.  This uses triangular filter banks.
  User can control which device the filter bank (fb) is (e.g. fb.to(spec_f.device)).
  Args:
      n_mels (int, optional): Number of mel filterbanks. (Default: 128)
      sample_rate (int, optional): Sample rate of audio signal. (Default: 16000)
      f_min (float, optional): Minimum frequency. (Default: 0.)
      f_max (float or None, optional): Maximum frequency.
          (Default: sample_rate // 2)
      n_stft (int, optional): Number of bins in STFT. Calculated from first input
          if None is given.  See n_fft in :class:Spectrogram.
          (Default: None)
class_docstr_tok: ["Turn","a","normal","STFT","into","a","mel","frequency","STFT",",","using","a","conversion","matrix",".","This","uses","triangular","filter","banks",".","User","can","control","which","device","the","filter","bank","(","fb",")","is","(","e.g",".","fb.to","(","spec_f.device",")",")",".","Args",":","n_mels","(","int",",","optional",")",":","Number","of","mel","filterbanks",".","(","Default",":","128",")","sample_rate","(","int",",","optional",")",":","Sample","rate","of","audio","signal",".","(","Default",":","16000",")","f_min","(","float",",","optional",")",":","Minimum","frequency",".","(","Default",":","0",".",")","f_max","(","float","or","None",",","optional",")",":","Maximum","frequency",".","(","Default",":","sample_rate","\/\/","2",")","n_stft","(","int",",","optional",")",":","Number","of","bins","in","STFT",".","Calculated","from","first","input","if","None","is","given",".","See","n_fft","in",":","class",":","Spectrogram",".","(","Default",":","None",")"]
docstr: Args:
      specgram (Tensor): A spectrogram STFT of dimension (..., freq, time).
  Returns:
      Tensor: Mel frequency spectrogram of size (..., n_mels, time).
code: def forward(self, specgram: torch.Tensor) -> torch.Tensor:
      """
      Args:
          specgram (Tensor): A spectrogram STFT of dimension (..., freq, time).
      Returns:
          Tensor: Mel frequency spectrogram of size (..., n_mels, time).
      """
  
      # pack batch
      shape = specgram.size()
      specgram = specgram.reshape(-1, shape[-2], shape[-1])
  
      if self.fb.numel() == 0:
          tmp_fb = create_fb_matrix(
              specgram.size(1),
              self.f_min,
              self.f_max,
              self.n_mels,
              self.sample_rate,
          )
          # Attributes cannot be reassigned outside __init__ so workaround
          self.fb.resize_(tmp_fb.size())
          self.fb.copy_(tmp_fb)
  
      # (channel, frequency, time).transpose(...) dot (frequency, n_mels)
      # -> (channel, time, n_mels).transpose(...)
      mel_specgram = torch.matmul(
          specgram.transpose(1, 2), self.fb
      ).transpose(1, 2)
  
      # unpack batch
      mel_specgram = mel_specgram.reshape(
          shape[:-2] + mel_specgram.shape[-2:]
      )
  
      return mel_specgram
  
imports: import logging
  import math
  from typing import Any, Dict, List, Optional
  import numpy
  import torch
  import torch.nn.functional
  from espnet2.gan_svs.visinger2.ddsp import remove_above_nyquist, scale_function, upsample
  from espnet2.gan_tts.hifigan import HiFiGANMultiPeriodDiscriminator, HiFiGANMultiScaleDiscriminator, HiFiGANMultiScaleMultiPeriodDiscriminator, HiFiGANPeriodDiscriminator, HiFiGANScaleDiscriminator
  from espnet2.gan_tts.hifigan.residual_block import ResidualBlock
label_desc: Use image node_id 2 for calling the MelScale obj's underlying member method code with example usage: obj.forward(specgram) and returns: mel_specgram