class_docstr: Controller.`
  Keep Track of each ship and shipyard
docstr: Compute returns for training value and policy network
  Args:
      reward (np.array) : reward
      terminal (np.array) : the flag of terminal
      next_value (float) :  the value of the last state 
      gamma (float) : coefficient for computing discount value
  Return:
      returns (np.array): discounted value
docstr_tok: ["Compute","returns","for","training","value","and","policy","network","Args",":","reward","(","np.array",")",":","reward","terminal","(","np.array",")",":","the","flag","of","terminal","next_value","(","float",")",":","the","value","of","the","last","state","gamma","(","float",")",":","coefficient","for","computing","discount","value","Return",":","returns","(","np.array",")",":","discounted","value"]
code: def compute_returns(self, reward, terminal, next_value, gamma):
      """Compute returns for training value and policy network
      Args:
          reward (np.array) : reward
          terminal (np.array) : the flag of terminal
          next_value (float) :  the value of the last state
          gamma (float) : coefficient for computing discount value
      Return:
          returns (np.array): discounted value
      """
      returns = np.ones(reward.shape)
      pre_r_sum = next_value
      for step in range(len(reward) - 1, -1, -1):
          returns[step] = (
              reward[step] + gamma * pre_r_sum * terminal[step]
          )
          pre_r_sum = returns[step]
  
      return returns
  
imports: import numpy
  from config import config
  from zerosum_env.envs.halite.helpers import *
  from .agent import Agent
  from .model import Model
  from .algorithm import PPO
  from .obs_parser import get_ship_feature
  from .replay_memory import ReplayMemory
  from .utils import is_alive, check_nearby_ship, nearest_shipyard_position, mahattan_distance
  from .policy import do_nothing_policy, move_up_policy, move_down_policy, move_left_policy, move_right_policy, spawn_policy, return_to_base_policy, mine_policy, convert_policy
label_desc: Use image node_id 14 for calling the Controller obj's underlying member method code with example usage: obj.compute_returns(reward, terminal, next_value, gamma) and returns: returns