code: def test_sensitivity_maps():
      """Test sensitivity map computation."""
      fwd = read_forward_solution(fwd_fname)
      fwd = convert_forward_solution(fwd, surf_ori=True)
      projs = read_proj(eog_fname)
      projs.extend(read_proj(ecg_fname))
      decim = 6
      for ch_type in ["eeg", "grad", "mag"]:
          w = read_source_estimate(
              Path(str(sensmap_fname) % (ch_type, "lh"))
          ).data
          stc = sensitivity_map(
              fwd,
              projs=None,
              ch_type=ch_type,
              mode="free",
              exclude="bads",
          )
          assert_array_almost_equal(stc.data, w, decim)
          assert stc.subject == "sample"
          # let's just make sure the others run
          if ch_type == "grad":
              # fixed (2)
              w = read_source_estimate(
                  str(sensmap_fname) % (ch_type, "2-lh")
              ).data
              stc = sensitivity_map(
                  fwd,
                  projs=None,
                  mode="fixed",
                  ch_type=ch_type,
                  exclude="bads",
              )
              assert_array_almost_equal(stc.data, w, decim)
          if ch_type == "mag":
              # ratio (3)
              w = read_source_estimate(
                  str(sensmap_fname) % (ch_type, "3-lh")
              ).data
              stc = sensitivity_map(
                  fwd,
                  projs=None,
                  mode="ratio",
                  ch_type=ch_type,
                  exclude="bads",
              )
              assert_array_almost_equal(stc.data, w, decim)
          if ch_type == "eeg":
              # radiality (4), angle (5), remaining (6), and  dampening (7)
              modes = ["radiality", "angle", "remaining", "dampening"]
              ends = ["4-lh", "5-lh", "6-lh", "7-lh"]
              for mode, end in zip(modes, ends):
                  w = read_source_estimate(
                      str(sensmap_fname) % (ch_type, end)
                  ).data
                  stc = sensitivity_map(
                      fwd,
                      projs=projs,
                      mode=mode,
                      ch_type=ch_type,
                      exclude="bads",
                  )
                  assert_array_almost_equal(stc.data, w, decim)
  
      # test corner case for EEG
      stc = sensitivity_map(
          fwd,
          projs=[make_eeg_average_ref_proj(fwd["info"])],
          ch_type="eeg",
          exclude="bads",
      )
      # test corner case for projs being passed but no valid ones (#3135)
      pytest.raises(
          ValueError, sensitivity_map, fwd, projs=None, mode="angle"
      )
      pytest.raises(
          RuntimeError, sensitivity_map, fwd, projs=[], mode="angle"
      )
      # test volume source space
      fname = sample_path / "sample_audvis_trunc-meg-vol-7-fwd.fif"
      fwd = read_forward_solution(fname)
      sensitivity_map(fwd)
  
imports: import copy
  from pathlib import Path
  import numpy
  import pytest
  from numpy.testing import assert_allclose, assert_array_almost_equal, assert_equal
  from scipy import linalg
  from mne import Epochs, compute_proj_epochs, compute_proj_evoked, compute_proj_raw, compute_raw_covariance, convert_forward_solution, create_info, pick_types, read_events, read_forward_solution, read_source_estimate, sensitivity_map
  from mne._fiff.proj import _EEG_AVREF_PICK_DICT, _needs_eeg_average_ref_proj, activate_proj, make_projector, setup_proj
  from mne.cov import compute_whitener, regularize
  from mne.datasets import testing
  from mne.io import RawArray, read_raw_fif
  from mne.preprocessing import maxwell_filter
  from mne.proj import _has_eeg_average_ref_proj, make_eeg_average_ref_proj, read_proj, write_proj
  from mne.rank import _compute_rank_int
  from mne.utils import _record_warnings
label_desc: Use image node_id 3 for calling a global function with example usage: test_sensitivity_maps() without return types