class_docstr: A2C: Advantage Actor-Critic.
  
  A2C is a synchronous, deterministic variant of Asynchronous Advantage
      Actor Critic (A3C).
  
  See https://arxiv.org/abs/1708.05144
  
  Args:
      model (A2CModel): Model to train
      optimizer (chainer.Optimizer): optimizer used to train the model
      gamma (float): Discount factor [0,1]
      num_processes (int): The number of processes
      gpu (int): GPU device id if not None nor negative.
      update_steps (int): The number of update steps
      phi (callable): Feature extractor function
      pi_loss_coef (float): Weight coefficient for the loss of the policy
      v_loss_coef (float): Weight coefficient for the loss of the value
          function
      entropy_coeff (float): Weight coefficient for the loss of the entropy
      use_gae (bool): use generalized advantage estimation(GAE)
      tau (float): gae parameter
      average_actor_loss_decay (float): Decay rate of average actor loss.
          Used only to record statistics.
      average_entropy_decay (float): Decay rate of average entropy. Used only
          to record statistics.
      average_value_decay (float): Decay rate of average value. Used only
          to record statistics.
      act_deterministically (bool): If set true, choose most probable actions
          in act method.
      batch_states (callable): method which makes a batch of observations.
          default is `chainerrl.misc.batch_states.batch_states`
class_docstr_tok: ["A2C",":","Advantage","Actor-Critic",".","A2C","is","a","synchronous",",","deterministic","variant","of","Asynchronous","Advantage","Actor","Critic","(","A3C",")",".","See","https",":","\/\/arxiv.org\/abs\/1708.05144","Args",":","model","(","A2CModel",")",":","Model","to","train","optimizer","(","chainer.Optimizer",")",":","optimizer","used","to","train","the","model","gamma","(","float",")",":","Discount","factor","[","0,1","]","num_processes","(","int",")",":","The","number","of","processes","gpu","(","int",")",":","GPU","device","id","if","not","None","nor","negative",".","update_steps","(","int",")",":","The","number","of","update","steps","phi","(","callable",")",":","Feature","extractor","function","pi_loss_coef","(","float",")",":","Weight","coefficient","for","the","loss","of","the","policy","v_loss_coef","(","float",")",":","Weight","coefficient","for","the","loss","of","the","value","function","entropy_coeff","(","float",")",":","Weight","coefficient","for","the","loss","of","the","entropy","use_gae","(","bool",")",":","use","generalized","advantage","estimation","(","GAE",")","tau","(","float",")",":","gae","parameter","average_actor_loss_decay","(","float",")",":","Decay","rate","of","average","actor","loss",".","Used","only","to","record","statistics",".","average_entropy_decay","(","float",")",":","Decay","rate","of","average","entropy",".","Used","only","to","record","statistics",".","average_value_decay","(","float",")",":","Decay","rate","of","average","value",".","Used","only","to","record","statistics",".","act_deterministically","(","bool",")",":","If","set","true",",","choose","most","probable","actions","in","act","method",".","batch_states","(","callable",")",":","method","which","makes","a","batch","of","observations",".","default","is","`","chainerrl.misc.batch_states.batch_states","`"]
code: def _compute_returns(self, next_value):
      if self.use_gae:
          self.value_preds[-1] = next_value
          gae = 0
          for i in reversed(range(self.update_steps)):
              delta = (
                  self.rewards[i]
                  + self.gamma * self.value_preds[i + 1] * self.masks[i]
                  - self.value_preds[i]
              )
              gae = delta + self.gamma * self.tau * self.masks[i] * gae
              self.returns[i] = gae + self.value_preds[i]
      else:
          self.returns[-1] = next_value
          for i in reversed(range(self.update_steps)):
              self.returns[i] = (
                  self.rewards[i]
                  + self.gamma * self.returns[i + 1] * self.masks[i]
              )
  
imports: from logging import getLogger
  import warnings
  import chainer
  from chainer import functions
  from chainerrl import agent
  from chainerrl.misc.batch_states import batch_states
  from chainerrl.recurrent import RecurrentChainMixin
label_desc: Use image node_id 3 for calling the A2C obj's underlying member method code with example usage: obj._compute_returns(next_value) without return types