class_docstr: Experience Replay Buffer
  
  As described in
  https://storage.googleapis.com/deepmind-media/dqn/DQNNaturePaper.pdf.
  
  Args:
      capacity (int): capacity in terms of number of transitions
      num_steps (int): Number of timesteps per stored transition
          (for N-step updates)
class_docstr_tok: ["Experience","Replay","Buffer","As","described","in","https",":","\/\/storage.googleapis.com\/deepmind-media\/dqn\/DQNNaturePaper.pdf",".","Args",":","capacity","(","int",")",":","capacity","in","terms","of","number","of","transitions","num_steps","(","int",")",":","Number","of","timesteps","per","stored","transition","(","for","N-step","updates",")"]
code: def append(
      self,
      state,
      action,
      reward,
      next_state=None,
      next_action=None,
      is_state_terminal=False,
      env_id=0,
      **kwargs,
  ):
      last_n_transitions = self.last_n_transitions[env_id]
      experience = dict(
          state=state,
          action=action,
          reward=reward,
          next_state=next_state,
          next_action=next_action,
          is_state_terminal=is_state_terminal,
          **kwargs,
      )
      last_n_transitions.append(experience)
      if is_state_terminal:
          while last_n_transitions:
              self.memory.append(list(last_n_transitions))
              del last_n_transitions[0]
          assert len(last_n_transitions) == 0
      else:
          if len(last_n_transitions) == self.num_steps:
              self.memory.append(list(last_n_transitions))
  
file_path: pfrl/pfrl/replay_buffers/replay_buffer.py
imports: import collections
  import pickle
  from typing import Optional
  from pfrl import replay_buffer
  from pfrl.collections.random_access_queue import RandomAccessQueue
label_desc: Use image node_id 2 for calling the ReplayBuffer obj's underlying member method code with example usage: obj.append(state, action, reward, next_state, next_action, is_state_terminal, env_id) without return types