code: def test_generate_2d_layout():
      """Test creation of a layout from 2d points."""
      snobg = 10
      sbg = 15
      side = range(snobg)
      bg_image = np.random.RandomState(42).randn(sbg, sbg)
      w, h = [0.2, 0.5]
  
      # Generate fake data
      xy = np.array([(i, j) for i in side for j in side])
      lt = generate_2d_layout(xy, w=w, h=h)
  
      # Correct points ordering / minmaxing
      comp_1, comp_2 = [(5, 0), (7, 0)]
      assert lt.pos[:, :2].max() == 1
      assert lt.pos[:, :2].min() == 0
      with np.errstate(invalid="ignore"):  # divide by zero
          assert_allclose(
              xy[comp_2] / float(xy[comp_1]),
              lt.pos[comp_2] / float(lt.pos[comp_1]),
          )
      assert_allclose(lt.pos[0, [2, 3]], [w, h])
  
      # Correct number elements
      assert lt.pos.shape[1] == 4
      assert len(lt.box) == 4
  
      # Make sure background image normalizing is correct
      lt_bg = generate_2d_layout(xy, bg_image=bg_image)
      assert_allclose(lt_bg.pos[:, :2].max(), xy.max() / float(sbg))
  
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 9 for calling a global function with example usage: test_generate_2d_layout() without return types