code: def test_xdawn_fit():
      """Test Xdawn fit."""
      # Get data
      raw, events, picks = _get_data()
      raw.del_proj()
      epochs = Epochs(
          raw,
          events,
          event_id,
          tmin,
          tmax,
          picks=picks,
          preload=True,
          baseline=None,
          verbose=False,
      )
      # =========== Basic Fit test =================
      # Test base xdawn
      xd = Xdawn(n_components=2, correct_overlap="auto")
      xd.fit(epochs)
      # With these parameters, the overlap correction must be False
      assert not xd.correct_overlap_
      # No overlap correction should give averaged evoked
      evoked = epochs["cond2"].average()
      assert_array_equal(evoked.data, xd.evokeds_["cond2"].data)
  
      assert_allclose(np.linalg.norm(xd.filters_["cond2"], axis=1), 1)
  
      # ========== with signal cov provided ====================
      # Provide covariance object
      signal_cov = compute_raw_covariance(raw, picks=picks)
      xd = Xdawn(
          n_components=2, correct_overlap=False, signal_cov=signal_cov
      )
      xd.fit(epochs)
      # Provide ndarray
      signal_cov = np.eye(len(picks))
      xd = Xdawn(
          n_components=2, correct_overlap=False, signal_cov=signal_cov
      )
      xd.fit(epochs)
      # Provide ndarray of bad shape
      signal_cov = np.eye(len(picks) - 1)
      xd = Xdawn(
          n_components=2, correct_overlap=False, signal_cov=signal_cov
      )
      pytest.raises(ValueError, xd.fit, epochs)
      # Provide another type
      signal_cov = 42
      xd = Xdawn(
          n_components=2, correct_overlap=False, signal_cov=signal_cov
      )
      pytest.raises(ValueError, xd.fit, epochs)
      # Fit with baseline correction and overlap correction should throw an
      # error
      # XXX This is a buggy test, the epochs here don't overlap
      epochs = Epochs(
          raw,
          events,
          event_id,
          tmin,
          tmax,
          picks=picks,
          preload=True,
          baseline=(None, 0),
          verbose=False,
      )
  
      xd = Xdawn(n_components=2, correct_overlap=True)
      pytest.raises(ValueError, xd.fit, epochs)
  
file_path: mne-python/mne/preprocessing/tests/test_xdawn.py
imports: from pathlib import Path
  import numpy
  import pytest
  from numpy.testing import assert_allclose, assert_array_almost_equal, assert_array_equal
  from scipy import stats
  from mne import Epochs, EpochsArray, compute_raw_covariance, create_info, pick_types, read_events
  from mne.decoding import Vectorizer
  from mne.fixes import _safe_svd
  from mne.io import read_raw_fif
  from mne.preprocessing.xdawn import Xdawn, _XdawnTransformer
label_desc: Use image node_id 4 for calling a global function with example usage: test_xdawn_fit() without return types