class_docstr: Replay memory to store samples of experience.
  
  Each transition is represented as (state, action, reward, next_state,
  priority) tuple. 'priority' is ignored for non-prioritized experience
  replay.
class_docstr_tok: ["Replay","memory","to","store","samples","of","experience",".","Each","transition","is","represented","as","(","state",",","action",",","reward",",","next_state",",","priority",")","tuple",".","'priority","'","is","ignored","for","non-prioritized","experience","replay","."]
code: def _sample_with_priority(self, p):
      parent = 0
      while True:
          left = 2 * parent + 1
          if left >= len(self._memory):
              # parent points to a leaf node already.
              return parent
  
          left_p = (
              self._memory[left]
              if left < self._capacity - 1
              else self._memory[left].priority
          )
          if p <= left_p:
              parent = left
          else:
              if left + 1 >= len(self._memory):
                  raise RuntimeError(
                      "Right child is expected to exist."
                  )
              p -= left_p
              parent = left + 1
  
file_path: CNTK/bindings/python/cntk/contrib/deeprl/agent/shared/replay_memory.py
imports: from __future__ import division
  import math
  import random
  from collections import namedtuple
label_desc: Use image node_id 10 for calling the ReplayMemory obj's underlying member method code with example usage: obj._sample_with_priority(p) and returns: parent