code: def test_sorting():
      """Test sorting learning during training."""
      X, _, _ = simulate_data(
          n_trials=100, n_channels=20, n_samples=500
      )
      # Epoch length is 1 second
      X = np.reshape(X, (100, 20, 500))
      # split data
      Xtr, Xte = X[:80], X[80:]
      sf = 250
      n_channels = Xtr.shape[1]
      info = create_info(ch_names=n_channels, sfreq=sf, ch_types="eeg")
  
      filt_params_signal = dict(
          l_freq=freqs_sig[0],
          h_freq=freqs_sig[1],
          l_trans_bandwidth=4,
          h_trans_bandwidth=4,
      )
      filt_params_noise = dict(
          l_freq=freqs_noise[0],
          h_freq=freqs_noise[1],
          l_trans_bandwidth=4,
          h_trans_bandwidth=4,
      )
  
      # check sort_by_spectral_ratio set to False
      ssd = SSD(
          info,
          filt_params_signal,
          filt_params_noise,
          n_components=None,
          sort_by_spectral_ratio=False,
      )
      ssd.fit(Xtr)
      _, sorter_tr = ssd.get_spectral_ratio(ssd.transform(Xtr))
      _, sorter_te = ssd.get_spectral_ratio(ssd.transform(Xte))
      assert any(sorter_tr != sorter_te)
  
      # check sort_by_spectral_ratio set to True
      ssd = SSD(
          info,
          filt_params_signal,
          filt_params_noise,
          n_components=None,
          sort_by_spectral_ratio=True,
      )
      ssd.fit(Xtr)
  
      # check sorters
      sorter_in = ssd.sorter_spec
      ssd = SSD(
          info,
          filt_params_signal,
          filt_params_noise,
          n_components=None,
          sort_by_spectral_ratio=False,
      )
      ssd.fit(Xtr)
      _, sorter_out = ssd.get_spectral_ratio(ssd.transform(Xtr))
  
      assert all(sorter_in == sorter_out)
  
file_path: mne-python/mne/decoding/tests/test_ssd.py
imports: import numpy
  import pytest
  from numpy.testing import assert_array_almost_equal, assert_array_equal
  from mne import create_info, io
  from mne.decoding import CSP
  from mne.decoding.ssd import SSD
  from mne.filter import filter_data
  from mne.time_frequency import psd_array_welch
label_desc: Use image node_id 5 for calling a global function with example usage: test_sorting() without return types