class_docstr: Implementation of a directed version of the GraphSAGE algorithm of Hamilton et al. with Keras layers.
  see: http://snap.stanford.edu/graphsage/
  
  The model minimally requires specification of the layer sizes as a list of int
  corresponding to the feature dimensions for each hidden layer and a generator object.
  
  Different neighbour node aggregators can also be specified with the ``aggregator``
  argument, which should be the aggregator class,
  either :class:`.MeanAggregator`, :class:`.MeanPoolingAggregator`,
  :class:`.MaxPoolingAggregator`, or :class:`.AttentionalAggregator`.
  
  .. seealso::
  
     Examples using Directed GraphSAGE:
  
     - `node classification <https://stellargraph.readthedocs.io/en/stable/demos/node-classification/directed-graphsage-node-classification.html>`__
     - `node classification with Neo4j <https://stellargraph.readthedocs.io/en/stable/demos/connector/neo4j/directed-graphsage-on-cora-neo4j-example.html>`__
  
     Appropriate data generators: :class:`.DirectedGraphSAGENodeGenerator`, :class:`.Neo4jDirectedGraphSAGENodeGenerator`, :class:`.DirectedGraphSAGELinkGenerator`.
  
     Related models:
  
     - :class:`.GraphSAGE` for undirected graphs
     - :class:`.HinSAGE` for undirected heterogeneous graphs
  
     Aggregators: :class:`.MeanAggregator`, :class:`.MeanPoolingAggregator`, :class:`.MaxPoolingAggregator`, :class:`.AttentionalAggregator`.
  
  Args:
      layer_sizes (list): Hidden feature dimensions for each layer.
      generator (DirectedGraphSAGENodeGenerator):
          If specified `n_samples` and `input_dim` will be extracted from this object.
      aggregator (class, optional): The GraphSAGE aggregator to use; defaults to the `MeanAggregator`.
      bias (bool, optional): If True (default), a bias vector is learnt for each layer.
      dropout (float, optional): The dropout supplied to each layer; defaults to no dropout.
      normalize (str, optional): The normalization used after each layer; defaults to L2 normalization.
      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.
  
  Notes::
      If a generator is not specified, then additional keyword arguments must be supplied:
  
      * in_samples (list): The number of in-node samples per layer in the model.
  
      * out_samples (list): The number of out-node samples per layer in the model.
  
      * input_dim (int): The dimensions of the node features used as input to the model.
  
      * multiplicity (int): 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).
  
      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.
  
      
class_docstr_tok: ["Implementation","of","a","directed","version","of","the","GraphSAGE","algorithm","of","Hamilton","et","al",".","with","Keras","layers",".","see",":","http",":","\/\/snap.stanford.edu\/graphsage\/","The","model","minimally","requires","specification","of","the","layer","sizes","as","a","list","of","int","corresponding","to","the","feature","dimensions","for","each","hidden","layer","and","a","generator","object",".","Different","neighbour","node","aggregators","can","also","be","specified","with","the","``","aggregator","``","argument",",","which","should","be","the","aggregator","class",",","either",":","class",":","`",".MeanAggregator","`",",",":","class",":","`",".MeanPoolingAggregator","`",",",":","class",":","`",".MaxPoolingAggregator","`",",","or",":","class",":","`",".AttentionalAggregator","`",".","..","seealso",":",":","Examples","using","Directed","GraphSAGE",":","-","`","node","classification","<","https",":","\/\/stellargraph.readthedocs.io\/en\/stable\/demos\/node-classification\/directed-graphsage-node-classification.html",">","`","__","-","`","node","classification","with","Neo4j","<","https",":","\/\/stellargraph.readthedocs.io\/en\/stable\/demos\/connector\/neo4j\/directed-graphsage-on-cora-neo4j-example.html",">","`","__","Appropriate","data","generators",":",":","class",":","`",".DirectedGraphSAGENodeGenerator","`",",",":","class",":","`",".Neo4jDirectedGraphSAGENodeGenerator","`",",",":","class",":","`",".DirectedGraphSAGELinkGenerator","`",".","Related","models",":","-",":","class",":","`",".GraphSAGE","`","for","undirected","graphs","-",":","class",":","`",".HinSAGE","`","for","undirected","heterogeneous","graphs","Aggregators",":",":","class",":","`",".MeanAggregator","`",",",":","class",":","`",".MeanPoolingAggregator","`",",",":","class",":","`",".MaxPoolingAggregator","`",",",":","class",":","`",".AttentionalAggregator","`",".","Args",":","layer_sizes","(","list",")",":","Hidden","feature","dimensions","for","each","layer",".","generator","(","DirectedGraphSAGENodeGenerator",")",":","If","specified","`","n_samples","`","and","`","input_dim","`","will","be","extracted","from","this","object",".","aggregator","(","class",",","optional",")",":","The","GraphSAGE","aggregator","to","use",";","defaults","to","the","`","MeanAggregator","`",".","bias","(","bool",",","optional",")",":","If","True","(","default",")",",","a","bias","vector","is","learnt","for","each","layer",".","dropout","(","float",",","optional",")",":","The","dropout","supplied","to","each","layer",";","defaults","to","no","dropout",".","normalize","(","str",",","optional",")",":","The","normalization","used","after","each","layer",";","defaults","to","L2","normalization",".","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",".","Notes",":",":","If","a","generator","is","not","specified",",","then","additional","keyword","arguments","must","be","supplied",":","*","in_samples","(","list",")",":","The","number","of","in-node","samples","per","layer","in","the","model",".","*","out_samples","(","list",")",":","The","number","of","out-node","samples","per","layer","in","the","model",".","*","input_dim","(","int",")",":","The","dimensions","of","the","node","features","used","as","input","to","the","model",".","*","multiplicity","(","int",")",":","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",")",".","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","."]
docstr: Computes the total (cumulative product) number of nodes
  sampled at each neighbourhood.
  
  Each hop has to sample separately from both the in-nodes
  and the out-nodes of the previous nodes.
  This gives rise to a binary tree of directed neighbourhoods.
docstr_tok: ["Computes","the","total","(","cumulative","product",")","number","of","nodes","sampled","at","each","neighbourhood",".","Each","hop","has","to","sample","separately","from","both","the","in-nodes","and","the","out-nodes","of","the","previous","nodes",".","This","gives","rise","to","a","binary","tree","of","directed","neighbourhoods","."]
code: def _compute_neighbourhood_sizes(self):
      """
      Computes the total (cumulative product) number of nodes
      sampled at each neighbourhood.
  
      Each hop has to sample separately from both the in-nodes
      and the out-nodes of the previous nodes.
      This gives rise to a binary tree of directed neighbourhoods.
      """
      self.max_slots = 2 ** (self.max_hops + 1) - 1
      self.neighbourhood_sizes = [1] + [
          np.product(
              [
                  self.in_samples[kk]
                  if d == "0"
                  else self.out_samples[kk]
                  for kk, d in enumerate(np.binary_repr(ii + 1)[1:])
              ]
          )
          for ii in range(1, self.max_slots)
      ]
  
imports: import warnings
  import numpy
  from tensorflow.keras.layers import Layer
  from tensorflow.keras import Input
  from tensorflow.keras import backend
  from tensorflow.keras.layers import Lambda, Dropout, Reshape, LeakyReLU
  from tensorflow.keras.utils import Sequence
  from tensorflow.keras import activations, initializers, constraints, regularizers
  from typing import List, Tuple, Callable, AnyStr, Union
  from ..mapper import GraphSAGENodeGenerator, GraphSAGELinkGenerator, DirectedGraphSAGENodeGenerator, DirectedGraphSAGELinkGenerator, NodeSequence, LinkSequence
  from .misc import deprecated_model_function
  from ..connector.neo4j.mapper import Neo4jGraphSAGENodeGenerator, Neo4jDirectedGraphSAGENodeGenerator
label_desc: Use image node_id 3 for calling the DirectedGraphSAGE obj's underlying member method code with example usage: obj._compute_neighbourhood_sizes() without return types