code: def discount_with_dones(rewards, dones, gamma):
      discounted = []
      r = 0
      for reward, done in zip(rewards[::-1], dones[::-1]):
          r = reward + gamma * r * (1.0 - done)  # fixed off by one bug
          discounted.append(r)
      return discounted[::-1]
  
imports: import os
  import numpy
  import tensorflow
  from collections import deque
label_desc: Use image node_id 13 for calling a global function with example usage: discount_with_dones(rewards, dones, gamma) and returns: discounted