class_docstr: Implementation of the GraphSAGE algorithm extended for heterogeneous graphs with Keras layers.
  
  To use this class as a Keras model, the features and graph should be supplied using the
  :class:`.HinSAGENodeGenerator` class for node inference models or the
  :class:`.HinSAGELinkGenerator` class for link inference models.  The `.in_out_tensors` method should
  be used to create a Keras model from the `GraphSAGE` object.
  
  Currently the class supports node or link prediction models which are built depending on whether
  a `HinSAGENodeGenerator` or `HinSAGELinkGenerator` object is specified.
  The models are built for a single node or link type. For example if you have nodes of types 'A' and 'B'
  you can build a link model for only a single pair of node types, for example ('A', 'B'), which should
  be specified in the `HinSAGELinkGenerator`.
  
  If you feed links into the model that do not have these node types (in correct order) an error will be
  raised.
  
  Examples:
      Creating a two-level GrapSAGE node classification model on nodes of type 'A' with hidden node sizes of 8 and 4
      and 10 neighbours sampled at each layer using an existing :class:`.StellarGraph` object `G`
      containing the graph and node features::
  
          generator = HinSAGENodeGenerator(
              G, batch_size=50, num_samples=[10,10], head_node_type='A'
              )
          gat = HinSAGE(
                  layer_sizes=[8, 4],
                  activations=["relu","softmax"],
                  generator=generator,
              )
          x_inp, predictions = gat.in_out_tensors()
  
      Creating a two-level GrapSAGE link classification model on nodes pairs of type ('A', 'B')
      with hidden node sizes of 8 and 4 and 5 neighbours sampled at each layer::
  
          generator = HinSAGELinkGenerator(
              G, batch_size=50, num_samples=[5,5], head_node_types=('A','B')
              )
          gat = HinSAGE(
                  layer_sizes=[8, 4],
                  activations=["relu","softmax"],
                  generator=generator,
              )
          x_inp, predictions = gat.in_out_tensors()
  
  Note that passing a `NodeSequence` or `LinkSequence` object from the `generator.flow(...)` method
  as the `generator=` argument is now deprecated and the base generator object should be passed instead.
  
  .. seealso::
  
     Examples using HinSAGE:
  
     - `link prediction <https://stellargraph.readthedocs.io/en/stable/demos/link-prediction/hinsage-link-prediction.html>`__
     - `unsupervised representation learning with Deep Graph Infomax <https://stellargraph.readthedocs.io/en/stable/demos/embeddings/deep-graph-infomax-embeddings.html>`__
  
     Appropriate data generators: :class:`.HinSAGENodeGenerator`, :class:`.HinSAGELinkGenerator`.
  
     Related models:
  
     - :class:`.GraphSAGE` for homogeneous graphs
     - :class:`.DirectedGraphSAGE` for homogeneous directed graphs
     - :class:`.DeepGraphInfomax` for unsupervised training
  
     Aggregators: :class:`.MeanHinAggregator`.
  
     The `Heterogeneous GraphSAGE (HinSAGE) <https://stellargraph.readthedocs.io/en/stable/hinsage.html>`__ explanatory document has more theoretical details.
  
  Args:
      layer_sizes (list): Hidden feature dimensions for each layer
      generator (HinSAGENodeGenerator or HinSAGELinkGenerator):
          If specified, required model arguments such as the number of samples
          will be taken from the generator object. See note below.
      aggregator (HinSAGEAggregator): The HinSAGE aggregator to use; defaults to the `MeanHinAggregator`.
      bias (bool): If True (default), a bias vector is learnt for each layer.
      dropout (float): The dropout supplied to each layer; defaults to no dropout.
      normalize (str): The normalization used after each layer; defaults to L2 normalization.
      activations (list): Activations applied to each layer's output;
          defaults to ``['relu', ..., 'relu', 'linear']``.
      kernel_initializer (str or func, optional): The initialiser to use for the weights of each layer.
      kernel_regularizer (str or func, optional): The regulariser to use for the weights of each layer.
      kernel_constraint (str or func, optional): The constraint to use for the weights of each layer.
      bias_initializer (str or func, optional): The initialiser to use for the bias of each layer.
      bias_regularizer (str or func, optional): The regulariser to use for the bias of each layer.
      bias_constraint (str or func, optional): The constraint to use for the bias of each layer.
      n_samples (list, optional): The number of samples per layer in the model.
      input_neighbor_tree (list of tuple, optional): A list of (node_type, [children]) tuples that
          specify the subtree to be created by the HinSAGE model.
      input_dim (dict, optional): The input dimensions for each node type as a dictionary of the form
          ``{node_type: feature_size}``.
      multiplicity (int, optional): The number of nodes to process at a time. This is 1 for a node
          inference and 2 for link inference (currently no others are supported).
  
  .. note::
      The values for ``n_samples``, ``input_neighbor_tree``, ``input_dim``, and ``multiplicity`` are
      obtained from the provided ``generator`` by default. The additional keyword arguments for these
      parameters provide an alternative way to specify them if a generator cannot be supplied.
class_docstr_tok: ["Implementation","of","the","GraphSAGE","algorithm","extended","for","heterogeneous","graphs","with","Keras","layers",".","To","use","this","class","as","a","Keras","model",",","the","features","and","graph","should","be","supplied","using","the",":","class",":","`",".HinSAGENodeGenerator","`","class","for","node","inference","models","or","the",":","class",":","`",".HinSAGELinkGenerator","`","class","for","link","inference","models",".","The","`",".in_out_tensors","`","method","should","be","used","to","create","a","Keras","model","from","the","`","GraphSAGE","`","object",".","Currently","the","class","supports","node","or","link","prediction","models","which","are","built","depending","on","whether","a","`","HinSAGENodeGenerator","`","or","`","HinSAGELinkGenerator","`","object","is","specified",".","The","models","are","built","for","a","single","node","or","link","type",".","For","example","if","you","have","nodes","of","types","'","A","'","and","'","B'","you","can","build","a","link","model","for","only","a","single","pair","of","node","types",",","for","example","(","'","A","'",",","'","B","'",")",",","which","should","be","specified","in","the","`","HinSAGELinkGenerator","`",".","If","you","feed","links","into","the","model","that","do","not","have","these","node","types","(","in","correct","order",")","an","error","will","be","raised",".","Examples",":","Creating","a","two-level","GrapSAGE","node","classification","model","on","nodes","of","type","'","A","'","with","hidden","node","sizes","of","8","and","4","and","10","neighbours","sampled","at","each","layer","using","an","existing",":","class",":","`",".StellarGraph","`","object","`","G","`","containing","the","graph","and","node","features",":",":","generator","=","HinSAGENodeGenerator","(","G",",","batch_size=50",",","num_samples=","[","10,10","]",",","head_node_type=","'","A'",")","gat","=","HinSAGE","(","layer_sizes=","[","8",",","4","]",",","activations=","[","``","relu","''",",","''","softmax","''","]",",","generator=generator",",",")","x_inp",",","predictions","=","gat.in_out_tensors","(",")","Creating","a","two-level","GrapSAGE","link","classification","model","on","nodes","pairs","of","type","(","'","A","'",",","'","B","'",")","with","hidden","node","sizes","of","8","and","4","and","5","neighbours","sampled","at","each","layer",":",":","generator","=","HinSAGELinkGenerator","(","G",",","batch_size=50",",","num_samples=","[","5,5","]",",","head_node_types=","(","'","A","'",",","'","B","'",")",")","gat","=","HinSAGE","(","layer_sizes=","[","8",",","4","]",",","activations=","[","``","relu","''",",","''","softmax","''","]",",","generator=generator",",",")","x_inp",",","predictions","=","gat.in_out_tensors","(",")","Note","that","passing","a","`","NodeSequence","`","or","`","LinkSequence","`","object","from","the","`","generator.flow","(","...",")","`","method","as","the","`","generator=","`","argument","is","now","deprecated","and","the","base","generator","object","should","be","passed","instead",".","..","seealso",":",":","Examples","using","HinSAGE",":","-","`","link","prediction","<","https",":","\/\/stellargraph.readthedocs.io\/en\/stable\/demos\/link-prediction\/hinsage-link-prediction.html",">","`","__","-","`","unsupervised","representation","learning","with","Deep","Graph","Infomax","<","https",":","\/\/stellargraph.readthedocs.io\/en\/stable\/demos\/embeddings\/deep-graph-infomax-embeddings.html",">","`","__","Appropriate","data","generators",":",":","class",":","`",".HinSAGENodeGenerator","`",",",":","class",":","`",".HinSAGELinkGenerator","`",".","Related","models",":","-",":","class",":","`",".GraphSAGE","`","for","homogeneous","graphs","-",":","class",":","`",".DirectedGraphSAGE","`","for","homogeneous","directed","graphs","-",":","class",":","`",".DeepGraphInfomax","`","for","unsupervised","training","Aggregators",":",":","class",":","`",".MeanHinAggregator","`",".","The","`","Heterogeneous","GraphSAGE","(","HinSAGE",")","<","https",":","\/\/stellargraph.readthedocs.io\/en\/stable\/hinsage.html",">","`","__","explanatory","document","has","more","theoretical","details",".","Args",":","layer_sizes","(","list",")",":","Hidden","feature","dimensions","for","each","layer","generator","(","HinSAGENodeGenerator","or","HinSAGELinkGenerator",")",":","If","specified",",","required","model","arguments","such","as","the","number","of","samples","will","be","taken","from","the","generator","object",".","See","note","below",".","aggregator","(","HinSAGEAggregator",")",":","The","HinSAGE","aggregator","to","use",";","defaults","to","the","`","MeanHinAggregator","`",".","bias","(","bool",")",":","If","True","(","default",")",",","a","bias","vector","is","learnt","for","each","layer",".","dropout","(","float",")",":","The","dropout","supplied","to","each","layer",";","defaults","to","no","dropout",".","normalize","(","str",")",":","The","normalization","used","after","each","layer",";","defaults","to","L2","normalization",".","activations","(","list",")",":","Activations","applied","to","each","layer","'s","output",";","defaults","to","``","[","'relu","'",",","...",",","'relu","'",",","'linear","'","]","``",".","kernel_initializer","(","str","or","func",",","optional",")",":","The","initialiser","to","use","for","the","weights","of","each","layer",".","kernel_regularizer","(","str","or","func",",","optional",")",":","The","regulariser","to","use","for","the","weights","of","each","layer",".","kernel_constraint","(","str","or","func",",","optional",")",":","The","constraint","to","use","for","the","weights","of","each","layer",".","bias_initializer","(","str","or","func",",","optional",")",":","The","initialiser","to","use","for","the","bias","of","each","layer",".","bias_regularizer","(","str","or","func",",","optional",")",":","The","regulariser","to","use","for","the","bias","of","each","layer",".","bias_constraint","(","str","or","func",",","optional",")",":","The","constraint","to","use","for","the","bias","of","each","layer",".","n_samples","(","list",",","optional",")",":","The","number","of","samples","per","layer","in","the","model",".","input_neighbor_tree","(","list","of","tuple",",","optional",")",":","A","list","of","(","node_type",",","[","children","]",")","tuples","that","specify","the","subtree","to","be","created","by","the","HinSAGE","model",".","input_dim","(","dict",",","optional",")",":","The","input","dimensions","for","each","node","type","as","a","dictionary","of","the","form","``","{","node_type",":","feature_size","}","``",".","multiplicity","(","int",",","optional",")",":","The","number","of","nodes","to","process","at","a","time",".","This","is","1","for","a","node","inference","and","2","for","link","inference","(","currently","no","others","are","supported",")",".","..","note",":",":","The","values","for","``","n_samples","``",",","``","input_neighbor_tree","``",",","``","input_dim","``",",","and","``","multiplicity","``","are","obtained","from","the","provided","``","generator","``","by","default",".","The","additional","keyword","arguments","for","these","parameters","provide","an","alternative","way","to","specify","them","if","a","generator","can","not","be","supplied","."]
docstr: Builds a HinSAGE model for node or link/node pair prediction, depending on the generator used to construct
  the model (whether it is a node or link/node pair generator).
  
  Returns:
      tuple: ``(x_inp, x_out)``, where ``x_inp`` is a list of Keras input tensors
          for the specified HinSAGE model (either node or link/node pair model) and ``x_out`` contains
          model output tensor(s) of shape (batch_size, layer_sizes[-1]).
docstr_tok: ["Builds","a","HinSAGE","model","for","node","or","link\/node","pair","prediction",",","depending","on","the","generator","used","to","construct","the","model","(","whether","it","is","a","node","or","link\/node","pair","generator",")",".","Returns",":","tuple",":","``","(","x_inp",",","x_out",")","``",",","where","``","x_inp","``","is","a","list","of","Keras","input","tensors","for","the","specified","HinSAGE","model","(","either","node","or","link\/node","pair","model",")","and","``","x_out","``","contains","model","output","tensor","(","s",")","of","shape","(","batch_size",",","layer_sizes","[","-1","]",")","."]
code: def in_out_tensors(self):
      """
      Builds a HinSAGE model for node or link/node pair prediction, depending on the generator used to construct
      the model (whether it is a node or link/node pair generator).
  
      Returns:
          tuple: ``(x_inp, x_out)``, where ``x_inp`` is a list of Keras input tensors
              for the specified HinSAGE model (either node or link/node pair model) and ``x_out`` contains
              model output tensor(s) of shape (batch_size, layer_sizes[-1]).
  
      """
  
      # Create tensor inputs
      x_inp = [Input(shape=s) for s in self._input_shapes()]
  
      # Output from HinSAGE model
      x_out = self(x_inp)
  
      return x_inp, x_out
  
imports: import tensorflow
  from tensorflow.keras.layers import Layer
  from tensorflow.keras import backend, Input
  from tensorflow.keras.layers import Lambda, Dropout, Reshape
  from tensorflow.keras.utils import Sequence
  from tensorflow.keras import activations, initializers, regularizers, constraints
  from typing import List, Callable, Tuple, Dict, Union, AnyStr
  import itertools
  import operator
  import warnings
  from .misc import deprecated_model_function
  from ..mapper import HinSAGENodeGenerator, HinSAGELinkGenerator
label_desc: Use image node_id 6 for calling the HinSAGE obj's underlying member method code with example usage: obj.in_out_tensors() and returns: x_inp,  x_out