code: def _primal_l21(M, G, X, active_set, alpha, n_orient):
      """Primal objective for the mixed-norm inverse problem.
  
      See :footcite:`GramfortEtAl2012`.
  
      Parameters
      ----------
      M : array, shape (n_sensors, n_times)
          The data.
      G : array, shape (n_sensors, n_active)
          The gain matrix a.k.a. lead field.
      X : array, shape (n_active, n_times)
          Sources.
      active_set : array of bool, shape (n_sources,)
          Mask of active sources.
      alpha : float
          The regularization parameter.
      n_orient : int
          Number of dipoles per locations (typically 1 or 3).
  
      Returns
      -------
      p_obj : float
          Primal objective.
      R : array, shape (n_sensors, n_times)
          Current residual (M - G * X).
      nR2 : float
          Data-fitting term.
      GX : array, shape (n_sensors, n_times)
          Forward prediction.
      """
      GX = np.dot(G[:, active_set], X)
      R = M - GX
      penalty = norm_l21(X, n_orient, copy=True)
      nR2 = sum_squared(R)
      p_obj = 0.5 * nR2 + alpha * penalty
      return p_obj, R, nR2, GX
  
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 5 for calling a global function with example usage: _primal_l21(M, G, X, active_set, alpha, n_orient) and returns: p_obj,  R,  nR2,  GX