class_docstr: Calculate Signal to Distortion Ratio (SDR) metric.
  
  See `SDR ref1`_ and `SDR ref2`_ for details on the metric.
  
  As input to ``forward`` and ``update`` the metric accepts the following input
  
  - ``preds`` (:class:`~torch.Tensor`): float tensor with shape ``(...,time)``
  - ``target`` (:class:`~torch.Tensor`): float tensor with shape ``(...,time)``
  
  As output of `forward` and `compute` the metric returns the following output
  
  - ``sdr`` (:class:`~torch.Tensor`): float scalar tensor with average SDR value over samples
  
  .. note:
      The metric currently does not seem to work with Pytorch v1.11 and specific GPU hardware.
  
  Args:
      use_cg_iter:
          If provided, conjugate gradient descent is used to solve for the distortion
          filter coefficients instead of direct Gaussian elimination, which requires that
          ``fast-bss-eval`` is installed and pytorch version >= 1.8.
          This can speed up the computation of the metrics in case the filters
          are long. Using a value of 10 here has been shown to provide
          good accuracy in most cases and is sufficient when using this
          loss to train neural separation networks.
      filter_length: The length of the distortion filter allowed
      zero_mean:
          When set to True, the mean of all signals is subtracted prior to computation of the metrics
      load_diag:
          If provided, this small value is added to the diagonal coefficients of the system metrics when solving
          for the filter coefficients. This can help stabilize the metric in the case where some reference
          signals may sometimes be zero
      kwargs: Additional keyword arguments, see :ref:`Metric kwargs` for more info.
  
  Example:
      >>> import torch
      >>> from torchmetrics.audio import SignalDistortionRatio
      >>> g = torch.manual_seed(1)
      >>> preds = torch.randn(8000)
      >>> target = torch.randn(8000)
      >>> sdr = SignalDistortionRatio()
      >>> sdr(preds, target)
      tensor(-12.0589)
      >>> # use with pit
      >>> from torchmetrics.audio import PermutationInvariantTraining
      >>> from torchmetrics.functional.audio import signal_distortion_ratio
      >>> preds = torch.randn(4, 2, 8000)  # [batch, spk, time]
      >>> target = torch.randn(4, 2, 8000)
      >>> pit = PermutationInvariantTraining(signal_distortion_ratio,
      ...     mode="speaker-wise", eval_func="max")
      >>> pit(preds, target)
      tensor(-11.6051)
class_docstr_tok: ["Calculate","Signal","to","Distortion","Ratio","(","SDR",")","metric",".","See","`","SDR","ref1","`","_","and","`","SDR","ref2","`","_","for","details","on","the","metric",".","As","input","to","``","forward","``","and","``","update","``","the","metric","accepts","the","following","input","-","``","preds","``","(",":","class",":","`","~torch.Tensor","`",")",":","float","tensor","with","shape","``","(","...",",","time",")","``","-","``","target","``","(",":","class",":","`","~torch.Tensor","`",")",":","float","tensor","with","shape","``","(","...",",","time",")","``","As","output","of","`","forward","`","and","`","compute","`","the","metric","returns","the","following","output","-","``","sdr","``","(",":","class",":","`","~torch.Tensor","`",")",":","float","scalar","tensor","with","average","SDR","value","over","samples","..","note",":","The","metric","currently","does","not","seem","to","work","with","Pytorch","v1.11","and","specific","GPU","hardware",".","Args",":","use_cg_iter",":","If","provided",",","conjugate","gradient","descent","is","used","to","solve","for","the","distortion","filter","coefficients","instead","of","direct","Gaussian","elimination",",","which","requires","that","``","fast-bss-eval","``","is","installed","and","pytorch","version",">","=","1.8",".","This","can","speed","up","the","computation","of","the","metrics","in","case","the","filters","are","long",".","Using","a","value","of","10","here","has","been","shown","to","provide","good","accuracy","in","most","cases","and","is","sufficient","when","using","this","loss","to","train","neural","separation","networks",".","filter_length",":","The","length","of","the","distortion","filter","allowed","zero_mean",":","When","set","to","True",",","the","mean","of","all","signals","is","subtracted","prior","to","computation","of","the","metrics","load_diag",":","If","provided",",","this","small","value","is","added","to","the","diagonal","coefficients","of","the","system","metrics","when","solving","for","the","filter","coefficients",".","This","can","help","stabilize","the","metric","in","the","case","where","some","reference","signals","may","sometimes","be","zero","kwargs",":","Additional","keyword","arguments",",","see",":","ref",":","`","Metric","kwargs","`","for","more","info",".","Example",":",">",">",">","import","torch",">",">",">","from","torchmetrics.audio","import","SignalDistortionRatio",">",">",">","g","=","torch.manual_seed","(","1",")",">",">",">","preds","=","torch.randn","(","8000",")",">",">",">","target","=","torch.randn","(","8000",")",">",">",">","sdr","=","SignalDistortionRatio","(",")",">",">",">","sdr","(","preds",",","target",")","tensor","(","-12.0589",")",">",">",">","#","use","with","pit",">",">",">","from","torchmetrics.audio","import","PermutationInvariantTraining",">",">",">","from","torchmetrics.functional.audio","import","signal_distortion_ratio",">",">",">","preds","=","torch.randn","(","4",",","2",",","8000",")","#","[","batch",",","spk",",","time","]",">",">",">","target","=","torch.randn","(","4",",","2",",","8000",")",">",">",">","pit","=","PermutationInvariantTraining","(","signal_distortion_ratio",",","...","mode=","''","speaker-wise","''",",","eval_func=","''","max","''",")",">",">",">","pit","(","preds",",","target",")","tensor","(","-11.6051",")"]
docstr: Update state with predictions and targets.
docstr_tok: ["Update","state","with","predictions","and","targets","."]
code: def update(self, preds: Tensor, target: Tensor) -> None:
      """Update state with predictions and targets."""
      sdr_batch = signal_distortion_ratio(
          preds,
          target,
          self.use_cg_iter,
          self.filter_length,
          self.zero_mean,
          self.load_diag,
      )
  
      self.sum_sdr += sdr_batch.sum()
      self.total += sdr_batch.numel()
  
imports: from typing import Any, Optional, Sequence, Union
  from torch import Tensor, tensor
  from torchmetrics.functional.audio.sdr import scale_invariant_signal_distortion_ratio, signal_distortion_ratio, source_aggregated_signal_distortion_ratio
  from torchmetrics.metric import Metric
  from torchmetrics.utilities.imports import _MATPLOTLIB_AVAILABLE
  from torchmetrics.utilities.plot import _AX_TYPE, _PLOT_OUT_TYPE
label_desc: Use image node_id 2 for calling the SignalDistortionRatio obj's underlying member method code with example usage: obj.update(preds, target) without return types