code: def calculate_sdr_numpy(
      estimate: np.ndarray,
      target: np.ndarray,
      scale_invariant: bool = False,
      convolution_invariant: bool = False,
      convolution_filter_length: Optional[int] = None,
      remove_mean: bool = True,
      sdr_max: Optional[float] = None,
      eps: float = 1e-8,
  ) -> float:
      """Calculate signal-to-distortion ratio.
  
          SDR = 10 * log10( ||t||_2^2 / (||e-t||_2^2 + alpha * ||t||^2)
  
      where
          alpha = 10^(-sdr_max/10)
  
      Optionally, apply scale-invariant scaling to target signal.
  
      Args:
          estimate: estimated signal
          target: target signal
  
      Returns:
          SDR in dB.
      """
      if scale_invariant and convolution_invariant:
          raise ValueError(
              "Arguments scale_invariant and convolution_invariant cannot be used simultaneously."
          )
  
      if remove_mean:
          estimate = estimate - np.mean(estimate)
          target = target - np.mean(target)
  
      if scale_invariant or (
          convolution_invariant and convolution_filter_length == 1
      ):
          target = scale_invariant_target_numpy(
              estimate=estimate, target=target, eps=eps
          )
      elif convolution_invariant:
          target = convolution_invariant_target_numpy(
              estimate=estimate,
              target=target,
              filter_length=convolution_filter_length,
              eps=eps,
          )
  
      target_pow = np.mean(np.abs(target) ** 2)
      distortion_pow = np.mean(np.abs(estimate - target) ** 2)
  
      if sdr_max is not None:
          distortion_pow = (
              distortion_pow + 10 ** (-sdr_max / 10) * target_pow
          )
  
      sdr = 10 * np.log10(target_pow / (distortion_pow + eps) + eps)
      return sdr
  
imports: import math
  from typing import Iterable, Optional, Union
  import librosa
  import numpy
  import numpy.typing
  import scipy
  import soundfile
  import torch
  from scipy.spatial.distance import pdist, squareform
  from nemo.utils import logging
label_desc: Use image node_id 13 for calling a global function with example usage: calculate_sdr_numpy(estimate, target, scale_invariant, convolution_invariant, convolution_filter_length, remove_mean, sdr_max, eps) and returns: sdr