class_docstr: Computes signal-to-distortion ratio (SDR) loss with weighted average across channels.
  
  Args:
      weight: weight for SDR of each output channel, used for averaging the loss across channels. Defaults to `None` (averaging).
      reduction: batch reduction. Defaults to `mean` over the batch.
      scale_invariant: If `True`, use scale-invariant SDR. Defaults to `False`.
      remove_mean: Remove mean before calculating the loss. Defaults to `True`.
      sdr_max: Soft thresholding of the loss to SDR_max.
      eps: Small value for regularization.
class_docstr_tok: ["Computes","signal-to-distortion","ratio","(","SDR",")","loss","with","weighted","average","across","channels",".","Args",":","weight",":","weight","for","SDR","of","each","output","channel",",","used","for","averaging","the","loss","across","channels",".","Defaults","to","`","None","`","(","averaging",")",".","reduction",":","batch","reduction",".","Defaults","to","`","mean","`","over","the","batch",".","scale_invariant",":","If","`","True","`",",","use","scale-invariant","SDR",".","Defaults","to","`","False","`",".","remove_mean",":","Remove","mean","before","calculating","the","loss",".","Defaults","to","`","True","`",".","sdr_max",":","Soft","thresholding","of","the","loss","to","SDR_max",".","eps",":","Small","value","for","regularization","."]
code: def __init__(
      self,
      weight: Optional[List[float]] = None,
      reduction: str = "mean",
      scale_invariant: bool = False,
      convolution_invariant: bool = False,
      convolution_filter_length: Optional[int] = 512,
      remove_mean: bool = True,
      sdr_max: Optional[float] = None,
      eps: float = 1e-8,
  ):
      super().__init__()
  
      # SDR weight buffer
      if weight is not None:
          if any([w <= 0 for w in weight]):
              raise ValueError(
                  f"Weight must be positive! Current value: {weight}"
              )
          elif not np.isclose(sum(weight), 1, atol=1e-6):
              raise ValueError(
                  f"Weight should add to one, current weight: {weight}"
              )
          weight = torch.tensor(weight).reshape(1, -1)
          logging.info(f"Channel weight set to %s", weight)
      self.register_buffer("weight", weight)
      self.weight: Optional[Tensor]
  
      # Batch reduction
      self.reduction = reduction
      if reduction == "mean":
          self.reduce = torch.mean
      else:
          raise ValueError(f"Unexpected reduction mode {reduction}.")
  
      # SDR calculation setup
      if scale_invariant and convolution_invariant:
          raise ValueError(
              f"{self.__class__.__name__}: arguments scale_invariant and convolution_invariant cannot be used simultaneously."
          )
      self.scale_invariant = scale_invariant
      self.convolution_invariant = convolution_invariant
      self.convolution_filter_length = convolution_filter_length
      self.remove_mean = remove_mean
      self.sdr_max = sdr_max
      self.eps = eps
  
file_path: NeMo/nemo/collections/asr/losses/audio_losses.py
imports: import math
  from typing import List, Optional
  import numpy
  import torch
  from nemo.collections.asr.parts.preprocessing.features import make_seq_mask_like
  from nemo.collections.asr.parts.utils.audio_utils import toeplitz
  from nemo.core.classes import Loss, Typing, typecheck
  from nemo.core.neural_types import AudioSignal, LengthsType, LossType, MaskType, NeuralType
  from nemo.utils import logging
label_desc: Use image node_id 1 to create a new SDRLoss object from inherited base classes: Loss, Typing with example: obj = SDRLoss(weight, reduction, scale_invariant, convolution_invariant, convolution_filter_length, remove_mean, sdr_max, eps)