code: def test_unsupervised_spatial_filter():
      """Test unsupervised spatial filter."""
      pytest.importorskip("sklearn")
      from sklearn.decomposition import PCA
      from sklearn.kernel_ridge import KernelRidge
  
      raw = io.read_raw_fif(raw_fname)
      events = read_events(event_name)
      picks = pick_types(
          raw.info,
          meg=True,
          stim=False,
          ecg=False,
          eog=False,
          exclude="bads",
      )
      picks = picks[1:13:3]
      epochs = Epochs(
          raw,
          events,
          event_id,
          tmin,
          tmax,
          picks=picks,
          preload=True,
          baseline=None,
          verbose=False,
      )
  
      # Test estimator
      pytest.raises(
          ValueError, UnsupervisedSpatialFilter, KernelRidge(2)
      )
  
      # Test fit
      X = epochs.get_data(copy=False)
      n_components = 4
      usf = UnsupervisedSpatialFilter(PCA(n_components))
      usf.fit(X)
      usf1 = UnsupervisedSpatialFilter(PCA(n_components))
  
      # test transform
      assert_equal(usf.transform(X).ndim, 3)
      # test fit_transform
      assert_array_almost_equal(usf.transform(X), usf1.fit_transform(X))
      assert_equal(usf.transform(X).shape[1], n_components)
      assert_array_almost_equal(
          usf.inverse_transform(usf.transform(X)), X
      )
  
      # Test with average param
      usf = UnsupervisedSpatialFilter(PCA(4), average=True)
      usf.fit_transform(X)
      pytest.raises(ValueError, UnsupervisedSpatialFilter, PCA(4), 2)
  
file_path: mne-python/mne/decoding/tests/test_transformer.py
imports: from pathlib import Path
  import numpy
  import pytest
  from numpy.testing import assert_allclose, assert_array_almost_equal, assert_array_equal, assert_equal
  from mne import Epochs, io, pick_types, read_events
  from mne.decoding import FilterEstimator, PSDEstimator, Scaler, TemporalFilter, UnsupervisedSpatialFilter, Vectorizer
  from mne.defaults import DEFAULTS
  from mne.utils import check_version, use_log_level
label_desc: Use image node_id 5 for calling a global function with example usage: test_unsupervised_spatial_filter() without return types