code: def test_make_forward_solution_ctf(tmp_path, fname_src_small, other):
      """Test CTF w/compensation against MNE-C or OpenMEEG."""
      pytest.importorskip("nibabel")
      src = read_source_spaces(fname_src_small)
      raw = read_raw_fif(fname_ctf_raw)
      assert raw.compensation_grade == 3
      if other == "openmeeg":
          mindist = 20.0
          n_src_want = 51
      else:
          assert other == "MNE-C"
          mindist = 0.0
          n_src_want = n_src_small
          assert n_src_want == 108
      mindist = 20.0 if other == "openmeeg" else 0.0
      fwd_py = make_forward_solution(
          fname_ctf_raw,
          fname_trans,
          src,
          fname_bem_meg,
          eeg=False,
          mindist=mindist,
          verbose=True,
      )
  
      if other == "openmeeg":
          # TODO: This should be a 1-layer, but it's broken
          # (some correlations become negative!)...
          bem_surfaces = read_bem_surfaces(fname_bem)  # fname_bem_meg
          bem = make_bem_solution(bem_surfaces, solver="openmeeg")
          # TODO: These tolerances are bad
          tol_kwargs = dict(
              meg_atol=1, meg_corr_tol=0.65, meg_rdm_tol=0.6
          )
          fwd = make_forward_solution(
              fname_ctf_raw,
              fname_trans,
              src,
              bem,
              eeg=False,
              mindist=mindist,
              verbose=True,
          )
      else:
          assert other == "MNE-C"
          bem = None
          tol_kwargs = dict()
          fwd = _do_forward_solution(
              "sample",
              fname_ctf_raw,
              mri=fname_trans,
              src=fname_src_small,
              bem=fname_bem_meg,
              eeg=False,
              meg=True,
              subjects_dir=subjects_dir,
              mindist=mindist,
          )
      _compare_forwards(fwd, fwd_py, 274, n_src_want, **tol_kwargs)
  
      # CTF with compensation changed in python
      ctf_raw = read_raw_fif(fname_ctf_raw)
      ctf_raw.info["bads"] = [
          "MRO24-2908"
      ]  # test that it works with some bads
      ctf_raw.apply_gradient_compensation(2)
  
      fwd_py = make_forward_solution(
          ctf_raw.info,
          fname_trans,
          src,
          fname_bem_meg,
          eeg=False,
          meg=True,
          mindist=mindist,
      )
      if other == "openmeeg":
          assert bem is not None
          fwd = make_forward_solution(
              ctf_raw.info,
              fname_trans,
              src,
              bem,
              eeg=False,
              mindist=mindist,
              verbose=True,
          )
      else:
          fwd = _do_forward_solution(
              "sample",
              ctf_raw,
              mri=fname_trans,
              src=fname_src_small,
              bem=fname_bem_meg,
              eeg=False,
              meg=True,
              subjects_dir=subjects_dir,
              mindist=mindist,
          )
      _compare_forwards(fwd, fwd_py, 274, n_src_want, **tol_kwargs)
  
      fname_temp = tmp_path / "test-ctf-fwd.fif"
      write_forward_solution(fname_temp, fwd_py)
      fwd_py2 = read_forward_solution(fname_temp)
      _compare_forwards(fwd_py, fwd_py2, 274, n_src_want, **tol_kwargs)
      repr(fwd_py)
  
imports: from itertools import product
  from pathlib import Path
  import numpy
  import pytest
  from numpy.testing import assert_allclose, assert_array_equal, assert_array_less
  from mne import convert_forward_solution, create_info, get_volume_labels_from_aseg, make_forward_solution, make_sphere_model, pick_info, pick_types, pick_types_forward, read_cov, read_dipole, read_evokeds, read_forward_solution, read_source_spaces, setup_volume_source_space, write_forward_solution
  from mne._fiff.constants import FIFF
  from mne.bem import make_bem_solution, read_bem_surfaces
  from mne.channels import make_standard_montage
  from mne.datasets import testing
  from mne.dipole import Dipole, fit_dipole
  from mne.forward import Forward, _do_forward_solution, use_coil_def
  from mne.forward._compute_forward import _magnetic_dipole_field_vec
  from mne.forward._make_forward import _create_meg_coils, make_forward_dipole
  from mne.forward.tests.test_forward import assert_forward_allclose
  from mne.io import read_info, read_raw_bti, read_raw_fif, read_raw_kit
  from mne.simulation import simulate_evoked
  from mne.source_estimate import VolSourceEstimate
  from mne.source_space._source_space import _compare_source_spaces, setup_source_space, write_source_spaces
  from mne.surface import _get_ico_surface
  from mne.transforms import Transform
  from mne.utils import catch_logging, requires_mne, requires_mne_mark, requires_openmeeg_mark, run_subprocess
label_desc: Use image node_id 7 for calling a global function with example usage: test_make_forward_solution_ctf(tmp_path, fname_src_small, other) without return types