code: def test_receptive_field_basic(n_jobs):
      """Test model prep and fitting."""
      pytest.importorskip("sklearn")
      from sklearn.linear_model import Ridge
  
      # Make sure estimator pulling works
      mod = Ridge()
      rng = np.random.RandomState(1337)
  
      # Test the receptive field model
      # Define parameters for the model and simulate inputs + weights
      tmin, tmax = -10.0, 0
      n_feats = 3
      rng = np.random.RandomState(0)
      X = rng.randn(10000, n_feats)
      w = rng.randn(int((tmax - tmin) + 1) * n_feats)
  
      # Delay inputs and cut off first 4 values since they'll be cut in the fit
      X_del = np.concatenate(
          _delay_time_series(X, tmin, tmax, 1.0).transpose(2, 0, 1),
          axis=1,
      )
      y = np.dot(X_del, w)
  
      # Fit the model and test values
      feature_names = ["feature_%i" % ii for ii in [0, 1, 2]]
      rf = ReceptiveField(
          tmin, tmax, 1, feature_names, estimator=mod, patterns=True
      )
      rf.fit(X, y)
      assert_array_equal(rf.delays_, np.arange(tmin, tmax + 1))
  
      y_pred = rf.predict(X)
      assert_allclose(
          y[rf.valid_samples_], y_pred[rf.valid_samples_], atol=1e-2
      )
      scores = rf.score(X, y)
      assert scores > 0.99
      assert_allclose(rf.coef_.T.ravel(), w, atol=1e-3)
      # Make sure different input shapes work
      rf.fit(X[:, np.newaxis :], y[:, np.newaxis])
      rf.fit(X, y[:, np.newaxis])
      with pytest.raises(
          ValueError, match="If X has 3 .* y must have 2 or 3"
      ):
          rf.fit(X[..., np.newaxis], y)
      with pytest.raises(ValueError, match="X must be shape"):
          rf.fit(X[:, 0], y)
      with pytest.raises(
          ValueError, match="X and y do not have the same n_epo"
      ):
          rf.fit(
              X[:, np.newaxis],
              np.tile(y[:, np.newaxis, np.newaxis], [1, 2, 1]),
          )
      with pytest.raises(
          ValueError, match="X and y do not have the same n_tim"
      ):
          rf.fit(X, y[:-2])
      with pytest.raises(
          ValueError, match="n_features in X does not match"
      ):
          rf.fit(X[:, :1], y)
      # auto-naming features
      feature_names = ["feature_%s" % ii for ii in [0, 1, 2]]
      rf = ReceptiveField(
          tmin, tmax, 1, estimator=mod, feature_names=feature_names
      )
      assert_equal(rf.feature_names, feature_names)
      rf = ReceptiveField(tmin, tmax, 1, estimator=mod)
      rf.fit(X, y)
      assert_equal(rf.feature_names, None)
      # Float becomes ridge
      rf = ReceptiveField(
          tmin, tmax, 1, ["one", "two", "three"], estimator=0
      )
      str(rf)  # repr works before fit
      rf.fit(X, y)
      assert isinstance(rf.estimator_, TimeDelayingRidge)
      str(rf)  # repr works after fit
      rf = ReceptiveField(tmin, tmax, 1, ["one"], estimator=0)
      rf.fit(X[:, [0]], y)
      str(rf)  # repr with one feature
      # Should only accept estimators or floats
      with pytest.raises(
          ValueError, match="`estimator` must be a float or"
      ):
          ReceptiveField(tmin, tmax, 1, estimator="foo").fit(X, y)
      with pytest.raises(
          ValueError, match="`estimator` must be a float or"
      ):
          ReceptiveField(
              tmin, tmax, 1, estimator=np.array([1, 2, 3])
          ).fit(X, y)
      with pytest.raises(
          ValueError, match="tmin .* must be at most tmax"
      ):
          ReceptiveField(5, 4, 1).fit(X, y)
      # scorers
      for key, val in _SCORERS.items():
          rf = ReceptiveField(
              tmin,
              tmax,
              1,
              ["one"],
              estimator=0,
              scoring=key,
              patterns=True,
          )
          rf.fit(X[:, [0]], y)
          y_pred = rf.predict(X[:, [0]]).T.ravel()[:, np.newaxis]
          assert_allclose(
              val(y[:, np.newaxis], y_pred, multioutput="raw_values"),
              rf.score(X[:, [0]], y),
              rtol=1e-2,
          )
      with pytest.raises(ValueError, match="inputs must be shape"):
          _SCORERS["corrcoef"](
              y.ravel(), y_pred, multioutput="raw_values"
          )
      # Need correct scorers
      with pytest.raises(ValueError, match="scoring must be one of"):
          ReceptiveField(tmin, tmax, 1.0, scoring="foo").fit(X, y)
  
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 4 for calling a global function with example usage: test_receptive_field_basic(n_jobs) without return types