code: def sensitivity_map(
      fwd,
      projs=None,
      ch_type="grad",
      mode="fixed",
      exclude=(),
      *,
      verbose=None,
  ):
      """Compute sensitivity map.
  
      Such maps are used to know how much sources are visible by a type
      of sensor, and how much projections shadow some sources.
  
      Parameters
      ----------
      fwd : Forward
          The forward operator.
      projs : list
          List of projection vectors.
      ch_type : ``'grad'`` | ``'mag'`` | ``'eeg'``
          The type of sensors to use.
      mode : str
          The type of sensitivity map computed. See manual. Should be ``'free'``,
          ``'fixed'``, ``'ratio'``, ``'radiality'``, ``'angle'``,
          ``'remaining'``, or ``'dampening'`` corresponding to the argument
          ``--map 1, 2, 3, 4, 5, 6, 7`` of the command ``mne_sensitivity_map``.
      exclude : list of str | str
          List of channels to exclude. If empty do not exclude any (default).
          If ``'bads'``, exclude channels in ``fwd['info']['bads']``.
      %(verbose)s
  
      Returns
      -------
      stc : SourceEstimate | VolSourceEstimate
          The sensitivity map as a SourceEstimate or VolSourceEstimate instance
          for visualization.
  
      Notes
      -----
      When mode is ``'fixed'`` or ``'free'``, the sensitivity map is normalized
      by its maximum value.
      """
      # check strings
      _check_option("ch_type", ch_type, ["eeg", "grad", "mag"])
      _check_option(
          "mode",
          mode,
          [
              "free",
              "fixed",
              "ratio",
              "radiality",
              "angle",
              "remaining",
              "dampening",
          ],
      )
  
      # check forward
      if is_fixed_orient(fwd, orig=True):
          raise ValueError(
              "fwd should must be computed with free orientation"
          )
  
      # limit forward (this will make a copy of the data for us)
      if ch_type == "eeg":
          fwd = pick_types_forward(
              fwd, meg=False, eeg=True, exclude=exclude
          )
      else:
          fwd = pick_types_forward(
              fwd, meg=ch_type, eeg=False, exclude=exclude
          )
  
      convert_forward_solution(
          fwd,
          surf_ori=True,
          force_fixed=False,
          copy=False,
          verbose=False,
      )
      assert fwd["surf_ori"] and not is_fixed_orient(fwd)
  
      gain = fwd["sol"]["data"]
  
      # Make sure EEG has average
      if ch_type == "eeg":
          if projs is None or not _has_eeg_average_ref_proj(
              fwd["info"], projs=projs
          ):
              eeg_ave = [make_eeg_average_ref_proj(fwd["info"])]
          else:
              eeg_ave = []
          projs = eeg_ave if projs is None else projs + eeg_ave
  
      # Construct the projector
      residual_types = ["angle", "remaining", "dampening"]
      if projs is not None:
          proj, ncomp, U = make_projector(
              projs, fwd["sol"]["row_names"], include_active=True
          )
          # do projection for most types
          if mode not in residual_types:
              gain = np.dot(proj, gain)
          elif ncomp == 0:
              raise RuntimeError(
                  "No valid projectors found for channel type "
                  "%s, cannot compute %s" % (ch_type, mode)
              )
      # can only run the last couple methods if there are projectors
      elif mode in residual_types:
          raise ValueError(
              "No projectors used, cannot compute %s" % mode
          )
  
      _, n_dipoles = gain.shape
      n_locations = n_dipoles // 3
      del n_dipoles
      sensitivity_map = np.empty(n_locations)
  
      for k in range(n_locations):
          gg = gain[:, 3 * k : 3 * (k + 1)]  # noqa: E203
          if mode != "fixed":
              s = _safe_svd(gg, full_matrices=False, compute_uv=False)
          if mode == "free":
              sensitivity_map[k] = s[0]
          else:
              gz = np.linalg.norm(gg[:, 2])  # the normal component
              if mode == "fixed":
                  sensitivity_map[k] = gz
              elif mode == "ratio":
                  sensitivity_map[k] = gz / s[0]
              elif mode == "radiality":
                  sensitivity_map[k] = 1.0 - (gz / s[0])
              else:
                  if mode == "angle":
                      co = np.linalg.norm(np.dot(gg[:, 2], U))
                      sensitivity_map[k] = co / gz
                  else:
                      p = np.linalg.norm(np.dot(proj, gg[:, 2]))
                      if mode == "remaining":
                          sensitivity_map[k] = p / gz
                      elif mode == "dampening":
                          sensitivity_map[k] = 1.0 - p / gz
                      else:
                          raise ValueError(
                              "Unknown mode type (got %s)" % mode
                          )
  
      # only normalize fixed and free methods
      if mode in ["fixed", "free"]:
          sensitivity_map /= np.max(sensitivity_map)
  
      subject = _subject_from_forward(fwd)
      vertices = [s["vertno"] for s in fwd["src"]]
      return _make_stc(
          sensitivity_map[:, np.newaxis],
          vertices,
          fwd["src"].kind,
          tmin=0.0,
          tstep=1.0,
          subject=subject,
      )
  
imports: import numpy
  from ._fiff.constants import FIFF
  from ._fiff.open import fiff_open
  from ._fiff.pick import _picks_to_idx, pick_types, pick_types_forward
  from ._fiff.proj import Projection, _has_eeg_average_ref_proj, _read_proj, _write_proj, make_eeg_average_ref_proj, make_projector
  from ._fiff.write import start_and_end_file
  from .cov import _check_n_samples
  from .epochs import Epochs
  from .event import make_fixed_length_events
  from .fixes import _safe_svd
  from .forward import _subject_from_forward, convert_forward_solution, is_fixed_orient
  from .parallel import parallel_func
  from .source_estimate import _make_stc
  from .utils import _check_fname, _check_option, _validate_type, check_fname, logger, verbose
label_desc: Use image node_id 8 for calling a global function with example usage: sensitivity_map(fwd, projs, ch_type, mode, exclude) and returns: _make_stc