class_docstr: Spectogram Denoiser.
  
  Ref: https://arxiv.org/pdf/2207.06389.pdf.
docstr: Calculate diffusion process during training.
  
  Args:
      xs_ref (torch.Tensor): Input tensor.
      steps (torch.Tensor): Number of step.
      noise (Optional[torch.Tensor], optional): Noise tensor. Defaults to None.
  
  Returns:
      torch.Tensor: Output tensor.
docstr_tok: ["Calculate","diffusion","process","during","training",".","Args",":","xs_ref","(","torch.Tensor",")",":","Input","tensor",".","steps","(","torch.Tensor",")",":","Number","of","step",".","noise","(","Optional","[","torch.Tensor","]",",","optional",")",":","Noise","tensor",".","Defaults","to","None",".","Returns",":","torch.Tensor",":","Output","tensor","."]
code: def diffusion(
      self,
      xs_ref: torch.Tensor,
      steps: torch.Tensor,
      noise: Optional[torch.Tensor] = None,
  ) -> torch.Tensor:
      """Calculate diffusion process during training.
  
      Args:
          xs_ref (torch.Tensor): Input tensor.
          steps (torch.Tensor): Number of step.
          noise (Optional[torch.Tensor], optional): Noise tensor. Defaults to None.
  
      Returns:
          torch.Tensor: Output tensor.
  
      """
      # here goes norm_spec if does something
      batch_size = xs_ref.shape[0]
      xs_ref = xs_ref.transpose(1, 2).unsqueeze(1)
      steps = torch.clamp(steps, min=0)  # not sure if this is required
  
      # make a noise tensor
      if noise is None:
          noise = torch.randn_like(xs_ref)
  
      # q-sample
      ndims = (batch_size, *((1,) * (xs_ref.dim() - 1)))
      cum_prods = self.alphas_cumulative.gather(-1, steps).reshape(
          ndims
      )
      min_cum_prods = self.min_alphas_cumulative.gather(
          -1, steps
      ).reshape(ndims)
      xs_noisy = xs_ref * cum_prods + noise * min_cum_prods
      return xs_noisy
  
imports: import math
  from typing import Optional, Union
  import numpy
  import torch
  from torch import nn
  from torch.nn import functional
  from espnet.nets.pytorch_backend.transformer.embedding import PositionalEncoding
label_desc: Use image node_id 4 for calling the SpectogramDenoiser obj's underlying member method code with example usage: obj.diffusion(xs_ref, steps, noise) and returns: xs_noisy