code: def norm_epsilon(Y, l1_ratio, phi, w_space=1.0, w_time=None):
      """Weighted epsilon norm.
  
      The weighted epsilon norm is the dual norm of::
  
      w_{space} * (1. - l1_ratio) * ||Y||_2 + l1_ratio * ||Y||_{1, w_{time}}.
  
      where `||Y||_{1, w_{time}} = (np.abs(Y) * w_time).sum()`
  
      Warning: it takes into account the fact that Y only contains coefficients
      corresponding to the positive frequencies (see `stft_norm2()`): some
      entries will be counted twice. It is also assumed that all entries of both
      Y and w_time are non-negative. See
      :footcite:`NdiayeEtAl2016,BurdakovMerkulov2001`.
  
      Parameters
      ----------
      Y : array, shape (n_coefs,)
          The input data.
      l1_ratio : float between 0 and 1
          Tradeoff between L2 and L1 regularization. When it is 0, no temporal
          regularization is applied.
      phi : instance of _Phi
          The TF operator.
      w_space : float
          Scalar weight of the L2 norm. By default, it is taken equal to 1.
      w_time : array, shape (n_coefs, ) | None
          Weights of each TF coefficient in the L1 norm. If None, weights equal
          to 1 are used.
  
  
      Returns
      -------
      nu : float
          The value of the dual norm evaluated at Y.
  
      References
      ----------
      .. footbibliography::
      """
      # since the solution is invariant to flipped signs in Y, all entries
      # of Y are assumed positive
  
      # Add negative freqs: count all freqs twice except first and last:
      freqs_count = np.full(len(Y), 2)
      for i, fc in enumerate(
          np.array_split(freqs_count, np.cumsum(phi.n_coefs)[:-1])
      ):
          fc[: phi.n_steps[i]] = 1
          fc[-phi.n_steps[i] :] = 1
  
      # exclude 0 weights:
      if w_time is not None:
          nonzero_weights = w_time != 0.0
          Y = Y[nonzero_weights]
          freqs_count = freqs_count[nonzero_weights]
          w_time = w_time[nonzero_weights]
  
      norm_inf_Y = (
          np.max(Y / w_time) if w_time is not None else np.max(Y)
      )
      if l1_ratio == 1.0:
          # dual norm of L1 weighted is Linf with inverse weights
          return norm_inf_Y
      elif l1_ratio == 0.0:
          # dual norm of L2 is L2
          return np.sqrt(phi.norm(Y[None, :], ord=2).sum())
  
      if norm_inf_Y == 0.0:
          return 0.0
  
      # ignore some values of Y by lower bound on dual norm:
      if w_time is None:
          idx = Y > l1_ratio * norm_inf_Y
      else:
          idx = Y > l1_ratio * np.max(
              Y / (w_space * (1.0 - l1_ratio) + l1_ratio * w_time)
          )
  
      if idx.sum() == 1:
          return norm_inf_Y
  
      # sort both Y / w_time and freqs_count at the same time
      if w_time is not None:
          idx_sort = np.argsort(Y[idx] / w_time[idx])[::-1]
          w_time = w_time[idx][idx_sort]
      else:
          idx_sort = np.argsort(Y[idx])[::-1]
  
      Y = Y[idx][idx_sort]
      freqs_count = freqs_count[idx][idx_sort]
  
      Y = np.repeat(Y, freqs_count)
      if w_time is not None:
          w_time = np.repeat(w_time, freqs_count)
  
      K = Y.shape[0]
      if w_time is None:
          p_sum_Y2 = np.cumsum(Y**2)
          p_sum_w2 = np.arange(1, K + 1)
          p_sum_Yw = np.cumsum(Y)
          upper = p_sum_Y2 / Y**2 - 2.0 * p_sum_Yw / Y + p_sum_w2
      else:
          p_sum_Y2 = np.cumsum(Y**2)
          p_sum_w2 = np.cumsum(w_time**2)
          p_sum_Yw = np.cumsum(Y * w_time)
          upper = (
              p_sum_Y2 / (Y / w_time) ** 2
              - 2.0 * p_sum_Yw / (Y / w_time)
              + p_sum_w2
          )
      upper_greater = np.where(
          upper > w_space**2 * (1.0 - l1_ratio) ** 2 / l1_ratio**2
      )[0]
  
      i0 = upper_greater[0] - 1 if upper_greater.size else K - 1
  
      p_sum_Y2 = p_sum_Y2[i0]
      p_sum_w2 = p_sum_w2[i0]
      p_sum_Yw = p_sum_Yw[i0]
  
      denom = (
          l1_ratio**2 * p_sum_w2
          - w_space**2 * (1.0 - l1_ratio) ** 2
      )
      if np.abs(denom) < 1e-10:
          return p_sum_Y2 / (2.0 * l1_ratio * p_sum_Yw)
      else:
          delta = (l1_ratio * p_sum_Yw) ** 2 - p_sum_Y2 * denom
          return (l1_ratio * p_sum_Yw - np.sqrt(delta)) / denom
  
imports: import functools
  from math import sqrt
  import numpy
  from ..time_frequency._stft import istft, stft, stft_norm1, stft_norm2
  from ..utils import _check_option, _get_blas_funcs, _validate_type, logger, sum_squared, verbose, warn
  from .mxne_debiasing import compute_bias
label_desc: Use image node_id 17 for calling a global function with example usage: norm_epsilon(Y, l1_ratio, phi, w_space, w_time) and returns: norm_inf_Y, int, norm_inf_Y, unknown, unknown, np