code: def _auto_topomap_coords(
      info, picks, ignore_overlap, to_sphere, sphere
  ):
      """Make a 2 dimensional sensor map from sensor positions in an info dict.
  
      The default is to use the electrode locations. The fallback option is to
      attempt using digitization points of kind FIFFV_POINT_EEG. This only works
      with EEG and requires an equal number of digitization points and sensors.
  
      Parameters
      ----------
      %(info_not_none)s
      picks : list | str | slice | None
          None will pick all channels.
      ignore_overlap : bool
          Whether to ignore overlapping positions in the layout. If False and
          positions overlap, an error is thrown.
      to_sphere : bool
          If True, the radial distance of spherical coordinates is ignored, in
          effect fitting the xyz-coordinates to a sphere.
      sphere : array-like | str
          The head sphere definition.
  
      Returns
      -------
      locs : array, shape = (n_sensors, 2)
          An array of positions of the 2 dimensional map.
      """
      sphere = _check_sphere(sphere, info)
      logger.debug(f"Generating coords using: {sphere}")
  
      picks = _picks_to_idx(
          info, picks, "all", exclude=(), allow_empty=False
      )
      chs = [info["chs"][i] for i in picks]
  
      # Use channel locations if available
      locs3d = np.array([ch["loc"][:3] for ch in chs])
  
      # If electrode locations are not available, use digization points
      if not _check_ch_locs(info=info, picks=picks):
          logging.warning(
              "Did not find any electrode locations (in the info "
              "object), will attempt to use digitization points "
              "instead. However, if digitization points do not "
              "correspond to the EEG electrodes, this will lead to "
              "bad results. Please verify that the sensor locations "
              "in the plot are accurate."
          )
  
          # MEG/EOG/ECG sensors don't have digitization points; all requested
          # channels must be EEG
          for ch in chs:
              if ch["kind"] != FIFF.FIFFV_EEG_CH:
                  raise ValueError(
                      "Cannot determine location of MEG/EOG/ECG "
                      "channels using digitization points."
                  )
  
          eeg_ch_names = [
              ch["ch_name"]
              for ch in info["chs"]
              if ch["kind"] == FIFF.FIFFV_EEG_CH
          ]
  
          # Get EEG digitization points
          if info["dig"] is None or len(info["dig"]) == 0:
              raise RuntimeError("No digitization points found.")
  
          locs3d = np.array(
              [
                  point["r"]
                  for point in info["dig"]
                  if point["kind"] == FIFF.FIFFV_POINT_EEG
              ]
          )
  
          if len(locs3d) == 0:
              raise RuntimeError(
                  "Did not find any digitization points of "
                  "kind FIFFV_POINT_EEG (%d) in the info."
                  % FIFF.FIFFV_POINT_EEG
              )
  
          if len(locs3d) != len(eeg_ch_names):
              raise ValueError(
                  "Number of EEG digitization points (%d) "
                  "doesn't match the number of EEG channels "
                  "(%d)" % (len(locs3d), len(eeg_ch_names))
              )
  
          # We no longer center digitization points on head origin, as we work
          # in head coordinates always
  
          # Match the digitization points with the requested
          # channels.
          eeg_ch_locs = dict(zip(eeg_ch_names, locs3d))
          locs3d = np.array([eeg_ch_locs[ch["ch_name"]] for ch in chs])
  
      # Sometimes we can get nans
      locs3d[~np.isfinite(locs3d)] = 0.0
  
      # Duplicate points cause all kinds of trouble during visualization
      dist = pdist(locs3d)
      if (
          len(locs3d) > 1
          and np.min(dist) < 1e-10
          and not ignore_overlap
      ):
          problematic_electrodes = [
              chs[elec_i]["ch_name"]
              for elec_i in squareform(dist < 1e-10)
              .any(axis=0)
              .nonzero()[0]
          ]
  
          raise ValueError(
              "The following electrodes have overlapping positions,"
              " which causes problems during visualization:\n"
              + ", ".join(problematic_electrodes)
          )
  
      if to_sphere:
          # translate to sphere origin, transform/flatten Z, translate back
          locs3d -= sphere[:3]
          # use spherical (theta, pol) as (r, theta) for polar->cartesian
          cart_coords = _cart_to_sph(locs3d)
          out = _pol_to_cart(cart_coords[:, 1:][:, ::-1])
          # scale from radians to mm
          out *= cart_coords[:, [0]] / (np.pi / 2.0)
          out += sphere[:2]
      else:
          out = _pol_to_cart(_cart_to_sph(locs3d))
      return out
  
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 10 for calling a global function with example usage: _auto_topomap_coords(info, picks, ignore_overlap, to_sphere, sphere) and returns: out