code: def test_receptive_field_nd(n_jobs):
      """Test multidimensional support."""
      pytest.importorskip("sklearn")
      from sklearn.linear_model import Ridge
  
      # multidimensional
      rng = np.random.RandomState(3)
      x = rng.randn(1000, 3)
      y = np.zeros((1000, 2))
      smin, smax = 0, 5
      # This is a weird assignment, but it's just a way to distribute some
      # unique values at various delays, and "expected" explains how they
      # should appear in the resulting RF
      for ii in range(1, 5):
          y[ii:, ii % 2] += (-1) ** ii * ii * x[:-ii, ii % 3]
      y -= np.mean(y, axis=0)
      x -= np.mean(x, axis=0)
      x_off = x + 1e3
      expected = [
          [[0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 4, 0], [0, 0, 2, 0, 0, 0]],
          [
              [0, 0, 0, -3, 0, 0],
              [0, -1, 0, 0, 0, 0],
              [0, 0, 0, 0, 0, 0],
          ],
      ]
      tdr_l = TimeDelayingRidge(
          smin, smax, 1.0, 0.1, "laplacian", n_jobs=n_jobs
      )
      tdr_nc = TimeDelayingRidge(
          smin, smax, 1.0, 0.1, n_jobs=n_jobs, edge_correction=False
      )
      for estimator, atol in zip(
          (Ridge(alpha=0.0), 0.0, 0.01, tdr_l, tdr_nc),
          (1e-3, 1e-3, 1e-3, 5e-3, 5e-2),
      ):
          model = ReceptiveField(smin, smax, 1.0, estimator=estimator)
          model.fit(x, y)
          assert_array_equal(model.delays_, np.arange(smin, smax + 1))
          assert_allclose(model.coef_, expected, atol=atol)
      tdr = TimeDelayingRidge(
          smin, smax, 1.0, 0.01, reg_type="foo", n_jobs=n_jobs
      )
      model = ReceptiveField(smin, smax, 1.0, estimator=tdr)
      with pytest.raises(
          ValueError, match="reg_type entries must be one of"
      ):
          model.fit(x, y)
      tdr = TimeDelayingRidge(
          smin, smax, 1.0, 0.01, reg_type=["laplacian"], n_jobs=n_jobs
      )
      model = ReceptiveField(smin, smax, 1.0, estimator=tdr)
      with pytest.raises(
          ValueError, match="reg_type must have two elements"
      ):
          model.fit(x, y)
      model = ReceptiveField(
          smin, smax, 1, estimator=tdr, fit_intercept=False
      )
      with pytest.raises(ValueError, match="fit_intercept"):
          model.fit(x, y)
  
      # Now check the intercept_
      tdr = TimeDelayingRidge(smin, smax, 1.0, 0.0, n_jobs=n_jobs)
      tdr_no = TimeDelayingRidge(
          smin, smax, 1.0, 0.0, fit_intercept=False, n_jobs=n_jobs
      )
      for estimator in (
          Ridge(alpha=0.0),
          tdr,
          Ridge(alpha=0.0, fit_intercept=False),
          tdr_no,
      ):
          # first with no intercept in the data
          model = ReceptiveField(smin, smax, 1.0, estimator=estimator)
          model.fit(x, y)
          assert_allclose(
              model.estimator_.intercept_,
              0.0,
              atol=1e-7,
              err_msg=repr(estimator),
          )
          assert_allclose(
              model.coef_, expected, atol=1e-3, err_msg=repr(estimator)
          )
          y_pred = model.predict(x)
          assert_allclose(
              y_pred[model.valid_samples_],
              y[model.valid_samples_],
              atol=1e-2,
              err_msg=repr(estimator),
          )
          score = np.mean(model.score(x, y))
          assert score > 0.9999
  
          # now with an intercept in the data
          model.fit(x_off, y)
          if estimator.fit_intercept:
              val = [-6000, 4000]
              itol = 0.5
              ctol = 5e-4
          else:
              val = itol = 0.0
              ctol = 2.0
          assert_allclose(
              model.estimator_.intercept_,
              val,
              atol=itol,
              err_msg=repr(estimator),
          )
          assert_allclose(
              model.coef_,
              expected,
              atol=ctol,
              rtol=ctol,
              err_msg=repr(estimator),
          )
          if estimator.fit_intercept:
              ptol = 1e-2
              stol = 0.999999
          else:
              ptol = 10
              stol = 0.6
          y_pred = model.predict(x_off)[model.valid_samples_]
          assert_allclose(
              y_pred,
              y[model.valid_samples_],
              atol=ptol,
              err_msg=repr(estimator),
          )
          score = np.mean(model.score(x_off, y))
          assert score > stol, estimator
          model = ReceptiveField(smin, smax, 1.0, fit_intercept=False)
          model.fit(x_off, y)
          assert_allclose(model.estimator_.intercept_, 0.0, atol=1e-7)
          score = np.mean(model.score(x_off, y))
          assert score > 0.6
  
imports: from pathlib import Path
  import numpy
  import pytest
  from numpy import einsum
  from numpy.fft import irfft, rfft
  from numpy.testing import assert_allclose, assert_array_equal, assert_equal
  from mne.decoding import ReceptiveField, TimeDelayingRidge
  from mne.decoding.receptive_field import _SCORERS, _delay_time_series, _delays_to_slice, _times_to_delays
  from mne.decoding.time_delaying_ridge import _compute_corrs, _compute_reg_neighbors
label_desc: Use image node_id 7 for calling a global function with example usage: test_receptive_field_nd(n_jobs) without return types