code: def test_resolution_matrix_free(src_type, fwd_volume_small):
      """Test make_inverse_resolution_matrix on surfaces."""
      # read forward solution
      if src_type == "surface":
          forward = mne.read_forward_solution(fname_fwd)
          verbose = False
          # Some arbitrary vertex numbers
          idx = [1, 100, 400]
      else:
          assert src_type == "volume"
          forward = fwd_volume_small
          verbose = "error"  # ignore missing chs in vol
          idx = [1, 3, 8]
      assert forward["src"].kind == src_type
      noise_cov = mne.read_cov(fname_cov)
      evoked = mne.read_evokeds(fname_evoked, 0)
  
      # make inverse operator from forward solution
      # free source orientation
      inverse_operator = mne.minimum_norm.make_inverse_operator(
          info=evoked.info,
          forward=forward,
          noise_cov=noise_cov,
          loose=1.0,
          depth=None,
          verbose=verbose,
      )
      assert_allclose(
          inverse_operator["source_nn"], forward["source_nn"]
      )
  
      # regularisation parameter based on SNR
      snr = 3.0
      lambda2 = 1.0 / snr**2
      # resolution matrices for free source orientation
      # compute resolution matrix for MNE with free source orientations
      rm_mne_free = make_inverse_resolution_matrix(
          forward,
          inverse_operator,
          method="MNE",
          lambda2=lambda2,
          verbose=verbose,
      )
      assert_array_almost_equal(rm_mne_free, rm_mne_free.T)
      # check various summary and normalisation options
      for mode in [None, "sum", "mean", "maxval", "maxnorm", "pca"]:
          n_comps = [1, 3]
          if mode in [None, "sum", "mean"]:
              n_comps = [1]
          for n_comp in n_comps:
              for norm in [None, "max", "norm", True]:
                  # with free orientations and vector source estimates
                  if src_type == "surface":
                      ctx = pytest.raises(
                          TypeError, match="vector surface"
                      )
                  else:
                      ctx = nullcontext()
                  with ctx:
                      stc_psf_free = get_point_spread(
                          rm_mne_free,
                          forward["src"],
                          idx,
                          mode=mode,
                          n_comp=n_comp,
                          norm=norm,
                          return_pca_vars=False,
                          vector=True,
                      )
                  stc_psf_free = get_point_spread(
                      rm_mne_free,
                      inverse_operator,
                      idx,
                      mode=mode,
                      n_comp=n_comp,
                      norm=norm,
                      return_pca_vars=False,
                      vector=True,
                  )
                  stc_ctf_free = get_cross_talk(
                      rm_mne_free,
                      forward,
                      idx,
                      mode=mode,
                      n_comp=n_comp,
                      norm=norm,
                      return_pca_vars=False,
                      vector=True,
                  )
                  err_msg = f"mode={mode}, n_comp={n_comp}, norm={norm}"
                  # There is an ambiguity in the sign flip from the PCA here.
                  # Ideally we would use the normals to fix it, but it's not
                  # trivial.
                  if mode == "pca" and n_comp == 3:
                      stc_psf_free = abs(stc_psf_free)
                      stc_ctf_free = abs(stc_psf_free)
                  assert_array_almost_equal(
                      stc_psf_free.data,
                      stc_ctf_free.data,
                      err_msg=err_msg,
                  )
      # For MNE, PSF and CTF for same vertices should be the same
      label = mne.read_label(fname_label)
      label = [label]
      stc_psf_label_free = get_point_spread(
          rm_mne_free, inverse_operator, label, norm="norm", vector=True
      )
      stc_ctf_label_free = get_cross_talk(
          rm_mne_free, inverse_operator, label, norm="norm", vector=True
      )
      assert_array_almost_equal(
          stc_psf_label_free.data, stc_ctf_label_free.data
      )
  
file_path: mne-python/mne/minimum_norm/tests/test_resolution_matrix.py
imports: from contextlib import nullcontext
  import numpy
  import pytest
  from numpy.testing import assert_allclose, assert_array_almost_equal, assert_array_equal
  import mne
  from mne.datasets import testing
  from mne.minimum_norm.resolution_matrix import _vertices_for_get_psf_ctf, get_cross_talk, get_point_spread, make_inverse_resolution_matrix
label_desc: Use image node_id 1 for calling a global function with example usage: test_resolution_matrix_free(src_type, fwd_volume_small) without return types