docstr: return obs, action, reward, isOver,
  note that some frames in obs may be generated from last episode,
  they should be removed from obs
docstr_tok: ["return","obs",",","action",",","reward",",","isOver",",","note","that","some","frames","in","obs","may","be","generated","from","last","episode",",","they","should","be","removed","from","obs"]
code: def sample(self, idx):
      """return obs, action, reward, isOver,
      note that some frames in obs may be generated from last episode,
      they should be removed from obs
      """
      obs = np.zeros(
          (self.context_len + 1,) + self.obs_shape, dtype=np.uint8
      )
      obs_idx = (
          np.arange(idx, idx + self.context_len + 1) % self._curr_size
      )
  
      # confirm that no frame was generated from last episode
      has_last_episode = False
      for k in range(self.context_len - 2, -1, -1):
          to_check_idx = obs_idx[k]
          if self.isOver[to_check_idx]:
              has_last_episode = True
              obs_idx = obs_idx[k + 1 :]
              obs[k + 1 :] = self.obs[obs_idx]
              break
  
      if not has_last_episode:
          obs = self.obs[obs_idx]
  
      real_idx = (idx + self.context_len - 1) % self._curr_size
      action = self.action[real_idx]
      reward = self.reward[real_idx]
      isOver = self.isOver[real_idx]
      return obs, reward, action, isOver
  
file_path: PARL/benchmark/torch/dqn/replay_memory.py
imports: import numpy
  import copy
  from collections import deque, namedtuple
label_desc: Use image node_id 4 for calling the ReplayMemory obj's underlying member method code with example usage: obj.sample(idx) and returns: obs,  reward,  action,  isOver