code: def test_read_ctf_mag_bad_comp(tmp_path, monkeypatch):
      """Test CTF reader with mag comps and bad comps."""
      path = op.join(ctf_dir, ctf_fname_continuous)
      raw_orig = read_raw_ctf(path)
      assert raw_orig.compensation_grade == 0
      monkeypatch.setattr(
          mne.io.ctf.ctf, "_read_res4", _read_res4_mag_comp
      )
      raw_mag_comp = read_raw_ctf(path)
      assert raw_mag_comp.compensation_grade == 0
      sphere = mne.make_sphere_model()
      src = mne.setup_volume_source_space(
          pos=50.0, exclude=5.0, bem=sphere
      )
      assert src[0]["nuse"] == 26
      for grade in (0, 1):
          raw_orig.apply_gradient_compensation(grade)
          raw_mag_comp.apply_gradient_compensation(grade)
          args = (None, src, sphere, True, False)
          fwd_orig = make_forward_solution(raw_orig.info, *args)
          fwd_mag_comp = make_forward_solution(raw_mag_comp.info, *args)
          assert_allclose(
              fwd_orig["sol"]["data"], fwd_mag_comp["sol"]["data"]
          )
      monkeypatch.setattr(
          mne.io.ctf.ctf, "_read_res4", _bad_res4_grad_comp
      )
      with pytest.raises(
          RuntimeError, match="inconsistent compensation grade"
      ):
          read_raw_ctf(path)
  
imports: import copy
  import os
  import shutil
  from datetime import datetime, timezone
  from os import path
  import numpy
  import pytest
  from numpy import array_equal
  from numpy.testing import assert_allclose, assert_array_equal
  import mne
  import mne.io.ctf.info
  from mne import create_info, events_from_annotations, make_forward_solution, pick_types, read_annotations
  from mne._fiff.compensator import get_current_comp
  from mne._fiff.constants import FIFF
  from mne._fiff.pick import _picks_to_idx
  from mne.datasets import brainstorm, spm_face, testing
  from mne.io import RawArray, read_raw_ctf, read_raw_fif
  from mne.io.ctf.constants import CTF
  from mne.io.ctf.info import _convert_time
  from mne.io.tests.test_raw import _test_raw_reader
  from mne.tests.test_annotations import _assert_annotations_equal
  from mne.transforms import apply_trans
  from mne.utils import _clean_names, _record_warnings, _stamp_to_dt, catch_logging
label_desc: Use image node_id 10 for calling a global function with example usage: test_read_ctf_mag_bad_comp(tmp_path, monkeypatch) without return types