code: def _pair_grad_sensors(
      info,
      layout=None,
      topomap_coords=True,
      exclude="bads",
      raise_error=True,
  ):
      """Find the picks for pairing grad channels.
  
      Parameters
      ----------
      %(info_not_none)s
      layout : Layout | None
          The layout if available. Defaults to None.
      topomap_coords : bool
          Return the coordinates for a topomap plot along with the picks. If
          False, only picks are returned. Defaults to True.
      exclude : list of str | str
          List of channels to exclude. If empty, do not exclude any.
          If 'bads', exclude channels in info['bads']. Defaults to 'bads'.
      raise_error : bool
          Whether to raise an error when no pairs are found. If False, raises a
          warning.
  
      Returns
      -------
      picks : array of int
          Picks for the grad channels, ordered in pairs.
      coords : array, shape = (n_grad_channels, 3)
          Coordinates for a topomap plot (optional, only returned if
          topomap_coords == True).
      """
      # find all complete pairs of grad channels
      pairs = defaultdict(list)
      grad_picks = pick_types(
          info, meg="grad", ref_meg=False, exclude=exclude
      )
  
      _, has_vv_grad, *_, has_neuromag_122_grad, _ = _get_ch_info(info)
  
      for i in grad_picks:
          ch = info["chs"][i]
          name = ch["ch_name"]
          if has_vv_grad and name.startswith("MEG"):
              if name.endswith(("2", "3")):
                  key = name[-4:-1]
                  pairs[key].append(ch)
          if has_neuromag_122_grad and name.startswith("MEG"):
              key = (int(name[-3:]) - 1) // 2
              pairs[key].append(ch)
  
      pairs = [p for p in pairs.values() if len(p) == 2]
      if len(pairs) == 0:
          if raise_error:
              raise ValueError("No 'grad' channel pairs found.")
          else:
              warn("No 'grad' channel pairs found.")
              return list()
  
      # find the picks corresponding to the grad channels
      grad_chs = sum(pairs, [])
      ch_names = info["ch_names"]
      picks = [ch_names.index(c["ch_name"]) for c in grad_chs]
  
      if topomap_coords:
          shape = (len(pairs), 2, -1)
          coords = (
              _find_topomap_coords(info, picks, layout)
              .reshape(shape)
              .mean(axis=1)
          )
          return picks, coords
      else:
          return picks
  
imports: import logging
  from collections import defaultdict
  from itertools import combinations
  from pathlib import Path
  import numpy
  from scipy.spatial.distance import pdist, squareform
  from .._fiff.constants import FIFF
  from .._fiff.meas_info import Info
  from .._fiff.pick import _FNIRS_CH_TYPES_SPLIT, _picks_to_idx, pick_types
  from ..transforms import _cart_to_sph, _pol_to_cart
  from ..utils import _check_ch_locs, _check_fname, _check_option, _check_sphere, _clean_names, fill_doc, logger, warn
  from ..viz.topomap import plot_layout
  from .channels import _get_ch_info
label_desc: Use image node_id 12 for calling a global function with example usage: _pair_grad_sensors(info, layout, topomap_coords, exclude, raise_error) and returns: picks,  coords, picks, list