code: def discount_cumsum(x, discount):
      """Discounted cumulative sum.
  
      See https://docs.scipy.org/doc/scipy/reference/tutorial/signal.html#difference-equation-filtering  # noqa: E501
      Here, we have y[t] - discount*y[t+1] = x[t]
      or rev(y)[t] - discount*rev(y)[t-1] = rev(x)[t]
  
      Args:
          x (np.ndarrary): Input.
          discount (float): Discount factor.
  
      Returns:
          np.ndarrary: Discounted cumulative sum.
  
  
      """
      return scipy.signal.lfilter(
          [1], [1, float(-discount)], x[::-1], axis=-1
      )[::-1]
  
file_path: garage/src/garage/np/_functions.py
imports: import warnings
  import numpy
  import scipy.signal
label_desc: Use image node_id 4 for calling a global function with example usage: discount_cumsum(x, discount) and returns: scipy