class_docstr: Log STFT magnitude loss module.
class_docstr_tok: ["Log","STFT","magnitude","loss","module","."]
docstr: Calculate forward propagation.
  Args:
      x_mag (Tensor): Magnitude spectrogram of predicted signal (B, #frames, #freq_bins).
      y_mag (Tensor): Magnitude spectrogram of groundtruth signal (B, #frames, #freq_bins).
      input_lengths (Tensor): Length of groundtruth sample in samples (B).
  Returns:
      Tensor: Log STFT magnitude loss value.
docstr_tok: ["Calculate","forward","propagation",".","Args",":","x_mag","(","Tensor",")",":","Magnitude","spectrogram","of","predicted","signal","(","B",",","#","frames",",","#","freq_bins",")",".","y_mag","(","Tensor",")",":","Magnitude","spectrogram","of","groundtruth","signal","(","B",",","#","frames",",","#","freq_bins",")",".","input_lengths","(","Tensor",")",":","Length","of","groundtruth","sample","in","samples","(","B",")",".","Returns",":","Tensor",":","Log","STFT","magnitude","loss","value","."]
code: def forward(self, *, x_mag, y_mag, input_lengths=None):
      """Calculate forward propagation.
      Args:
          x_mag (Tensor): Magnitude spectrogram of predicted signal (B, #frames, #freq_bins).
          y_mag (Tensor): Magnitude spectrogram of groundtruth signal (B, #frames, #freq_bins).
          input_lengths (Tensor): Length of groundtruth sample in samples (B).
      Returns:
          Tensor: Log STFT magnitude loss value.
      """
      if input_lengths is None:
          # During training, we used fixed sequence length, so just average across all dimensions
          return F.l1_loss(torch.log(y_mag), torch.log(x_mag))
      loss = F.l1_loss(
          torch.log(y_mag), torch.log(x_mag), reduction="none"
      )
      # First sum and average across time and freq bins
      loss = loss / loss.shape[2]
      loss = torch.sum(loss, dim=[1, 2])
      loss = loss / input_lengths
      # Last average across batch
      return torch.sum(loss) / loss.shape[0]
  
imports: import torch
  import torch.nn.functional
  from nemo.core.classes import Loss, typecheck
  from nemo.core.neural_types.elements import AudioSignal, LengthsType, LossType, SpectrogramType
  from nemo.core.neural_types.neural_type import NeuralType
label_desc: Use image node_id 3 for calling the LogSTFTMagnitudeLoss obj's underlying member method code with example usage: obj.forward() and returns: unknown, F