code: def policy_backward(eph, epx, epdlogp, model):
      """backward pass. (eph is array of intermediate hidden states)"""
      # the way to change the policy parameters is to
      # do some rollouts, take the gradient of the sampled actions
      #  multiply it by the score and add everything
      dW2 = np.dot(eph.T, epdlogp).ravel()
      dh = np.outer(epdlogp, model["W2"])
      # Backprop relu.
      dh[eph <= 0] = 0
      dW1 = np.dot(dh.T, epx)
      return {"W1": dW1, "W2": dW2}
  
file_path: analytics-zoo/pyzoo/zoo/examples/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 zoo.orca import init_orca_context, stop_orca_context
  from zoo.orca import OrcaContext
label_desc: Use image node_id 5 for calling a global function with example usage: policy_backward(eph, epx, epdlogp, model) and returns: dict