code: def clf_transform(spfilt, X, labels, n_matrices, n_channels, n_times):
      n_classes = len(np.unique(labels))
      if spfilt is BilinearFilter:
          n_filters = 4
          sf = spfilt(filters=np.eye(n_filters, n_channels))
      elif spfilt is AJDC:
          sf = spfilt(dim_red={"expl_var": 0.9})
      else:
          sf = spfilt()
      if spfilt is AJDC:
          sf.fit(X, labels)
          X_new = np.squeeze(X[0])
          n_matrices = X_new.shape[0]
          Xtr = sf.transform(X_new)
      else:
          Xtr = sf.fit(X, labels).transform(X)
  
      if spfilt is AJDC:
          assert Xtr.shape == (n_matrices, n_channels, n_times)
      elif spfilt is BilinearFilter:
          assert Xtr.shape == (n_matrices, n_filters, n_filters)
      elif spfilt is Xdawn:
          n_components = min(n_channels, sf.nfilter)
          assert Xtr.shape == (
              n_matrices,
              n_classes * n_components,
              n_times,
          )
      else:
          n_components = min(n_channels, sf.nfilter)
          assert Xtr.shape == (n_matrices, n_components)
  
imports: from conftest import get_metrics
  import pytest
  import numpy
  from numpy.testing import assert_array_equal
  from pyriemann.spatialfilters import Xdawn, CSP, SPoC, BilinearFilter, AJDC
label_desc: Use image node_id 4 for calling a global function with example usage: clf_transform(spfilt, X, labels, n_matrices, n_channels, n_times) without return types