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",")"]
code: def __init__(
      self,
      G,
      batch_size,
      num_samples,
      head_node_types=None,
      schema=None,
      seed=None,
      name=None,
  ):
      super().__init__(G, batch_size, schema)
      self.num_samples = num_samples
      self.name = name
  
      # This is a link generator and requires two nodes per query
      if head_node_types is None:
          # infer the head node types, if this is a homogeneous-node graph
          node_type = G.unique_node_type(
              "head_node_types: expected a pair of head node types because G has more than one node type, found node types: %(found)s"
          )
          head_node_types = [node_type, node_type]
  
      self.head_node_types = head_node_types
      if len(self.head_node_types) != 2:
          raise ValueError(
              "The head_node_types should be of length 2 for a link generator"
          )
  
      # Create sampling schema
      self._sampling_schema = self.schema.sampling_layout(
          self.head_node_types, self.num_samples
      )
      self._type_adjacency_list = self.schema.type_adjacency_list(
          self.head_node_types, len(self.num_samples)
      )
  
      # The sampler used to generate random samples of neighbours
      self.sampler = SampledHeterogeneousBreadthFirstWalk(
          G, graph_schema=self.schema, seed=seed
      )
  
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 1 to create a new HinSAGELinkGenerator object from inherited base classes: BatchedLinkGenerator with example: obj = HinSAGELinkGenerator(G, batch_size, num_samples, head_node_types, schema, seed, name)