class_docstr: GraphSAGE layer from `Inductive Representation Learning on
  Large Graphs <https://arxiv.org/pdf/1706.02216.pdf>`__
  
  .. 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}) \right)
  
      h_{i}^{(l+1)} &= \mathrm{norm}(h_{i}^{(l+1)})
  
  If a weight tensor on each edge is provided, the aggregation becomes:
  
  .. math::
      h_{\mathcal{N}(i)}^{(l+1)} = \mathrm{aggregate}
      \left(\{e_{ji} h_{j}^{l}, \forall j \in \mathcal{N}(i) \}\right)
  
  where :math:`e_{ji}` is the scalar weight on the edge from node :math:`j` to node :math:`i`.
  Please make sure that :math:`e_{ji}` is broadcastable with :math:`h_j^{l}`.
  
  Parameters
  ----------
  in_feats : int, or pair of ints
      Input feature size; i.e, the number of dimensions of :math:`h_i^{(l)}`.
  
      SAGEConv can be applied on homogeneous graph and unidirectional
      `bipartite graph <https://docs.dgl.ai/generated/dgl.bipartite.html?highlight=bipartite>`__.
      If the layer applies on a unidirectional bipartite graph, ``in_feats``
      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.
  out_feats : int
      Output feature size; i.e, the number of dimensions of :math:`h_i^{(l+1)}`.
  aggregator_type : str
      Aggregator type to use (``mean``, ``gcn``, ``pool``, ``lstm``).
  feat_drop : float
      Dropout rate on features, default: ``0``.
  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``.
  
  Examples
  --------
  >>> import dgl
  >>> import numpy as np
  >>> import torch as th
  >>> from dgl.nn import SAGEConv
  
  >>> # Case 1: Homogeneous graph
  >>> g = dgl.graph(([0,1,2,3,2,5], [1,2,3,4,0,3]))
  >>> g = dgl.add_self_loop(g)
  >>> feat = th.ones(6, 10)
  >>> conv = SAGEConv(10, 2, 'pool')
  >>> res = conv(g, feat)
  >>> res
  tensor([[-1.0888, -2.1099],
          [-1.0888, -2.1099],
          [-1.0888, -2.1099],
          [-1.0888, -2.1099],
          [-1.0888, -2.1099],
          [-1.0888, -2.1099]], grad_fn=<AddBackward0>)
  
  >>> # Case 2: Unidirectional bipartite graph
  >>> u = [0, 1, 0, 0, 1]
  >>> v = [0, 1, 2, 3, 2]
  >>> g = dgl.heterograph({('_N', '_E', '_N'):(u, v)})
  >>> u_fea = th.rand(2, 5)
  >>> v_fea = th.rand(4, 10)
  >>> conv = SAGEConv((5, 10), 2, 'mean')
  >>> res = conv(g, (u_fea, v_fea))
  >>> res
  tensor([[ 0.3163,  3.1166],
          [ 0.3866,  2.5398],
          [ 0.5873,  1.6597],
          [-0.2502,  2.8068]], grad_fn=<AddBackward0>)
class_docstr_tok: ["GraphSAGE","layer","from","`","Inductive","Representation","Learning","on","Large","Graphs","<","https",":","\/\/arxiv.org\/pdf\/1706.02216.pdf",">","`","__","..","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","}",")","\\right",")","h_","{","i","}","^","{","(","l+1",")","}","&","=","\\mathrm","{","norm","}","(","h_","{","i","}","^","{","(","l+1",")","}",")","If","a","weight","tensor","on","each","edge","is","provided",",","the","aggregation","becomes",":","..","math",":",":","h_","{","\\mathcal","{","N","}","(","i",")","}","^","{","(","l+1",")","}","=","\\mathrm","{","aggregate","}","\\left","(","\\","{","e_","{","ji","}","h_","{","j","}","^","{","l","}",",","\\forall","j","\\in","\\mathcal","{","N","}","(","i",")","\\","}","\\right",")","where",":","math",":","`","e_","{","ji","}","`","is","the","scalar","weight","on","the","edge","from","node",":","math",":","`","j","`","to","node",":","math",":","`","i","`",".","Please","make","sure","that",":","math",":","`","e_","{","ji","}","`","is","broadcastable","with",":","math",":","`","h_j^","{","l","}","`",".","Parameters","--","--","--","--","--","in_feats",":","int",",","or","pair","of","ints","Input","feature","size",";","i.e",",","the","number","of","dimensions","of",":","math",":","`","h_i^","{","(","l",")","}","`",".","SAGEConv","can","be","applied","on","homogeneous","graph","and","unidirectional","`","bipartite","graph","<","https",":","\/\/docs.dgl.ai\/generated\/dgl.bipartite.html","?","highlight=bipartite",">","`","__",".","If","the","layer","applies","on","a","unidirectional","bipartite","graph",",","``","in_feats","``","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",".","out_feats",":","int","Output","feature","size",";","i.e",",","the","number","of","dimensions","of",":","math",":","`","h_i^","{","(","l+1",")","}","`",".","aggregator_type",":","str","Aggregator","type","to","use","(","``","mean","``",",","``","gcn","``",",","``","pool","``",",","``","lstm","``",")",".","feat_drop",":","float","Dropout","rate","on","features",",","default",":","``","0","``",".","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","``",".","Examples","--","--","--","--",">",">",">","import","dgl",">",">",">","import","numpy","as","np",">",">",">","import","torch","as","th",">",">",">","from","dgl.nn","import","SAGEConv",">",">",">","#","Case","1",":","Homogeneous","graph",">",">",">","g","=","dgl.graph","(","(","[","0,1,2,3,2,5","]",",","[","1,2,3,4,0,3","]",")",")",">",">",">","g","=","dgl.add_self_loop","(","g",")",">",">",">","feat","=","th.ones","(","6",",","10",")",">",">",">","conv","=","SAGEConv","(","10",",","2",",","'pool","'",")",">",">",">","res","=","conv","(","g",",","feat",")",">",">",">","res","tensor","(","[","[","-1.0888",",","-2.1099","]",",","[","-1.0888",",","-2.1099","]",",","[","-1.0888",",","-2.1099","]",",","[","-1.0888",",","-2.1099","]",",","[","-1.0888",",","-2.1099","]",",","[","-1.0888",",","-2.1099","]","]",",","grad_fn=","<","AddBackward0",">",")",">",">",">","#","Case","2",":","Unidirectional","bipartite","graph",">",">",">","u","=","[","0",",","1",",","0",",","0",",","1","]",">",">",">","v","=","[","0",",","1",",","2",",","3",",","2","]",">",">",">","g","=","dgl.heterograph","(","{","(","'_N","'",",","'_E","'",",","'_N","'",")",":","(","u",",","v",")","}",")",">",">",">","u_fea","=","th.rand","(","2",",","5",")",">",">",">","v_fea","=","th.rand","(","4",",","10",")",">",">",">","conv","=","SAGEConv","(","(","5",",","10",")",",","2",",","'mean","'",")",">",">",">","res","=","conv","(","g",",","(","u_fea",",","v_fea",")",")",">",">",">","res","tensor","(","[","[","0.3163",",","3.1166","]",",","[","0.3866",",","2.5398","]",",","[","0.5873",",","1.6597","]",",","[","-0.2502",",","2.8068","]","]",",","grad_fn=","<","AddBackward0",">",")"]
docstr: LSTM reducer
  NOTE(zihao): lstm reducer with default schedule (degree bucketing)
  is slow, we could accelerate this with degree padding in the future.
docstr_tok: ["LSTM","reducer","NOTE","(","zihao",")",":","lstm","reducer","with","default","schedule","(","degree","bucketing",")","is","slow",",","we","could","accelerate","this","with","degree","padding","in","the","future","."]
code: def _lstm_reducer(self, nodes):
      """LSTM reducer
      NOTE(zihao): lstm reducer with default schedule (degree bucketing)
      is slow, we could accelerate this with degree padding in the future.
      """
      m = nodes.mailbox["m"]  # (B, L, D)
      batch_size = m.shape[0]
      h = (
          m.new_zeros((1, batch_size, self._in_src_feats)),
          m.new_zeros((1, batch_size, self._in_src_feats)),
      )
      _, (rst, _) = self.lstm(m, h)
      return {"neigh": rst.squeeze(0)}
  
file_path: dgl/python/dgl/nn/pytorch/conv/sageconv.py
imports: import torch
  from torch import nn
  from torch.nn import functional
  from ....None import function
  from ....base import DGLError
  from ....utils import check_eq_shape, expand_as_pair
label_desc: Use image node_id 3 for calling the SAGEConv obj's underlying member method code with example usage: obj._lstm_reducer(nodes) and returns: dict