class_docstr: PPO Model
class_docstr_tok: ["PPO","Model"]
docstr: Compute the rewards of the trials in trials_info based on trials_result,
  and update the rewards in trials_info
  
  Parameters
  ----------
  trials_info : TrialsInfo
      Info of the generated trials
  trials_result : list
      Final results (e.g., acc) of the generated trials
docstr_tok: ["Compute","the","rewards","of","the","trials","in","trials_info","based","on","trials_result",",","and","update","the","rewards","in","trials_info","Parameters","--","--","--","--","--","trials_info",":","TrialsInfo","Info","of","the","generated","trials","trials_result",":","list","Final","results","(","e.g.",",","acc",")","of","the","generated","trials"]
code: def compute_rewards(self, trials_info, trials_result):
      """
      Compute the rewards of the trials in trials_info based on trials_result,
      and update the rewards in trials_info
  
      Parameters
      ----------
      trials_info : TrialsInfo
          Info of the generated trials
      trials_result : list
          Final results (e.g., acc) of the generated trials
      """
      mb_rewards = np.asarray(
          [trials_result for _ in trials_info.actions], dtype=np.float32
      )
      # discount/bootstrap off value fn
      mb_returns = np.zeros_like(mb_rewards)
      mb_advs = np.zeros_like(mb_rewards)
      lastgaelam = 0
      last_dones = np.asarray(
          [True for _ in trials_result], dtype=bool
      )  # ugly
      for t in reversed(range(self.model_config.nsteps)):
          if t == self.model_config.nsteps - 1:
              nextnonterminal = 1.0 - last_dones
              nextvalues = trials_info.last_value
          else:
              nextnonterminal = 1.0 - trials_info.dones[t + 1]
              nextvalues = trials_info.values[t + 1]
          delta = (
              mb_rewards[t]
              + self.model_config.gamma * nextvalues * nextnonterminal
              - trials_info.values[t]
          )
          lastgaelam = (
              delta
              + self.model_config.gamma
              * self.model_config.lam
              * nextnonterminal
              * lastgaelam
          )
          mb_advs[
              t
          ] = lastgaelam  # pylint: disable=unsupported-assignment-operation
      mb_returns = mb_advs + trials_info.values
  
      trials_info.update_rewards(mb_rewards, mb_returns)
      trials_info.convert_shape()
  
imports: import copy
  import logging
  import numpy
  from gym import spaces
  from schema import Schema, Optional
  import nni
  from nni import ClassArgsValidator
  from nni.tuner import Tuner
  from nni.utils import OptimizeMode, extract_scalar_reward
  from .model import Model
  from .util import set_global_seeds
  from .policy import build_lstm_policy
label_desc: Use image node_id 3 for calling the PPOModel obj's underlying member method code with example usage: obj.compute_rewards(trials_info, trials_result) without return types