class_docstr: Set2Set operator from `Order Matters: Sequence to sequence for sets
  <https://arxiv.org/pdf/1511.06391.pdf>`__
  
  For each individual graph in the batch, set2set computes
  
  .. math::
      q_t &= \mathrm{LSTM} (q^*_{t-1})
  
      \alpha_{i,t} &= \mathrm{softmax}(x_i \cdot q_t)
  
      r_t &= \sum_{i=1}^N \alpha_{i,t} x_i
  
      q^*_t &= q_t \Vert r_t
  
  for this graph.
  
  Parameters
  ----------
  input_dim : int
      The size of each input sample.
  n_iters : int
      The number of iterations.
  n_layers : int
      The number of recurrent layers.
  
  Examples
  --------
  The following example uses PyTorch backend.
  
  >>> import dgl
  >>> import torch as th
  >>> from dgl.nn import Set2Set
  >>>
  >>> g1 = dgl.rand_graph(3, 4)  # g1 is a random graph with 3 nodes and 4 edges
  >>> g1_node_feats = th.rand(3, 5)  # feature size is 5
  >>> g1_node_feats
  tensor([[0.8948, 0.0699, 0.9137, 0.7567, 0.3637],
          [0.8137, 0.8938, 0.8377, 0.4249, 0.6118],
          [0.5197, 0.9030, 0.6825, 0.5725, 0.4755]])
  >>>
  >>> g2 = dgl.rand_graph(4, 6)  # g2 is a random graph with 4 nodes and 6 edges
  >>> g2_node_feats = th.rand(4, 5)  # feature size is 5
  >>> g2_node_feats
  tensor([[0.2053, 0.2426, 0.4111, 0.9028, 0.5658],
          [0.5278, 0.6365, 0.9990, 0.2351, 0.8945],
          [0.3134, 0.0580, 0.4349, 0.7949, 0.3891],
          [0.0142, 0.2709, 0.3330, 0.8521, 0.6925]])
  >>>
  >>> s2s = Set2Set(5, 2, 1)  # create a Set2Set layer(n_iters=2, n_layers=1)
  
  Case 1: Input a single graph
  
  >>> s2s(g1, g1_node_feats)
      tensor([[-0.0235, -0.2291,  0.2654,  0.0376,  0.1349,  0.7560,  0.5822,  0.8199,
                0.5960,  0.4760]], grad_fn=<CatBackward>)
  
  Case 2: Input a batch of graphs
  
  Build a batch of DGL graphs and concatenate all graphs' node features into one tensor.
  
  >>> batch_g = dgl.batch([g1, g2])
  >>> batch_f = th.cat([g1_node_feats, g2_node_feats], 0)
  >>>
  >>> s2s(batch_g, batch_f)
  tensor([[-0.0235, -0.2291,  0.2654,  0.0376,  0.1349,  0.7560,  0.5822,  0.8199,
            0.5960,  0.4760],
          [-0.0483, -0.2010,  0.2324,  0.0145,  0.1361,  0.2703,  0.3078,  0.5529,
            0.6876,  0.6399]], grad_fn=<CatBackward>)
  
  Notes
  -----
  Set2Set is widely used in molecular property predictions, see
  `dgl-lifesci's MPNN example <https://github.com/awslabs/dgl-lifesci/blob/
  ecd95c905479ec048097777039cf9a19cfdcf223/python/dgllife/model/model_zoo/
  mpnn_predictor.py>`__
  on how to use DGL's Set2Set layer in graph property prediction applications.
class_docstr_tok: ["Set2Set","operator","from","`","Order","Matters",":","Sequence","to","sequence","for","sets","<","https",":","\/\/arxiv.org\/pdf\/1511.06391.pdf",">","`","__","For","each","individual","graph","in","the","batch",",","set2set","computes","..","math",":",":","q_t","&","=","\\mathrm","{","LSTM","}","(","q^","*","_","{","t-1","}",")","\\alpha_","{","i",",","t","}","&","=","\\mathrm","{","softmax","}","(","x_i","\\cdot","q_t",")","r_t","&","=","\\sum_","{","i=1","}","^N","\\alpha_","{","i",",","t","}","x_i","q^","*","_t","&","=","q_t","\\Vert","r_t","for","this","graph",".","Parameters","--","--","--","--","--","input_dim",":","int","The","size","of","each","input","sample",".","n_iters",":","int","The","number","of","iterations",".","n_layers",":","int","The","number","of","recurrent","layers",".","Examples","--","--","--","--","The","following","example","uses","PyTorch","backend",".",">",">",">","import","dgl",">",">",">","import","torch","as","th",">",">",">","from","dgl.nn","import","Set2Set",">",">",">",">",">",">","g1","=","dgl.rand_graph","(","3",",","4",")","#","g1","is","a","random","graph","with","3","nodes","and","4","edges",">",">",">","g1_node_feats","=","th.rand","(","3",",","5",")","#","feature","size","is","5",">",">",">","g1_node_feats","tensor","(","[","[","0.8948",",","0.0699",",","0.9137",",","0.7567",",","0.3637","]",",","[","0.8137",",","0.8938",",","0.8377",",","0.4249",",","0.6118","]",",","[","0.5197",",","0.9030",",","0.6825",",","0.5725",",","0.4755","]","]",")",">",">",">",">",">",">","g2","=","dgl.rand_graph","(","4",",","6",")","#","g2","is","a","random","graph","with","4","nodes","and","6","edges",">",">",">","g2_node_feats","=","th.rand","(","4",",","5",")","#","feature","size","is","5",">",">",">","g2_node_feats","tensor","(","[","[","0.2053",",","0.2426",",","0.4111",",","0.9028",",","0.5658","]",",","[","0.5278",",","0.6365",",","0.9990",",","0.2351",",","0.8945","]",",","[","0.3134",",","0.0580",",","0.4349",",","0.7949",",","0.3891","]",",","[","0.0142",",","0.2709",",","0.3330",",","0.8521",",","0.6925","]","]",")",">",">",">",">",">",">","s2s","=","Set2Set","(","5",",","2",",","1",")","#","create","a","Set2Set","layer","(","n_iters=2",",","n_layers=1",")","Case","1",":","Input","a","single","graph",">",">",">","s2s","(","g1",",","g1_node_feats",")","tensor","(","[","[","-0.0235",",","-0.2291",",","0.2654",",","0.0376",",","0.1349",",","0.7560",",","0.5822",",","0.8199",",","0.5960",",","0.4760","]","]",",","grad_fn=","<","CatBackward",">",")","Case","2",":","Input","a","batch","of","graphs","Build","a","batch","of","DGL","graphs","and","concatenate","all","graphs","'","node","features","into","one","tensor",".",">",">",">","batch_g","=","dgl.batch","(","[","g1",",","g2","]",")",">",">",">","batch_f","=","th.cat","(","[","g1_node_feats",",","g2_node_feats","]",",","0",")",">",">",">",">",">",">","s2s","(","batch_g",",","batch_f",")","tensor","(","[","[","-0.0235",",","-0.2291",",","0.2654",",","0.0376",",","0.1349",",","0.7560",",","0.5822",",","0.8199",",","0.5960",",","0.4760","]",",","[","-0.0483",",","-0.2010",",","0.2324",",","0.0145",",","0.1361",",","0.2703",",","0.3078",",","0.5529",",","0.6876",",","0.6399","]","]",",","grad_fn=","<","CatBackward",">",")","Notes","--","--","-","Set2Set","is","widely","used","in","molecular","property","predictions",",","see","`","dgl-lifesci","'s","MPNN","example","<","https",":","\/\/github.com\/awslabs\/dgl-lifesci\/blob\/","ecd95c905479ec048097777039cf9a19cfdcf223\/python\/dgllife\/model\/model_zoo\/","mpnn_predictor.py",">","`","__","on","how","to","use","DGL","'s","Set2Set","layer","in","graph","property","prediction","applications","."]
docstr: Set the extra representation of the module.
  which will come into effect when printing the model.
docstr_tok: ["Set","the","extra","representation","of","the","module",".","which","will","come","into","effect","when","printing","the","model","."]
code: def extra_repr(self):
      """Set the extra representation of the module.
      which will come into effect when printing the model.
      """
      summary = "n_iters={n_iters}"
      return summary.format(**self.__dict__)
  
imports: import numpy
  import torch
  import torch.nn
  from ...backend import pytorch
  from ...base import dgl_warning
  from ...readout import broadcast_nodes, max_nodes, mean_nodes, softmax_nodes, sum_nodes, topk_nodes
label_desc: Use image node_id 4 for calling the Set2Set obj's underlying member method code with example usage: obj.extra_repr() and returns: summary