class_docstr: Keras-compatible data generator to use with Keras methods :meth:`keras.Model.fit`,
  :meth:`keras.Model.evaluate`, and :meth:`keras.Model.predict`
  
  This class generates data samples for link inference models
  and should be created using the :meth:`flow` method of
  :class:`.GraphSAGELinkGenerator` or :class:`.Attri2VecLinkGenerator`.
  
  Args:
      sample_function (Callable): A function that returns features for supplied head nodes.
      sampler (UnsupersizedSampler):  An object that encapsulates the neighbourhood sampling of a graph.
          The generator method of this class returns a batch of positive and negative samples on demand.
class_docstr_tok: ["Keras-compatible","data","generator","to","use","with","Keras","methods",":","meth",":","`","keras.Model.fit","`",",",":","meth",":","`","keras.Model.evaluate","`",",","and",":","meth",":","`","keras.Model.predict","`","This","class","generates","data","samples","for","link","inference","models","and","should","be","created","using","the",":","meth",":","`","flow","`","method","of",":","class",":","`",".GraphSAGELinkGenerator","`","or",":","class",":","`",".Attri2VecLinkGenerator","`",".","Args",":","sample_function","(","Callable",")",":","A","function","that","returns","features","for","supplied","head","nodes",".","sampler","(","UnsupersizedSampler",")",":","An","object","that","encapsulates","the","neighbourhood","sampling","of","a","graph",".","The","generator","method","of","this","class","returns","a","batch","of","positive","and","negative","samples","on","demand","."]
docstr: Generate one batch of data.
  
  Args:
      batch_num<int>: number of a batch
  
  Returns:
      batch_feats<list>: Node features for nodes and neighbours sampled from a
          batch of the supplied IDs
      batch_targets<list>: Targets/labels for the batch.
docstr_tok: ["Generate","one","batch","of","data",".","Args",":","batch_num","<","int",">",":","number","of","a","batch","Returns",":","batch_feats","<","list",">",":","Node","features","for","nodes","and","neighbours","sampled","from","a","batch","of","the","supplied","IDs","batch_targets","<","list",">",":","Targets\/labels","for","the","batch","."]
code: def __getitem__(self, batch_num):
      """
      Generate one batch of data.
  
      Args:
          batch_num<int>: number of a batch
  
      Returns:
          batch_feats<list>: Node features for nodes and neighbours sampled from a
              batch of the supplied IDs
          batch_targets<list>: Targets/labels for the batch.
  
      """
  
      if batch_num >= self.__len__():
          raise IndexError(
              "Mapper: batch_num larger than number of esstaimted  batches for this epoch."
          )
      # print("Fetching {} batch {} [{}]".format(self.name, batch_num, start_idx))
  
      # Get head nodes and labels
      head_ids, batch_targets = self._batches[batch_num]
  
      # Obtain features for head ids
      batch_feats = self._sample_features(head_ids, batch_num)
  
      return batch_feats, batch_targets
  
imports: import warnings
  import operator
  import random
  import collections
  import numpy
  import itertools
  import networkx
  import scipy.sparse
  from tensorflow.keras import backend
  from functools import reduce
  from tensorflow.keras.utils import Sequence
  from ..data.unsupervised_sampler import UnsupervisedSampler
  from ..core.utils import is_real_iterable
  from ..random import random_state
  from scipy import sparse
  from ..core.experimental import experimental
label_desc: Use image node_id 2 for calling the OnDemandLinkSequence obj's underlying member method code with example usage: obj.__getitem__(batch_num) and returns: batch_feats,  batch_targets