code: def sample_batch_indexes(low, high, size):
      if high - low >= size:
          # We have enough data. Draw without replacement, that is each index is unique in the
          # batch. We cannot use `np.random.choice` here because it is horribly inefficient as
          # the memory grows. See https://github.com/numpy/numpy/issues/2764 for a discussion.
          # `random.sample` does the same thing (drawing without replacement) and is way faster.
          r = range(low, high)
          batch_idxs = random.sample(r, size)
      else:
          # Not enough data. Help ourselves with sampling from the range, but the same index
          # can occur multiple times. This is not good and should be avoided by picking a
          # large enough warm-up phase.
          warnings.warn(
              "Not enough entries to sample without replacement. "
              "Consider increasing your warm-up phase to avoid oversampling!"
          )
          batch_idxs = np.random.random_integers(
              low, high - 1, size=size
          )
      assert len(batch_idxs) == size
      return batch_idxs
  
imports: from __future__ import absolute_import
  from collections import deque, namedtuple
  import warnings
  import random
  import numpy
label_desc: Use image node_id 1 for calling a global function with example usage: sample_batch_indexes(low, high, size) and returns: batch_idxs