class_docstr: Implementation of Graph Global Pooling "GlobalAttention"
      
  Reference Paper: Gated Graph Sequence Neural Networks.
  
  Args:
      gate: a neural network that mapping input \in [-1, channels] to output \in [-1, 1]
      nn: a neural network that mapping input \in [-1, in_channels] to output \in [-1, out_channels]. Default:None
class_docstr_tok: ["Implementation","of","Graph","Global","Pooling","``","GlobalAttention","''","Reference","Paper",":","Gated","Graph","Sequence","Neural","Networks",".","Args",":","gate",":","a","neural","network","that","mapping","input","\\in","[","-1",",","channels","]","to","output","\\in","[","-1",",","1","]","nn",":","a","neural","network","that","mapping","input","\\in","[","-1",",","in_channels","]","to","output","\\in","[","-1",",","out_channels","]",".","Default",":","None"]
docstr: Args:
      graph: the graph object from (:code:`Graph`)
      x: A tensor with shape (num_nodes, feature_size).
      
  Return:
      output_feat: A tensor with shape (num_nodes, output_size).
docstr_tok: ["Args",":","graph",":","the","graph","object","from","(",":","code",":","`","Graph","`",")","x",":","A","tensor","with","shape","(","num_nodes",",","feature_size",")",".","Return",":","output_feat",":","A","tensor","with","shape","(","num_nodes",",","output_size",")","."]
code: def forward(self, graph, x):
      """
      Args:
          graph: the graph object from (:code:`Graph`)
          x: A tensor with shape (num_nodes, feature_size).
  
      Return:
          output_feat: A tensor with shape (num_nodes, output_size).
      """
  
      graph_id = graph.graph_node_id
      gate_x = self.gate(x).reshape(shape=(-1, 1))
      x = self.nn(x) if self.nn else x
      assert x.ndim == gate_x.ndim and x.shape[0] == gate_x.shape[0]
      gate_x = segment_softmax(gate_x, graph_id)
      output = segment_sum(gate_x * x, graph_id)
      return output
  
imports: import warnings
  import numpy
  import paddle
  import paddle.nn
  import paddle.nn.functional
  import pgl
  from pgl.math import segment_sum, segment_softmax, segment_topk, segment_pool
  from pgl.utils.transform import filter_adj
label_desc: Use image node_id 2 for calling the GlobalAttention obj's underlying member method code with example usage: obj.forward(graph, x) and returns: output