class_docstr: A data generator for context node prediction with Node2Vec models.
  
  At minimum, supply the StellarGraph and the batch size.
  
  The supplied graph should be a StellarGraph object that is ready for
  machine learning. Currently the model does not require node features for
  nodes in the graph.
  
  Use the :meth:`flow` method supplying the nodes and targets,
  or an UnsupervisedSampler instance that generates node samples on demand,
  to get an object that can be used as a Keras data generator.
  
  Example::
  
      G_generator = Node2VecLinkGenerator(G, 50)
      data_gen = G_generator.flow(edge_ids, edge_labels)
  
  .. seealso::
  
     Model using this generator: :class:`.Node2Vec`.
  
     An example using this generator (see the model for more): `unsupervised representation learning <https://stellargraph.readthedocs.io/en/stable/demos/embeddings/keras-node2vec-embeddings.html>`__.
  
     Related functionality: :class:`.Node2VecNodeGenerator` for node classification and related tasks.
  
  Args:
      G (StellarGraph): A machine-learning ready graph.
      batch_size (int): Size of batch of links to return.
      name (str or None): Name of the generator (optional).
class_docstr_tok: ["A","data","generator","for","context","node","prediction","with","Node2Vec","models",".","At","minimum",",","supply","the","StellarGraph","and","the","batch","size",".","The","supplied","graph","should","be","a","StellarGraph","object","that","is","ready","for","machine","learning",".","Currently","the","model","does","not","require","node","features","for","nodes","in","the","graph",".","Use","the",":","meth",":","`","flow","`","method","supplying","the","nodes","and","targets",",","or","an","UnsupervisedSampler","instance","that","generates","node","samples","on","demand",",","to","get","an","object","that","can","be","used","as","a","Keras","data","generator",".","Example",":",":","G_generator","=","Node2VecLinkGenerator","(","G",",","50",")","data_gen","=","G_generator.flow","(","edge_ids",",","edge_labels",")","..","seealso",":",":","Model","using","this","generator",":",":","class",":","`",".Node2Vec","`",".","An","example","using","this","generator","(","see","the","model","for","more",")",":","`","unsupervised","representation","learning","<","https",":","\/\/stellargraph.readthedocs.io\/en\/stable\/demos\/embeddings\/keras-node2vec-embeddings.html",">","`","__",".","Related","functionality",":",":","class",":","`",".Node2VecNodeGenerator","`","for","node","classification","and","related","tasks",".","Args",":","G","(","StellarGraph",")",":","A","machine-learning","ready","graph",".","batch_size","(","int",")",":","Size","of","batch","of","links","to","return",".","name","(","str","or","None",")",":","Name","of","the","generator","(","optional",")","."]
docstr: Sample the ids of the target and context nodes.
  and return these as a list of feature arrays for the Node2Vec algorithm.
  
  Args:
      head_links: An iterable of edges to perform sampling for.
  
  Returns:
      A list of feature arrays, with each element being the ids of
      the sampled target and context node.
code: def sample_features(self, head_links, batch_num):
      """
      Sample the ids of the target and context nodes.
      and return these as a list of feature arrays for the Node2Vec algorithm.
  
      Args:
          head_links: An iterable of edges to perform sampling for.
  
      Returns:
          A list of feature arrays, with each element being the ids of
          the sampled target and context node.
      """
  
      return [np.array(ids) for ids in zip(*head_links)]
  
imports: import random
  import operator
  import numpy
  import itertools
  import operator
  import collections
  import abc
  import warnings
  from functools import reduce
  from tensorflow import keras
  from ..core.graph import StellarGraph, GraphSchema
  from ..data import SampledBreadthFirstWalk, SampledHeterogeneousBreadthFirstWalk, UniformRandomWalk, UnsupervisedSampler, DirectedBreadthFirstNeighbours
  from ..core.utils import is_real_iterable
  from .None import LinkSequence, OnDemandLinkSequence
  from ..random import SeededPerBatch
  from .base import Generator
label_desc: Use image node_id 2 for calling the Node2VecLinkGenerator obj's underlying member method code with example usage: obj.sample_features(head_links, batch_num) and returns: unknown