code: def test_generalization_light():
      """Test GeneralizingEstimator."""
      from sklearn.linear_model import LogisticRegression
      from sklearn.metrics import roc_auc_score
      from sklearn.pipeline import make_pipeline
  
      logreg = LogisticRegression(
          solver="liblinear", multi_class="ovr", random_state=0
      )
  
      X, y = make_data()
      n_epochs, _, n_time = X.shape
      # fit
      gl = GeneralizingEstimator(logreg)
      assert_equal(repr(gl)[:23], "<GeneralizingEstimator(")
      gl.fit(X, y)
      gl.fit(X, y, sample_weight=np.ones_like(y))
  
      assert_equal(gl.__repr__()[-28:], ", fitted with 10 estimators>")
      # transforms
      y_pred = gl.predict(X)
      assert_array_equal(y_pred.shape, [n_epochs, n_time, n_time])
      assert y_pred.dtype == np.dtype(int)
      y_proba = gl.predict_proba(X)
      assert y_proba.dtype == np.dtype(float)
      assert_array_equal(y_proba.shape, [n_epochs, n_time, n_time, 2])
  
      # transform to different datasize
      y_pred = gl.predict(X[:, :, :2])
      assert_array_equal(y_pred.shape, [n_epochs, n_time, 2])
  
      # score
      score = gl.score(X[:, :, :3], y)
      assert_array_equal(score.shape, [n_time, 3])
      assert np.sum(np.abs(score)) != 0
      assert score.dtype == np.dtype(float)
  
      gl = GeneralizingEstimator(logreg, scoring="roc_auc")
      gl.fit(X, y)
      score = gl.score(X, y)
      auc = roc_auc_score(
          y, gl.estimators_[0].predict_proba(X[..., 0])[..., 1]
      )
      assert_equal(score[0, 0], auc)
  
      for scoring in ["foo", 999]:
          gl = GeneralizingEstimator(logreg, scoring=scoring)
          gl.fit(X, y)
          pytest.raises((ValueError, TypeError), gl.score, X, y)
  
      # Check sklearn's roc_auc fix: scikit-learn/scikit-learn#6874
      # -- 3 class problem
      gl = GeneralizingEstimator(logreg, scoring="roc_auc")
      y = np.arange(len(X)) % 3
      gl.fit(X, y)
      pytest.raises(ValueError, gl.score, X, y)
      # -- 2 class problem not in [0, 1]
      y = np.arange(len(X)) % 2 + 1
      gl.fit(X, y)
      score = gl.score(X, y)
      manual_score = [
          [roc_auc_score(y - 1, _y_pred) for _y_pred in _y_preds]
          for _y_preds in gl.decision_function(X).transpose(1, 2, 0)
      ]
      assert_array_equal(score, manual_score)
  
      # n_jobs
      gl = GeneralizingEstimator(logreg, n_jobs=2)
      gl.fit(X, y)
      y_pred = gl.predict(X)
      assert_array_equal(y_pred.shape, [n_epochs, n_time, n_time])
      score = gl.score(X, y)
      assert_array_equal(score.shape, [n_time, n_time])
  
      # n_jobs > n_estimators
      gl.fit(X[..., [0]], y)
      gl.predict(X[..., [0]])
  
      # n-dimensional feature space
      X = np.random.rand(10, 3, 4, 2)
      y = np.arange(10) % 2
      y_preds = list()
      for n_jobs in [1, 2]:
          pipe = GeneralizingEstimator(
              make_pipeline(Vectorizer(), logreg), n_jobs=n_jobs
          )
          y_preds.append(pipe.fit(X, y).predict(X))
          features_shape = (
              pipe.estimators_[0].steps[0][1].features_shape_
          )
          assert_array_equal(features_shape, [3, 4])
      assert_array_equal(y_preds[0], y_preds[1])
  
file_path: mne-python/mne/decoding/tests/test_search_light.py
imports: import platform
  from inspect import signature
  import numpy
  import pytest
  from numpy.testing import assert_array_equal, assert_equal
  from mne.decoding.search_light import GeneralizingEstimator, SlidingEstimator
  from mne.decoding.transformer import Vectorizer
  from mne.utils import _record_warnings, check_version, use_log_level
label_desc: Use image node_id 3 for calling a global function with example usage: test_generalization_light() without return types