code: def test_hkernel():
      """Test the hrf computation."""
      tr = 2.0
  
      h = _hrf_kernel("spm", tr)
      assert_almost_equal(h[0], spm_hrf(tr))
  
      h = _hrf_kernel("spm + derivative", tr)
      assert_almost_equal(h[1], spm_time_derivative(tr))
  
      h = _hrf_kernel("spm + derivative + dispersion", tr)
      assert_almost_equal(h[2], spm_dispersion_derivative(tr))
  
      h = _hrf_kernel("glover", tr)
      assert_almost_equal(h[0], glover_hrf(tr))
  
      h = _hrf_kernel("glover + derivative", tr)
      assert_almost_equal(h[1], glover_time_derivative(tr))
      assert_almost_equal(h[0], glover_hrf(tr))
  
      h = _hrf_kernel("glover + derivative + dispersion", tr)
      assert_almost_equal(h[2], glover_dispersion_derivative(tr))
      assert_almost_equal(h[1], glover_time_derivative(tr))
      assert_almost_equal(h[0], glover_hrf(tr))
  
      h = _hrf_kernel("fir", tr, fir_delays=np.arange(4))
      for dh in h:
          assert_almost_equal(dh.sum(), 1.0)
  
      h = _hrf_kernel(None, tr)
      assert_almost_equal(h[0], np.hstack((1, np.zeros(49))))
  
      with pytest.raises(
          ValueError,
          match="Could not process custom HRF model provided.",
      ):
          _hrf_kernel(lambda x: np.ones(int(x)), tr)
          _hrf_kernel([lambda x, y, z: x + y + z], tr)
          _hrf_kernel([lambda x: np.ones(int(x))] * 2, tr)
  
      h = _hrf_kernel(lambda tr, ov: np.ones(int(tr * ov)), tr)
      assert_almost_equal(h[0], np.ones(100))
  
      h = _hrf_kernel([lambda tr, ov: np.ones(int(tr * ov))], tr)
      assert_almost_equal(h[0], np.ones(100))
      with pytest.raises(ValueError, match="is not a known hrf model."):
          _hrf_kernel("foo", tr)
  
imports: import warnings
  import numpy
  import pytest
  from numpy.testing import assert_almost_equal, assert_array_almost_equal, assert_array_equal
  from nilearn.glm.first_level.hemodynamic_models import _calculate_tr, _hrf_kernel, _regressor_names, _resample_regressor, _sample_condition, compute_regressor, glover_dispersion_derivative, glover_hrf, glover_time_derivative, orthogonalize, spm_dispersion_derivative, spm_hrf, spm_time_derivative
label_desc: Use image node_id 18 for calling a global function with example usage: test_hkernel() without return types