code: def discount_cumsum(x: np.ndarray, gamma: float) -> np.ndarray:
      """Calculates the discounted cumulative sum over a reward sequence `x`.
  
      y[t] - discount*y[t+1] = x[t]
      reversed(y)[t] - discount*reversed(y)[t-1] = reversed(x)[t]
  
      Args:
          gamma: The discount factor gamma.
  
      Returns:
          The sequence containing the discounted cumulative sums
          for each individual reward in `x` till the end of the trajectory.
  
       .. testcode::
          :skipif: True
  
          x = np.array([0.0, 1.0, 2.0, 3.0])
          gamma = 0.9
          discount_cumsum(x, gamma)
  
      .. testoutput::
  
          array([0.0 + 0.9*1.0 + 0.9^2*2.0 + 0.9^3*3.0,
                 1.0 + 0.9*2.0 + 0.9^2*3.0,
                 2.0 + 0.9*3.0,
                 3.0])
      """
      return scipy.signal.lfilter(
          [1], [1, float(-gamma)], x[::-1], axis=0
      )[::-1]
  
file_path: ray/rllib/evaluation/postprocessing.py
imports: import numpy
  import scipy.signal
  from typing import Dict, Optional
  from ray.rllib.evaluation.episode import Episode
  from ray.rllib.policy.policy import Policy
  from ray.rllib.policy.sample_batch import SampleBatch
  from ray.rllib.utils.annotations import DeveloperAPI
  from ray.rllib.utils.nested_dict import NestedDict
  from ray.rllib.utils.numpy import convert_to_numpy
  from ray.rllib.utils.torch_utils import convert_to_torch_tensor
  from ray.rllib.utils.typing import AgentID
  from ray.rllib.utils.typing import TensorType
label_desc: Use image node_id 5 for calling a global function with example usage: discount_cumsum(x, gamma) and returns: scipy