code: def discount_rewards(r):
      """take 1D float array of rewards and compute discounted reward"""
      discounted_r = np.zeros_like(r)
      running_add = 0
      for t in reversed(range(0, r.size)):
          # Reset the sum, since this was a game boundary (pong specific!).
          if r[t] != 0:
              running_add = 0
          running_add = running_add * gamma + r[t]
          discounted_r[t] = running_add
      return discounted_r
  
file_path: BigDL/python/orca/example/ray_on_spark/rl_pong/rl_pong.py
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import argparse
  import os
  import time
  import gym
  import numpy
  import ray
  from bigdl.orca import init_orca_context, stop_orca_context
  from bigdl.orca import OrcaContext
label_desc: Use image node_id 3 for calling a global function with example usage: discount_rewards(r) and returns: discounted_r