code: def test_find_topomap_coords():
      """Test mapping of coordinates in 3D space to 2D."""
      info = read_info(fif_fname)
      picks = pick_types(
          info, meg=False, eeg=True, eog=False, stim=False
      )
  
      # Remove extra digitization point, so EEG digitization points match up
      # with the EEG channels
      del info["dig"][85]
  
      # Use channel locations
      kwargs = dict(
          ignore_overlap=False, to_sphere=True, sphere=HEAD_SIZE_DEFAULT
      )
      l0 = _find_topomap_coords(info, picks, **kwargs)
  
      # Remove electrode position information, use digitization points from now
      # on.
      for ch in info["chs"]:
          ch["loc"].fill(np.nan)
  
      l1 = _find_topomap_coords(info, picks, **kwargs)
      assert_allclose(l1, l0, atol=1e-3)
  
      for z_pt in (
          (HEAD_SIZE_DEFAULT, 0.0, 0.0),
          (0.0, HEAD_SIZE_DEFAULT, 0.0),
      ):
          info["dig"][-1]["r"] = np.array(z_pt)
          l1 = _find_topomap_coords(info, picks, **kwargs)
          assert_allclose(
              l1[-1], z_pt[:2], err_msg="Z=0 point moved", atol=1e-6
          )
  
      # Test plotting mag topomap without channel locations: it should fail
      mag_picks = pick_types(info, meg="mag")
      with pytest.raises(ValueError, match="Cannot determine location"):
          _find_topomap_coords(info, mag_picks, **kwargs)
  
      # Test function with too many EEG digitization points: it should fail
      info["dig"].append({"r": [1, 2, 3], "kind": FIFF.FIFFV_POINT_EEG})
      with pytest.raises(
          ValueError, match="Number of EEG digitization points"
      ):
          _find_topomap_coords(info, picks, **kwargs)
  
      # Test function with too little EEG digitization points: it should fail
      info._unlocked = True
      info["dig"] = info["dig"][:-2]
      with pytest.raises(
          ValueError, match="Number of EEG digitization points"
      ):
          _find_topomap_coords(info, picks, **kwargs)
  
      # Electrode positions must be unique
      info["dig"].append(info["dig"][-1])
      with pytest.raises(ValueError, match="overlapping positions"):
          _find_topomap_coords(info, picks, **kwargs)
  
      # Test function without EEG digitization points: it should fail
      info["dig"] = [
          d for d in info["dig"] if d["kind"] != FIFF.FIFFV_POINT_EEG
      ]
      with pytest.raises(
          RuntimeError, match="Did not find any digitization"
      ):
          _find_topomap_coords(info, picks, **kwargs)
  
      # Test function without any digitization points, it should fail
      info["dig"] = None
      with pytest.raises(
          RuntimeError, match="No digitization points found"
      ):
          _find_topomap_coords(info, picks, **kwargs)
      info["dig"] = []
      with pytest.raises(
          RuntimeError, match="No digitization points found"
      ):
          _find_topomap_coords(info, picks, **kwargs)
  
imports: import copy
  from pathlib import Path
  import matplotlib.pyplot
  import numpy
  import pytest
  from numpy.testing import assert_allclose, assert_array_almost_equal, assert_array_equal, assert_equal
  from mne import pick_info, pick_types
  from mne._fiff.constants import FIFF
  from mne._fiff.meas_info import _empty_info
  from mne.channels import find_layout, make_eeg_layout, make_grid_layout, read_layout
  from mne.channels.layout import _box_size, _find_topomap_coords, generate_2d_layout
  from mne.defaults import HEAD_SIZE_DEFAULT
  from mne.io import read_info, read_raw_kit
label_desc: Use image node_id 4 for calling a global function with example usage: test_find_topomap_coords() without return types