class_docstr: A data generator for link prediction with Heterogeneous HinSAGE models
  
  At minimum, supply the StellarGraph, the batch size, and the number of
  node samples for each layer of the GraphSAGE model.
  
  The supplied graph should be a StellarGraph object with node features for all node types.
  
  Use the :meth:`flow` method supplying the nodes and (optionally) targets
  to get an object that can be used as a Keras data generator.
  
  The generator should be given the ``(src,dst)`` node types using
  
  * It's possible to do link prediction on a graph where that link type is completely removed from the graph
    (e.g., "same_as" links in ER)
  
  .. seealso::
  
     Model using this generator: :class:`.HinSAGE`.
  
     Example using this generator: `link prediction <https://stellargraph.readthedocs.io/en/stable/demos/link-prediction/hinsage-link-prediction.html>`__.
  
     Related functionality:
  
     - :class:`.UnsupervisedSampler` for unsupervised training using random walks
     - :class:`.HinSAGENodeGenerator` for node classification and related tasks
     - :class:`.GraphSAGELinkGenerator` for homogeneous graphs
     - :class:`.DirectedGraphSAGELinkGenerator` for directed homogeneous graphs
  
  Args:
      g (StellarGraph): A machine-learning ready graph.
      batch_size (int): Size of batch of links to return.
      num_samples (list): List of number of neighbour node samples per GraphSAGE layer (hop) to take.
      head_node_types (list, optional): List of the types (str) of the two head nodes forming the
          node pair. This does not need to be specified if ``G`` has only one node type.
      seed (int or str, optional): Random seed for the sampling methods.
  
  Example::
  
      G_generator = HinSAGELinkGenerator(G, 50, [10,10])
      data_gen = G_generator.flow(edge_ids)
class_docstr_tok: ["A","data","generator","for","link","prediction","with","Heterogeneous","HinSAGE","models","At","minimum",",","supply","the","StellarGraph",",","the","batch","size",",","and","the","number","of","node","samples","for","each","layer","of","the","GraphSAGE","model",".","The","supplied","graph","should","be","a","StellarGraph","object","with","node","features","for","all","node","types",".","Use","the",":","meth",":","`","flow","`","method","supplying","the","nodes","and","(","optionally",")","targets","to","get","an","object","that","can","be","used","as","a","Keras","data","generator",".","The","generator","should","be","given","the","``","(","src",",","dst",")","``","node","types","using","*","It","'s","possible","to","do","link","prediction","on","a","graph","where","that","link","type","is","completely","removed","from","the","graph","(","e.g.",",","``","same_as","''","links","in","ER",")","..","seealso",":",":","Model","using","this","generator",":",":","class",":","`",".HinSAGE","`",".","Example","using","this","generator",":","`","link","prediction","<","https",":","\/\/stellargraph.readthedocs.io\/en\/stable\/demos\/link-prediction\/hinsage-link-prediction.html",">","`","__",".","Related","functionality",":","-",":","class",":","`",".UnsupervisedSampler","`","for","unsupervised","training","using","random","walks","-",":","class",":","`",".HinSAGENodeGenerator","`","for","node","classification","and","related","tasks","-",":","class",":","`",".GraphSAGELinkGenerator","`","for","homogeneous","graphs","-",":","class",":","`",".DirectedGraphSAGELinkGenerator","`","for","directed","homogeneous","graphs","Args",":","g","(","StellarGraph",")",":","A","machine-learning","ready","graph",".","batch_size","(","int",")",":","Size","of","batch","of","links","to","return",".","num_samples","(","list",")",":","List","of","number","of","neighbour","node","samples","per","GraphSAGE","layer","(","hop",")","to","take",".","head_node_types","(","list",",","optional",")",":","List","of","the","types","(","str",")","of","the","two","head","nodes","forming","the","node","pair",".","This","does","not","need","to","be","specified","if","``","G","``","has","only","one","node","type",".","seed","(","int","or","str",",","optional",")",":","Random","seed","for","the","sampling","methods",".","Example",":",":","G_generator","=","HinSAGELinkGenerator","(","G",",","50",",","[","10,10","]",")","data_gen","=","G_generator.flow","(","edge_ids",")"]
docstr: Collect features from sampled nodes.
  Args:
      node_samples: A list of lists of node IDs
      head_size: The number of head nodes (typically the batch size).
  
  Returns:
      A list of numpy arrays that store the features for each head
      node.
code: def _get_features(self, node_samples, head_size, use_ilocs=False):
      """
      Collect features from sampled nodes.
      Args:
          node_samples: A list of lists of node IDs
          head_size: The number of head nodes (typically the batch size).
  
      Returns:
          A list of numpy arrays that store the features for each head
          node.
      """
      # Note the if there are no samples for a node a zero array is returned.
      # Resize features to (batch_size, n_neighbours, feature_size)
      # for each node type (note that we can have different feature size for each node type)
      batch_feats = [
          self.graph.node_features(layer_nodes, nt, use_ilocs=use_ilocs)
          for nt, layer_nodes in node_samples
      ]
  
      # Resize features to (batch_size, n_neighbours, feature_size)
      batch_feats = [
          np.reshape(a, (head_size, -1, a.shape[1]))
          for a in batch_feats
      ]
  
      return batch_feats
  
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 HinSAGELinkGenerator obj's underlying member method code with example usage: obj._get_features(node_samples, head_size, use_ilocs) and returns: batch_feats