class_docstr: Actor that acts according to the Q-function.
class_docstr_tok: ["Actor","that","acts","according","to","the","Q-function","."]
code: def observe(self, obs, reward, done, reset):
      if self.training:
          self.t += 1
          assert self.last_state is not None
          assert self.last_action is not None
          # Add a transition to the replay buffer
          transition = {
              "state": self.last_state,
              "action": self.last_action,
              "reward": reward,
              "next_state": obs,
              "is_state_terminal": done,
          }
          if self.recurrent:
              transition["recurrent_state"] = recurrent_state_as_numpy(
                  get_recurrent_state_at(
                      self.train_prev_recurrent_states, 0, detach=True
                  )
              )
              self.train_prev_recurrent_states = None
              transition[
                  "next_recurrent_state"
              ] = recurrent_state_as_numpy(
                  get_recurrent_state_at(
                      self.train_recurrent_states, 0, detach=True
                  )
              )
          self._send_to_learner(transition, stop_episode=done or reset)
          if (done or reset) and self.recurrent:
              self.train_prev_recurrent_states = None
              self.train_recurrent_states = None
      else:
          if (done or reset) and self.recurrent:
              self.test_recurrent_states = None
  
file_path: pfrl/pfrl/agents/state_q_function_actor.py
imports: from logging import getLogger
  import torch
  from pfrl import agent
  from pfrl.utils import evaluating
  from pfrl.utils.batch_states import batch_states
  from pfrl.utils.recurrent import get_recurrent_state_at, one_step_forward, recurrent_state_as_numpy
label_desc: Use image node_id 6 for calling the StateQFunctionActor obj's underlying member method code with example usage: obj.observe(obs, reward, done, reset) without return types