class_docstr: Implement experience replay in the paper
  `Human-level control through deep reinforcement learning
  <http://www.nature.com/nature/journal/v518/n7540/full/nature14236.html>`_.
  
  This implementation provides the interface as a :class:`DataFlow`.
  This DataFlow is __not__ fork-safe (thus doesn't support multiprocess prefetching).
  
  It does the following:
  * Spawn `num_parallel_players` environment thread, each running an instance
    of the environment with epislon-greedy policy.
  * All environment instances writes their experiences to a shared replay
    memory buffer.
  * Produces batched samples by sampling the replay buffer. After producing
    each batch, it executes the environment instances by a total of
    `update_frequency` steps.
  
  This implementation assumes that state is batch-able, and the network takes batched inputs.
class_docstr_tok: ["Implement","experience","replay","in","the","paper","`","Human-level","control","through","deep","reinforcement","learning","<","http",":","\/\/www.nature.com\/nature\/journal\/v518\/n7540\/full\/nature14236.html",">","`","_",".","This","implementation","provides","the","interface","as","a",":","class",":","`","DataFlow","`",".","This","DataFlow","is","__not__","fork-safe","(","thus","does","n't","support","multiprocess","prefetching",")",".","It","does","the","following",":","*","Spawn","`","num_parallel_players","`","environment","thread",",","each","running","an","instance","of","the","environment","with","epislon-greedy","policy",".","*","All","environment","instances","writes","their","experiences","to","a","shared","replay","memory","buffer",".","*","Produces","batched","samples","by","sampling","the","replay","buffer",".","After","producing","each","batch",",","it","executes","the","environment","instances","by","a","total","of","`","update_frequency","`","steps",".","This","implementation","assumes","that","state","is","batch-able",",","and","the","network","takes","batched","inputs","."]
code: def _debug_sample(self, sample):
      import cv2
  
      def view_state(comb_state):
          # this function assumes comb_state is 3D
          state = comb_state[:, :, :-1]
          next_state = comb_state[:, :, 1:]
          r = np.concatenate(
              [state[:, :, k] for k in range(self.history_len)], axis=1
          )
          r2 = np.concatenate(
              [next_state[:, :, k] for k in range(self.history_len)],
              axis=1,
          )
          r = np.concatenate([r, r2], axis=0)
          cv2.imshow("state", r)
          cv2.waitKey()
  
      print(
          "Act: ",
          sample[2],
          " reward:",
          sample[1],
          " isOver: ",
          sample[3],
      )
      if sample[1] or sample[3]:
          view_state(sample[0])
  
imports: import copy
  import itertools
  import numpy
  import threading
  from collections import namedtuple
  from six.moves import queue, range
  from tensorpack.utils.concurrency import LoopThread, ShareSessionThread
  from tensorpack.callbacks.base import Callback
  from tensorpack.dataflow import DataFlow
  from tensorpack.utils import logger, get_rng, get_tqdm
  from tensorpack.utils.stats import StatCounter
label_desc: Use image node_id 4 for calling the ExpReplay obj's underlying member method code with example usage: obj._debug_sample(sample) without return types