class_docstr: Implementation of set2set pooling operator.
  
  This is an implementation of the paper ORDER MATTERS: SEQUENCE TO SEQUENCE 
  FOR SETS (https://arxiv.org/pdf/1511.06391.pdf).
class_docstr_tok: ["Implementation","of","set2set","pooling","operator",".","This","is","an","implementation","of","the","paper","ORDER","MATTERS",":","SEQUENCE","TO","SEQUENCE","FOR","SETS","(","https",":","\/\/arxiv.org\/pdf\/1511.06391.pdf",")","."]
docstr: Args:
      feat: input feature with shape [batch, n_edges, dim].
  
  Return:
      output_feat: output feature of set2set pooling with shape [batch, 2*dim].
docstr_tok: ["Args",":","feat",":","input","feature","with","shape","[","batch",",","n_edges",",","dim","]",".","Return",":","output_feat",":","output","feature","of","set2set","pooling","with","shape","[","batch",",","2","*","dim","]","."]
code: def forward(self, feat):
      """
      Args:
          feat: input feature with shape [batch, n_edges, dim].
  
      Return:
          output_feat: output feature of set2set pooling with shape [batch, 2*dim].
      """
  
      seqlen = 1
      h = L.fill_constant_batch_size_like(
          feat, [1, self.n_layers, self.input_dim], "float32", 0
      )
      h = L.transpose(h, [1, 0, 2])
      c = h
  
      # [seqlen, batch, dim]
      q_star = L.fill_constant_batch_size_like(
          feat, [1, seqlen, self.output_dim], "float32", 0
      )
      q_star = L.transpose(q_star, [1, 0, 2])
  
      for _ in range(self.n_iters):
          # q [seqlen, batch, dim]
          # h [layer, batch, dim]
          q, h, c = L.lstm(
              q_star,
              h,
              c,
              seqlen,
              self.input_dim,
              self.n_layers,
              is_bidirec=False,
          )
  
          # e [batch, seqlen, n_edges]
          e = L.matmul(
              L.transpose(q, [1, 0, 2]), feat, transpose_y=True
          )
          # alpha [batch, seqlen, n_edges]
          alpha = L.softmax(e)
  
          # readout [batch, seqlen, dim]
          readout = L.matmul(alpha, feat)
          readout = L.transpose(readout, [1, 0, 2])
  
          # q_star [seqlen, batch, dim + dim]
          q_star = L.concat([q, readout], -1)
  
      return L.squeeze(q_star, [0])
  
file_path: PGL/legacy/pgl/layers/set2set.py
imports: from __future__ import division
  from __future__ import absolute_import
  from __future__ import print_function
  from __future__ import unicode_literals
  import paddle.fluid
  import paddle.fluid.layers
  import pgl
label_desc: Use image node_id 2 for calling the Set2Set obj's underlying member method code with example usage: obj.forward(feat) and returns: L