code: def find_layout(info, ch_type=None, exclude="bads"):
      """Choose a layout based on the channels in the info 'chs' field.
  
      Parameters
      ----------
      %(info_not_none)s
      ch_type : {'mag', 'grad', 'meg', 'eeg'} | None
          The channel type for selecting single channel layouts.
          Defaults to None. Note, this argument will only be considered for
          VectorView type layout. Use ``'meg'`` to force using the full layout
          in situations where the info does only contain one sensor type.
      exclude : list of str | str
          List of channels to exclude. If empty do not exclude any.
          If 'bads', exclude channels in info['bads'] (default).
  
      Returns
      -------
      layout : Layout instance | None
          None if layout not found.
      """
      _check_option(
          "ch_type", ch_type, [None, "mag", "grad", "meg", "eeg", "csd"]
      )
  
      (
          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)
      has_vv_meg = has_vv_mag and has_vv_grad
      has_vv_only_mag = has_vv_mag and not has_vv_grad
      has_vv_only_grad = has_vv_grad and not has_vv_mag
      if ch_type == "meg" and not has_any_meg:
          raise RuntimeError(
              "No MEG channels present. Cannot find MEG layout."
          )
  
      if ch_type == "eeg" and not has_eeg_coils:
          raise RuntimeError(
              "No EEG channels present. Cannot find EEG layout."
          )
  
      layout_name = None
      if (has_vv_meg and ch_type is None) or (
          any([has_vv_mag, has_vv_grad]) and ch_type == "meg"
      ):
          layout_name = "Vectorview-all"
      elif has_vv_only_mag or (has_vv_meg and ch_type == "mag"):
          layout_name = "Vectorview-mag"
      elif has_vv_only_grad or (has_vv_meg and ch_type == "grad"):
          if info["ch_names"][0].endswith("X"):
              layout_name = "Vectorview-grad_norm"
          else:
              layout_name = "Vectorview-grad"
      elif has_neuromag_122_grad:
          layout_name = "Neuromag_122"
      elif (has_eeg_coils_only and ch_type in [None, "eeg"]) or (
          has_eeg_coils_and_meg and ch_type == "eeg"
      ):
          if not isinstance(info, (dict, Info)):
              raise RuntimeError(
                  "Cannot make EEG layout, no measurement info "
                  "was passed to `find_layout`"
              )
          return make_eeg_layout(info, exclude=exclude)
      elif has_csd_coils and ch_type in [None, "csd"]:
          return make_eeg_layout(info, exclude=exclude, csd=True)
      elif has_4D_mag:
          layout_name = "magnesWH3600"
      elif has_CTF_grad:
          layout_name = "CTF-275"
      elif n_kit_grads > 0:
          layout_name = _find_kit_layout(info, n_kit_grads)
  
      # If no known layout is found, fall back on automatic layout
      if layout_name is None:
          picks = _picks_to_idx(
              info, "data", exclude=(), with_ref_meg=False
          )
          ch_names = [info["ch_names"][pick] for pick in picks]
          xy = _find_topomap_coords(
              info, picks=picks, ignore_overlap=True
          )
          return generate_2d_layout(
              xy, ch_names=ch_names, name="custom", normalize=True
          )
  
      layout = read_layout(fname=layout_name)
      if not is_old_vv:
          layout.names = _clean_names(
              layout.names, remove_whitespace=True
          )
      if has_CTF_grad:
          layout.names = _clean_names(layout.names, before_dash=True)
  
      # Apply mask for excluded channels.
      if exclude == "bads":
          exclude = info["bads"]
      idx = [
          ii
          for ii, name in enumerate(layout.names)
          if name not in exclude
      ]
      layout.names = [layout.names[ii] for ii in idx]
      layout.pos = layout.pos[idx]
      layout.ids = [layout.ids[ii] for ii in idx]
  
      return layout
  
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 6 for calling a global function with example usage: find_layout(info, ch_type, exclude) and returns: layout, generate_2d_layout, make_eeg_layout, make_eeg_layout