code: def find_ch_adjacency(info, ch_type):
      """Find the adjacency matrix for the given channels.
  
      This function tries to infer the appropriate adjacency matrix template
      for the given channels. If a template is not found, the adjacency matrix
      is computed using Delaunay triangulation based on 2D sensor locations.
  
      Parameters
      ----------
      %(info_not_none)s
      ch_type : str | None
          The channel type for computing the adjacency matrix. Currently
          supports ``'mag'``, ``'grad'``, ``'eeg'`` and ``None``.
          If ``None``, the info must contain only one channel type.
  
      Returns
      -------
      ch_adjacency : scipy.sparse.csr_matrix, shape (n_channels, n_channels)
          The adjacency matrix.
      ch_names : list
          The list of channel names present in adjacency matrix.
  
      See Also
      --------
      mne.viz.plot_ch_adjacency
      mne.stats.combine_adjacency
      get_builtin_ch_adjacencies
      read_ch_adjacency
  
      Notes
      -----
      .. versionadded:: 0.15
  
      Automatic detection of an appropriate adjacency matrix template only
      works for MEG data at the moment. This means that the adjacency matrix
      is always computed for EEG data and never loaded from a template file. If
      you want to load a template for a given montage use
      :func:`read_ch_adjacency` directly.
  
      .. warning::
          If Delaunay triangulation is used to calculate the adjacency matrix it
          may yield partially unexpected results (e.g., include unwanted edges
          between non-adjacent sensors). Therefore, it is recommended to check
          (and, if necessary, manually modify) the result by inspecting it
          via :func:`mne.viz.plot_ch_adjacency`.
  
      Note that depending on your use case, you may need to additionally use
      :func:`mne.stats.combine_adjacency` to prepare a final "adjacency"
      to pass to the eventual function.
      """
      from ..io.kit.constants import KIT_NEIGHBORS
  
      if ch_type is None:
          picks = channel_indices_by_type(info)
          if sum([len(p) != 0 for p in picks.values()]) != 1:
              raise ValueError(
                  "info must contain only one channel type if "
                  "ch_type is None."
              )
          ch_type = channel_type(info, 0)
      else:
          _check_option("ch_type", ch_type, ["mag", "grad", "eeg"])
      (
          has_vv_mag,
          has_vv_grad,
          is_old_vv,
          has_4D_mag,
          ctf_other_types,
          has_CTF_grad,
          n_kit_grads,
          has_any_meg,
          has_eeg_coils,
          has_eeg_coils_and_meg,
          has_eeg_coils_only,
          has_neuromag_122_grad,
          has_csd_coils,
      ) = _get_ch_info(info)
      conn_name = None
      if has_vv_mag and ch_type == "mag":
          conn_name = "neuromag306mag"
      elif has_vv_grad and ch_type == "grad":
          conn_name = "neuromag306planar"
      elif has_4D_mag:
          if "MEG 248" in info["ch_names"]:
              idx = info["ch_names"].index("MEG 248")
              grad = (
                  info["chs"][idx]["coil_type"]
                  == FIFF.FIFFV_COIL_MAGNES_GRAD
              )
              mag = (
                  info["chs"][idx]["coil_type"]
                  == FIFF.FIFFV_COIL_MAGNES_MAG
              )
              if ch_type == "grad" and grad:
                  conn_name = "bti248grad"
              elif ch_type == "mag" and mag:
                  conn_name = "bti248"
          elif "MEG 148" in info["ch_names"] and ch_type == "mag":
              idx = info["ch_names"].index("MEG 148")
              if (
                  info["chs"][idx]["coil_type"]
                  == FIFF.FIFFV_COIL_MAGNES_MAG
              ):
                  conn_name = "bti148"
      elif has_CTF_grad and ch_type == "mag":
          if info["nchan"] < 100:
              conn_name = "ctf64"
          elif info["nchan"] > 200:
              conn_name = "ctf275"
          else:
              conn_name = "ctf151"
      elif n_kit_grads > 0:
          conn_name = KIT_NEIGHBORS.get(info["kit_system_id"])
  
      if conn_name is not None:
          logger.info(f"Reading adjacency matrix for {conn_name}.")
          adjacency, ch_names = read_ch_adjacency(conn_name)
          if conn_name.startswith("neuromag") and info["ch_names"][
              0
          ].startswith("MEG "):
              ch_names = [
                  ch_name.replace("MEG", "MEG ") for ch_name in ch_names
              ]
          return adjacency, ch_names
      logger.info(
          "Could not find a adjacency matrix for the data. "
          "Computing adjacency based on Delaunay triangulations."
      )
      return _compute_ch_adjacency(info, ch_type)
  
imports: import os.path
  import string
  import sys
  from collections import OrderedDict
  from copy import deepcopy
  from dataclasses import dataclass
  from functools import partial
  from pathlib import Path
  from typing import Union
  import numpy
  from scipy.io import loadmat
  from scipy.sparse import csr_matrix, lil_matrix
  from scipy.spatial import Delaunay
  from scipy.stats import zscore
  from .._fiff.constants import FIFF
  from .._fiff.meas_info import Info, MontageMixin, _merge_info, _rename_comps, _unit2human, create_info
  from .._fiff.pick import _check_excludes_includes, _pick_data_channels, _picks_by_type, _picks_to_idx, _second_rules, channel_indices_by_type, channel_type, pick_channels, pick_info, pick_types
  from .._fiff.proj import setup_proj
  from .._fiff.reference import add_reference_channels, set_eeg_reference
  from .._fiff.tag import _rename_list
  from ..bem import _check_origin
  from ..defaults import HEAD_SIZE_DEFAULT, _handle_default
  from ..utils import _check_dict_keys, _check_fname, _check_option, _check_preload, _get_stim_channel, _on_missing, _validate_type, fill_doc, legacy, logger, verbose, warn
label_desc: Use image node_id 9 for calling a global function with example usage: find_ch_adjacency(info, ch_type) and returns: _compute_ch_adjacency, adjacency,  ch_names