code: def test_time_delay():
      """Test that time-delaying w/ times and samples works properly."""
      # Explicit delays + sfreq
      X = np.random.RandomState(0).randn(1000, 2)
      assert (X == 0).sum() == 0  # need this for later
      test_tlims = [
          ((1, 2), 1),
          ((1, 1), 1),
          ((0, 2), 1),
          ((0, 1), 1),
          ((0, 0), 1),
          ((-1, 2), 1),
          ((-1, 1), 1),
          ((-1, 0), 1),
          ((-1, -1), 1),
          ((-2, 2), 1),
          ((-2, 1), 1),
          ((-2, 0), 1),
          ((-2, -1), 1),
          ((-2, -1), 1),
          ((0, 0.2), 10),
          ((-0.1, 0.1), 10),
      ]
      for (tmin, tmax), isfreq in test_tlims:
          # sfreq must be int/float
          with pytest.raises(
              TypeError, match="`sfreq` must be an instance of"
          ):
              _delay_time_series(X, tmin, tmax, sfreq=[1])
          # Delays must be int/float
          with pytest.raises(TypeError, match=".*complex.*"):
              _delay_time_series(X, np.complex128(tmin), tmax, 1)
          # Make sure swapaxes works
          start, stop = (
              int(round(tmin * isfreq)),
              int(round(tmax * isfreq)) + 1,
          )
          n_delays = stop - start
          X_delayed = _delay_time_series(X, tmin, tmax, isfreq)
          assert_equal(X_delayed.shape, (1000, 2, n_delays))
          # Make sure delay slice is correct
          delays = _times_to_delays(tmin, tmax, isfreq)
          assert_array_equal(delays, np.arange(start, stop))
          keep = _delays_to_slice(delays)
          expected = np.where((X_delayed != 0).all(-1).all(-1))[0]
          got = np.arange(len(X_delayed))[keep]
          assert_array_equal(got, expected)
          assert X_delayed[keep].shape[-1] > 0
          assert (X_delayed[keep] == 0).sum() == 0
  
          del_zero = int(round(-tmin * isfreq))
          for ii in range(-2, 3):
              idx = del_zero + ii
              err_msg = f"[{tmin},{tmax}] ({isfreq}): {ii} {idx}"
              if 0 <= idx < X_delayed.shape[-1]:
                  if ii == 0:
                      assert_array_equal(
                          X_delayed[:, :, idx], X, err_msg=err_msg
                      )
                  elif ii < 0:  # negative delay
                      assert_array_equal(
                          X_delayed[:ii, :, idx],
                          X[-ii:, :],
                          err_msg=err_msg,
                      )
                      assert_array_equal(X_delayed[ii:, :, idx], 0.0)
                  else:
                      assert_array_equal(
                          X_delayed[ii:, :, idx],
                          X[:-ii, :],
                          err_msg=err_msg,
                      )
                      assert_array_equal(X_delayed[:ii, :, idx], 0.0)
  
imports: from pathlib import Path
  import numpy
  import pytest
  from numpy import einsum
  from numpy.fft import irfft, rfft
  from numpy.testing import assert_allclose, assert_array_equal, assert_equal
  from mne.decoding import ReceptiveField, TimeDelayingRidge
  from mne.decoding.receptive_field import _SCORERS, _delay_time_series, _delays_to_slice, _times_to_delays
  from mne.decoding.time_delaying_ridge import _compute_corrs, _compute_reg_neighbors
label_desc: Use image node_id 3 for calling a global function with example usage: test_time_delay() without return types