class_docstr: Multi-layered `GraphSAGE Network <https://arxiv.org/pdf/1706.02216.pdf>`__
  Support both unidirectional (i.e., regular) and bidirectional (i.e., `bi_sep` and `bi_fuse`)
  versions.
  
  .. math::
      h_{\mathcal{N}(i)}^{(l+1)} & = \mathrm{aggregate}
      \left(\{h_{j}^{l}, \forall j \in \mathcal{N}(i) \}\right)
      h_{i}^{(l+1)} & = \sigma \left(W \cdot \mathrm{concat}
      (h_{i}^{l}, h_{\mathcal{N}(i)}^{l+1} + b) \right)
      h_{i}^{(l+1)} & = \mathrm{norm}(h_{i}^{l})
  
  Parameters
  ----------
  num_layers: int
      Number of GraphSAGE layers.
  input_size : int, or pair of ints
      Input feature size.
      If the layer is to be applied to a unidirectional bipartite graph, ``input_size``
      specifies the input feature size on both the source and destination nodes.  If
      a scalar is given, the source and destination node feature size would take the
      same value.
      If aggregator type is ``gcn``, the feature size of source and destination nodes
      are required to be the same.
  hidden_size: int list of int
      Hidden layer size.
      If a scalar is given, the sizes of all the hidden layers are the same.
      If a list of scalar is given, each element in the list is the size of each hidden layer.
      Example: [100,50]
  output_size : int
      Output feature size. For the bisep version, the output size is 2*output_size
  direction_option: str
      Whether use unidirectional (i.e., regular) or bidirectional (i.e., `bi_sep` and `bi_fuse`)
      versions.
  feat_drop : float, optional
      Dropout rate on feature, defaults: ``0``.
  aggregator_type : str
      Aggregator type to use (``mean``, ``gcn``, ``pool``, ``lstm``).
  bias : bool
      If True, adds a learnable bias to the output. Default: ``True``.
  norm : callable activation function/layer or None, optional
      If not None, applies normalization to the updated node features.
  activation : callable activation function/layer or None, optional
      If not None, applies an activation function to the updated node features.
      Default: ``None``.
class_docstr_tok: ["Multi-layered","`","GraphSAGE","Network","<","https",":","\/\/arxiv.org\/pdf\/1706.02216.pdf",">","`","__","Support","both","unidirectional","(","i.e.",",","regular",")","and","bidirectional","(","i.e.",",","`","bi_sep","`","and","`","bi_fuse","`",")","versions",".","..","math",":",":","h_","{","\\mathcal","{","N","}","(","i",")","}","^","{","(","l+1",")","}","&","=","\\mathrm","{","aggregate","}","\\left","(","\\","{","h_","{","j","}","^","{","l","}",",","\\forall","j","\\in","\\mathcal","{","N","}","(","i",")","\\","}","\\right",")","h_","{","i","}","^","{","(","l+1",")","}","&","=","\\sigma","\\left","(","W","\\cdot","\\mathrm","{","concat","}","(","h_","{","i","}","^","{","l","}",",","h_","{","\\mathcal","{","N","}","(","i",")","}","^","{","l+1","}","+","b",")","\\right",")","h_","{","i","}","^","{","(","l+1",")","}","&","=","\\mathrm","{","norm","}","(","h_","{","i","}","^","{","l","}",")","Parameters","--","--","--","--","--","num_layers",":","int","Number","of","GraphSAGE","layers",".","input_size",":","int",",","or","pair","of","ints","Input","feature","size",".","If","the","layer","is","to","be","applied","to","a","unidirectional","bipartite","graph",",","``","input_size","``","specifies","the","input","feature","size","on","both","the","source","and","destination","nodes",".","If","a","scalar","is","given",",","the","source","and","destination","node","feature","size","would","take","the","same","value",".","If","aggregator","type","is","``","gcn","``",",","the","feature","size","of","source","and","destination","nodes","are","required","to","be","the","same",".","hidden_size",":","int","list","of","int","Hidden","layer","size",".","If","a","scalar","is","given",",","the","sizes","of","all","the","hidden","layers","are","the","same",".","If","a","list","of","scalar","is","given",",","each","element","in","the","list","is","the","size","of","each","hidden","layer",".","Example",":","[","100,50","]","output_size",":","int","Output","feature","size",".","For","the","bisep","version",",","the","output","size","is","2","*","output_size","direction_option",":","str","Whether","use","unidirectional","(","i.e.",",","regular",")","or","bidirectional","(","i.e.",",","`","bi_sep","`","and","`","bi_fuse","`",")","versions",".","feat_drop",":","float",",","optional","Dropout","rate","on","feature",",","defaults",":","``","0","``",".","aggregator_type",":","str","Aggregator","type","to","use","(","``","mean","``",",","``","gcn","``",",","``","pool","``",",","``","lstm","``",")",".","bias",":","bool","If","True",",","adds","a","learnable","bias","to","the","output",".","Default",":","``","True","``",".","norm",":","callable","activation","function\/layer","or","None",",","optional","If","not","None",",","applies","normalization","to","the","updated","node","features",".","activation",":","callable","activation","function\/layer","or","None",",","optional","If","not","None",",","applies","an","activation","function","to","the","updated","node","features",".","Default",":","``","None","``","."]
code: def __init__(
      self,
      num_layers,
      input_size,
      hidden_size,
      output_size,
      aggregator_type,
      direction_option="undirected",
      feat_drop=0.0,
      bias=True,
      norm=None,
      activation=None,
      use_edge_weight=False,
  ):
      super(GraphSAGE, self).__init__()
      self.use_edge_weight = use_edge_weight
      self.num_layers = num_layers
      self.direction_option = direction_option
      self.GraphSAGE_layers = nn.ModuleList()
  
      # transform the hidden size format
      if self.num_layers > 1 and type(hidden_size) is int:
          hidden_size = [
              hidden_size for i in range(self.num_layers - 1)
          ]
  
      if self.num_layers > 1:
          # input projection
          self.GraphSAGE_layers.append(
              GraphSAGELayer(
                  input_size,
                  hidden_size[0],
                  aggregator_type,
                  direction_option=self.direction_option,
                  feat_drop=feat_drop,
                  bias=bias,
                  norm=norm,
                  activation=activation,
              )
          )
      # hidden layers
      for l in range(1, self.num_layers - 1):
          # due to multi-head, the input_size = hidden_size * num_heads
          self.GraphSAGE_layers.append(
              GraphSAGELayer(
                  hidden_size[l - 1],
                  hidden_size[l],
                  aggregator_type,
                  direction_option=self.direction_option,
                  feat_drop=feat_drop,
                  bias=bias,
                  norm=norm,
                  activation=activation,
              )
          )
      # output projection
      self.GraphSAGE_layers.append(
          GraphSAGELayer(
              hidden_size[-1] if self.num_layers > 1 else input_size,
              output_size,
              aggregator_type,
              direction_option=self.direction_option,
              feat_drop=feat_drop,
              bias=bias,
              norm=norm,
              activation=activation,
          )
      )
  
imports: import warnings
  import dgl.function
  import torch
  import torch.nn
  import torch.nn.functional
  from dgl.utils import check_eq_shape, expand_as_pair
  from .base import GNNBase, GNNLayerBase
label_desc: Use image node_id 1 to create a new GraphSAGE object from inherited base classes: GNNBase with example: obj = GraphSAGE(num_layers, input_size, hidden_size, output_size, aggregator_type, direction_option, feat_drop, bias, norm, activation, use_edge_weight)