class_docstr: Calculate spectral component based on the magnitude of Fast Fourier Transform (FFT).
  
  Based on:
      Dhariwal, et al. 'Jukebox: A generative model for music.' https://arxiv.org/abs/2005.00341
  
  Args:
      spatial_dims: number of spatial dimensions.
      fft_signal_size: signal size in the transformed dimensions. See torch.fft.fftn() for more information.
      fft_norm: {``"forward"``, ``"backward"``, ``"ortho"``} Specifies the normalization mode in the fft. See
          torch.fft.fftn() for more information.
  
      reduction: {``"none"``, ``"mean"``, ``"sum"``}
          Specifies the reduction to apply to the output. Defaults to ``"mean"``.
  
          - ``"none"``: no reduction will be applied.
          - ``"mean"``: the sum of the output will be divided by the number of elements in the output.
          - ``"sum"``: the output will be summed.
class_docstr_tok: ["Calculate","spectral","component","based","on","the","magnitude","of","Fast","Fourier","Transform","(","FFT",")",".","Based","on",":","Dhariwal",",","et","al",".","'Jukebox",":","A","generative","model","for","music",".","'","https",":","\/\/arxiv.org\/abs\/2005.00341","Args",":","spatial_dims",":","number","of","spatial","dimensions",".","fft_signal_size",":","signal","size","in","the","transformed","dimensions",".","See","torch.fft.fftn","(",")","for","more","information",".","fft_norm",":","{","``","``","forward","''","``",",","``","``","backward","''","``",",","``","``","ortho","''","``","}","Specifies","the","normalization","mode","in","the","fft",".","See","torch.fft.fftn","(",")","for","more","information",".","reduction",":","{","``","``","none","''","``",",","``","``","mean","''","``",",","``","``","sum","''","``","}","Specifies","the","reduction","to","apply","to","the","output",".","Defaults","to","``","``","mean","''","``",".","-","``","``","none","''","``",":","no","reduction","will","be","applied",".","-","``","``","mean","''","``",":","the","sum","of","the","output","will","be","divided","by","the","number","of","elements","in","the","output",".","-","``","``","sum","''","``",":","the","output","will","be","summed","."]
code: def forward(
      self, input: torch.Tensor, target: torch.Tensor
  ) -> torch.Tensor:
      input_amplitude = self._get_fft_amplitude(target)
      target_amplitude = self._get_fft_amplitude(input)
  
      # Compute distance between amplitude of frequency components
      # See Section 3.3 from https://arxiv.org/abs/2005.00341
      loss = F.mse_loss(
          target_amplitude, input_amplitude, reduction="none"
      )
  
      if self.reduction == LossReduction.MEAN.value:
          loss = loss.mean()
      elif self.reduction == LossReduction.SUM.value:
          loss = loss.sum()
      elif self.reduction == LossReduction.NONE.value:
          pass
  
      return loss
  
file_path: MONAI/monai/losses/spectral_loss.py
imports: from __future__ import annotations
  import torch
  import torch.nn.functional
  from torch.fft import fftn
  from torch.nn.modules.loss import _Loss
  from monai.utils import LossReduction
label_desc: Use image node_id 2 for calling the JukeboxLoss obj's underlying member method code with example usage: obj.forward(input, target) and returns: loss