code: def _gamma_difference_hrf(
      tr,
      oversampling=50,
      time_length=32.0,
      onset=0.0,
      delay=6,
      undershoot=16.0,
      dispersion=1.0,
      u_dispersion=1.0,
      ratio=0.167,
  ):
      """Compute an hrf as the difference of two gamma functions.
  
      Parameters
      ----------
      tr : float
          :term:`Repetition time<TR>`, in seconds (sampling period).
  
      oversampling : int, default=50
          Temporal oversampling factor.
  
      time_length : float, default=32
          hrf kernel length, in seconds.
  
      onset : float, default=0
          Onset time of the hrf.
  
      delay : float, default=6
          Delay parameter of the hrf (in s.).
  
      undershoot : float, default=16
          Undershoot parameter of the hrf (in s.).
  
      dispersion : float, default=1
          Dispersion parameter for the first gamma function.
  
      u_dispersion : float, default=1
          Dispersion parameter for the second gamma function.
  
      ratio : float, default=0.167
          Ratio of the two gamma components.
  
      Returns
      -------
      hrf : array of shape(length / tr * oversampling, dtype=float)
           hrf sampling on the oversampled time grid
  
      """
      dt = tr / oversampling
      time_stamps = np.linspace(
          0, time_length, np.rint(float(time_length) / dt).astype(int)
      )
      time_stamps -= onset
  
      # define peak and undershoot gamma functions
      peak_gamma = gamma.pdf(
          time_stamps, delay / dispersion, loc=dt, scale=dispersion
      )
      undershoot_gamma = gamma.pdf(
          time_stamps,
          undershoot / u_dispersion,
          loc=dt,
          scale=u_dispersion,
      )
  
      # calculate the hrf
      hrf = peak_gamma - ratio * undershoot_gamma
      hrf /= hrf.sum()
      return hrf
  
imports: import warnings
  from collections.abc import Iterable
  import numpy
  from scipy.stats import gamma
  from nilearn._utils import fill_doc
label_desc: Use image node_id 1 for calling a global function with example usage: _gamma_difference_hrf(tr, oversampling, time_length, onset, delay, undershoot, dispersion, u_dispersion, ratio) and returns: hrf