code: def calc_discount_sum_rewards(rewards, gamma):
      """Calculate discounted forward sum of a sequence at each point.
  
      Args:
          rewards (List/Tuple/np.array): rewards of (s_t, s_{t+1}, ..., s_T)
          gamma (Scalar): gamma coefficient
  
      Returns:
          np.array: discounted sum rewards of (s_t, s_{t+1}, ..., s_T)
      """
      return scipy.signal.lfilter([1.0], [1.0, -gamma], rewards[::-1])[
          ::-1
      ]
  
imports: import numpy
  import scipy.signal
label_desc: Use image node_id 1 for calling a global function with example usage: calc_discount_sum_rewards(rewards, gamma) and returns: scipy