code: def test_l21_mxne():
      """Test convergence of MxNE solver."""
      n, p, t, alpha = 30, 40, 20, 1.0
      rng = np.random.RandomState(0)
      G = rng.randn(n, p)
      G /= np.std(G, axis=0)[None, :]
      X = np.zeros((p, t))
      X[0] = 3
      X[4] = -2
      M = np.dot(G, X)
  
      args = (M, G, alpha, 1000, 1e-8)
      with _record_warnings():  # CD
          X_hat_cd, active_set, _, gap_cd = mixed_norm_solver(
              *args,
              active_set_size=None,
              debias=True,
              solver="cd",
              return_gap=True,
          )
      assert_array_less(gap_cd, 1e-8)
      assert_array_equal(np.where(active_set)[0], [0, 4])
      with _record_warnings():  # CD
          X_hat_bcd, active_set, E, gap_bcd = mixed_norm_solver(
              M,
              G,
              alpha,
              maxit=1000,
              tol=1e-8,
              active_set_size=None,
              debias=True,
              solver="bcd",
              return_gap=True,
          )
      assert_array_less(gap_bcd, 9.6e-9)
      assert_array_equal(np.where(active_set)[0], [0, 4])
      assert_allclose(X_hat_bcd, X_hat_cd, rtol=1e-2)
  
      with _record_warnings():  # CD
          X_hat_cd, active_set, _ = mixed_norm_solver(
              *args, active_set_size=2, debias=True, solver="cd"
          )
      assert_array_equal(np.where(active_set)[0], [0, 4])
      with _record_warnings():  # CD
          X_hat_bcd, active_set, _ = mixed_norm_solver(
              *args, active_set_size=2, debias=True, solver="bcd"
          )
      assert_array_equal(np.where(active_set)[0], [0, 4])
      assert_allclose(X_hat_bcd, X_hat_cd, rtol=1e-2)
  
      with _record_warnings():  # CD
          X_hat_bcd, active_set, _ = mixed_norm_solver(
              *args,
              active_set_size=2,
              debias=True,
              n_orient=2,
              solver="bcd",
          )
      assert_array_equal(np.where(active_set)[0], [0, 1, 4, 5])
  
      # suppress a coordinate-descent warning here
      with pytest.warns(RuntimeWarning, match="descent"):
          X_hat_cd, active_set, _ = mixed_norm_solver(
              *args,
              active_set_size=2,
              debias=True,
              n_orient=2,
              solver="cd",
          )
      assert_array_equal(np.where(active_set)[0], [0, 1, 4, 5])
      assert_allclose(X_hat_bcd, X_hat_cd, rtol=1e-2)
  
      with _record_warnings():  # CD
          X_hat_bcd, active_set, _ = mixed_norm_solver(
              *args,
              active_set_size=2,
              debias=True,
              n_orient=5,
              solver="bcd",
          )
      assert_array_equal(np.where(active_set)[0], [0, 1, 2, 3, 4])
      with pytest.warns(RuntimeWarning, match="descent"):
          X_hat_cd, active_set, _ = mixed_norm_solver(
              *args,
              active_set_size=2,
              debias=True,
              n_orient=5,
              solver="cd",
          )
  
      assert_array_equal(np.where(active_set)[0], [0, 1, 2, 3, 4])
      assert_allclose(X_hat_bcd, X_hat_cd)
  
file_path: mne-python/mne/inverse_sparse/tests/test_mxne_optim.py
imports: import numpy
  import pytest
  from numpy.testing import assert_allclose, assert_array_almost_equal, assert_array_equal, assert_array_less
  from mne.inverse_sparse.mxne_optim import _Phi, _PhiT, dgap_l21l1, iterative_mixed_norm_solver, iterative_tf_mixed_norm_solver, mixed_norm_solver, norm_epsilon, norm_epsilon_inf, tf_mixed_norm_solver
  from mne.time_frequency._stft import stft_norm2
  from mne.utils import _record_warnings, catch_logging
label_desc: Use image node_id 2 for calling a global function with example usage: test_l21_mxne() without return types