code: def sdri(
      estimate: torch.Tensor,
      reference: torch.Tensor,
      mix: torch.Tensor,
      mask: Optional[torch.Tensor] = None,
      epsilon: float = 1e-8,
  ) -> torch.Tensor:
      """Compute the improvement of SDR (SDRi).
  
      This function compute how much SDR is improved if the estimation is changed from
      the original mixture signal to the actual estimated source signals. That is,
      ``SDR(estimate, reference) - SDR(mix, reference)``.
  
      For computing ``SDR(estimate, reference)``, PIT (permutation invariant training) is applied,
      so that best combination of sources between the reference signals and the esimate signals
      are picked.
  
      Args:
          estimate (torch.Tensor): Estimated source signals.
              Shape: [batch, speakers, time frame]
          reference (torch.Tensor): Reference (original) source signals.
              Shape: [batch, speakers, time frame]
          mix (torch.Tensor): Mixed souce signals, from which the setimated signals were generated.
              Shape: [batch, speakers == 1, time frame]
          mask (torch.Tensor or None, optional): Binary mask to indicate padded value (0) or valid value (1).
              Shape: [batch, 1, time frame]
          epsilon (float, optional): constant value used to stabilize division.
  
      Returns:
          torch.Tensor: Improved SDR. Shape: [batch, ]
  
      References:
          - Conv-TasNet: Surpassing Ideal Time--Frequency Magnitude Masking for Speech Separation
            Luo, Yi and Mesgarani, Nima
            https://arxiv.org/abs/1809.07454
      """
      sdr_ = sdr_pit(
          estimate, reference, mask=mask, epsilon=epsilon
      )  # [batch, ]
      base_sdr = sdr(
          mix, reference, mask=mask, epsilon=epsilon
      )  # [batch, speaker]
      return sdr_ - base_sdr.mean(dim=1)
  
file_path: audio/examples/source_separation/utils/metrics.py
imports: import math
  from itertools import permutations
  from typing import Optional
  import torch
label_desc: Use image node_id 3 for calling a global function with example usage: sdri(estimate, reference, mix, mask, epsilon) and returns: unknown