code: def test_find_layout():
      """Test finding layout."""
      pytest.raises(
          ValueError, find_layout, _get_test_info(), ch_type="meep"
      )
  
      sample_info = read_info(fif_fname)
      grads = pick_types(sample_info, meg="grad")
      sample_info2 = pick_info(sample_info, grads)
  
      mags = pick_types(sample_info, meg="mag")
      sample_info3 = pick_info(sample_info, mags)
  
      # mock new convention
      sample_info4 = copy.deepcopy(sample_info)
      for ii, name in enumerate(sample_info4["ch_names"]):
          new = name.replace(" ", "")
          sample_info4["chs"][ii]["ch_name"] = new
  
      eegs = pick_types(sample_info, meg=False, eeg=True)
      sample_info5 = pick_info(sample_info, eegs)
  
      lout = find_layout(sample_info, ch_type=None)
      assert lout.kind == "Vectorview-all"
      assert all(" " in k for k in lout.names)
  
      lout = find_layout(sample_info2, ch_type="meg")
      assert_equal(lout.kind, "Vectorview-all")
  
      # test new vector-view
      lout = find_layout(sample_info4, ch_type=None)
      assert_equal(lout.kind, "Vectorview-all")
      assert all(" " not in k for k in lout.names)
  
      lout = find_layout(sample_info, ch_type="grad")
      assert_equal(lout.kind, "Vectorview-grad")
      lout = find_layout(sample_info2)
      assert_equal(lout.kind, "Vectorview-grad")
      lout = find_layout(sample_info2, ch_type="grad")
      assert_equal(lout.kind, "Vectorview-grad")
      lout = find_layout(sample_info2, ch_type="meg")
      assert_equal(lout.kind, "Vectorview-all")
  
      lout = find_layout(sample_info, ch_type="mag")
      assert_equal(lout.kind, "Vectorview-mag")
      lout = find_layout(sample_info3)
      assert_equal(lout.kind, "Vectorview-mag")
      lout = find_layout(sample_info3, ch_type="mag")
      assert_equal(lout.kind, "Vectorview-mag")
      lout = find_layout(sample_info3, ch_type="meg")
      assert_equal(lout.kind, "Vectorview-all")
  
      lout = find_layout(sample_info, ch_type="eeg")
      assert_equal(lout.kind, "EEG")
      lout = find_layout(sample_info5)
      assert_equal(lout.kind, "EEG")
      lout = find_layout(sample_info5, ch_type="eeg")
      assert_equal(lout.kind, "EEG")
      # no common layout, 'meg' option not supported
  
      lout = find_layout(read_info(fname_ctf_raw))
      assert_equal(lout.kind, "CTF-275")
  
      fname_bti_raw = bti_dir / "exported4D_linux_raw.fif"
      lout = find_layout(read_info(fname_bti_raw))
      assert_equal(lout.kind, "magnesWH3600")
  
      raw_kit = read_raw_kit(fname_kit_157)
      lout = find_layout(raw_kit.info)
      assert_equal(lout.kind, "KIT-157")
  
      raw_kit.info["bads"] = [
          "MEG 013",
          "MEG 014",
          "MEG 015",
          "MEG 016",
      ]
      raw_kit.info._check_consistency()
      lout = find_layout(raw_kit.info)
      assert_equal(lout.kind, "KIT-157")
      # fallback for missing IDs
      for val in (35, 52, 54, 1001):
          with raw_kit.info._unlock():
              raw_kit.info["kit_system_id"] = val
          lout = find_layout(raw_kit.info)
          assert lout.kind == "custom"
  
      raw_umd = read_raw_kit(fname_kit_umd)
      lout = find_layout(raw_umd.info)
      assert_equal(lout.kind, "KIT-UMD-3")
  
      # Test plotting
      lout.plot()
      lout.plot(picks=np.arange(10))
      plt.close("all")
  
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 7 for calling a global function with example usage: test_find_layout() without return types