class_docstr: A3C: Asynchronous Advantage Actor-Critic.
  
  See http://arxiv.org/abs/1602.01783
  
  Args:
      model (A3CModel): Model to train
      optimizer (chainer.Optimizer): optimizer used to train the model
      t_max (int): The model is updated after every t_max local steps
      gamma (float): Discount factor [0,1]
      beta (float): Weight coefficient for the entropy regularizaiton term.
      process_idx (int): Index of the process.
      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
      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: ["A3C",":","Asynchronous","Advantage","Actor-Critic",".","See","http",":","\/\/arxiv.org\/abs\/1602.01783","Args",":","model","(","A3CModel",")",":","Model","to","train","optimizer","(","chainer.Optimizer",")",":","optimizer","used","to","train","the","model","t_max","(","int",")",":","The","model","is","updated","after","every","t_max","local","steps","gamma","(","float",")",":","Discount","factor","[","0,1","]","beta","(","float",")",":","Weight","coefficient","for","the","entropy","regularizaiton","term",".","process_idx","(","int",")",":","Index","of","the","process",".","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","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 act_and_train(self, obs, reward):
      statevar = self.batch_states([obs], np, self.phi)
  
      self.past_rewards[self.t - 1] = reward
  
      if self.t - self.t_start == self.t_max:
          self.update(statevar)
  
      self.past_states[self.t] = statevar
      pout, vout = self.model.pi_and_v(statevar)
      action = (
          pout.sample().array
      )  # Do not backprop through sampled actions
      self.past_action_log_prob[self.t] = pout.log_prob(action)
      self.past_action_entropy[self.t] = pout.entropy
      self.past_values[self.t] = vout
      self.t += 1
      action = action[0]
      if self.process_idx == 0:
          logger.debug(
              "t:%s r:%s a:%s pout:%s", self.t, reward, action, pout
          )
      # Update stats
      self.average_value += (1 - self.average_value_decay) * (
          float(vout.array[0]) - self.average_value
      )
      self.average_entropy += (1 - self.average_entropy_decay) * (
          float(pout.entropy.array[0]) - self.average_entropy
      )
      return action
  
imports: import copy
  from logging import getLogger
  import chainer
  from chainer import functions
  import numpy
  from chainerrl import agent
  from chainerrl.misc import async_
  from chainerrl.misc.batch_states import batch_states
  from chainerrl.misc import copy_param
  from chainerrl.recurrent import Recurrent
  from chainerrl.recurrent import RecurrentChainMixin
  from chainerrl.recurrent import state_kept
label_desc: Use image node_id 5 for calling the A3C obj's underlying member method code with example usage: obj.act_and_train(obs, reward) and returns: action