code: def test_split_gof_meg(forward, idx, weights):
      """Test GOF splitting on MEG data."""
      gain = forward["sol"]["data"][:, idx]
      # close to orthogonal
      norms = np.linalg.norm(gain, axis=0)
      triu = np.triu_indices(len(idx), 1)
      prods = np.abs(np.dot(gain.T, gain) / np.outer(norms, norms))[
          triu
      ]
      assert_array_less(prods, 5e-3)  # approximately orthogonal
      # first, split across time (one dipole per time point)
      M = gain * weights
      gof_split = _split_gof(M, np.diag(weights), gain)
      assert_allclose(
          gof_split.sum(0), 100.0, atol=1e-5
      )  # all sum to 100
      assert_allclose(
          gof_split, 100 * np.eye(len(weights)), atol=1
      )  # loc
      # next, summed to a single time point (all dipoles active at one time pt)
      weights = np.array(weights)[:, np.newaxis]
      x = gain @ weights
      assert x.shape == (gain.shape[0], 1)
      gof_split = _split_gof(x, weights, gain)
      want = (norms * weights.T).T ** 2
      want = 100 * want / want.sum()
      assert_allclose(gof_split, want, atol=1e-3, rtol=1e-2)
      assert_allclose(gof_split.sum(), 100, rtol=1e-5)
  
imports: import numpy
  import pytest
  from numpy.testing import assert_allclose, assert_array_almost_equal, assert_array_equal, assert_array_less
  import mne
  from mne import convert_forward_solution, read_cov, read_evokeds, read_forward_solution
  from mne.datasets import testing
  from mne.dipole import Dipole
  from mne.inverse_sparse import mixed_norm, tf_mixed_norm
  from mne.inverse_sparse.mxne_inverse import _compute_mxne_sure, _split_gof, make_stc_from_dipoles
  from mne.inverse_sparse.mxne_optim import norm_l2inf
  from mne.label import read_label
  from mne.minimum_norm import apply_inverse, make_inverse_operator
  from mne.minimum_norm.tests.test_inverse import assert_stc_res, assert_var_exp_log
  from mne.simulation import simulate_evoked, simulate_sparse_stc
  from mne.source_estimate import VolSourceEstimate
  from mne.utils import _record_warnings, assert_stcs_equal, catch_logging
label_desc: Use image node_id 5 for calling a global function with example usage: test_split_gof_meg(forward, idx, weights) without return types