code: def ptb_iterator_memnet(data, batch_size, memory_size):
      """Iterates through the ptb data."""
      data_length = len(data)
      length = data_length - memory_size
      order = list(range(length))
      np.random.shuffle(order)
  
      data = np.asarray(data)
  
      for i in range(0, length, batch_size):
          x, y = [], []
          for j in range(i, min(i + batch_size, length)):
              idx = order[j]
              x.append(data[idx : idx + memory_size])
              y.append(data[idx + memory_size])
          x, y = np.asarray(x), np.asarray(y)
          yield (x, y)
  
imports: import os
  import numpy
  import tensorflow
  import texar.tf
label_desc: Use image node_id 2 for calling a global function with example usage: ptb_iterator_memnet(data, batch_size, memory_size) without return types