class_docstr: Global Attention Pooling from `Gated Graph Sequence Neural Networks
  <https://arxiv.org/abs/1511.05493.pdf>`__
  
  .. math::
      r^{(i)} = \sum_{k=1}^{N_i}\mathrm{softmax}\left(f_{gate}
      \left(x^{(i)}_k\right)\right) f_{feat}\left(x^{(i)}_k\right)
  
  Parameters
  ----------
  gate_nn : tf.layers.Layer
      A neural network that computes attention scores for each feature.
  feat_nn : tf.layers.Layer, optional
      A neural network applied to each feature before combining them
      with attention scores.
class_docstr_tok: ["Global","Attention","Pooling","from","`","Gated","Graph","Sequence","Neural","Networks","<","https",":","\/\/arxiv.org\/abs\/1511.05493.pdf",">","`","__","..","math",":",":","r^","{","(","i",")","}","=","\\sum_","{","k=1","}","^","{","N_i","}","\\mathrm","{","softmax","}","\\left","(","f_","{","gate","}","\\left","(","x^","{","(","i",")","}","_k\\right",")","\\right",")","f_","{","feat","}","\\left","(","x^","{","(","i",")","}","_k\\right",")","Parameters","--","--","--","--","--","gate_nn",":","tf.layers.Layer","A","neural","network","that","computes","attention","scores","for","each","feature",".","feat_nn",":","tf.layers.Layer",",","optional","A","neural","network","applied","to","each","feature","before","combining","them","with","attention","scores","."]
docstr: Compute global attention pooling.
  
  Parameters
  ----------
  graph : DGLGraph
      The graph.
  feat : tf.Tensor
      The input node feature with shape :math:`(N, D)` where
      :math:`N` is the number of nodes in the graph.
  
  Returns
  -------
  tf.Tensor
      The output feature with shape :math:`(B, *)`, where
      :math:`B` refers to the batch size.
docstr_tok: ["Compute","global","attention","pooling",".","Parameters","--","--","--","--","--","graph",":","DGLGraph","The","graph",".","feat",":","tf.Tensor","The","input","node","feature","with","shape",":","math",":","`","(","N",",","D",")","`","where",":","math",":","`","N","`","is","the","number","of","nodes","in","the","graph",".","Returns","--","--","--","-","tf.Tensor","The","output","feature","with","shape",":","math",":","`","(","B",",","*",")","`",",","where",":","math",":","`","B","`","refers","to","the","batch","size","."]
code: def call(self, graph, feat):
      r"""Compute global attention pooling.
  
      Parameters
      ----------
      graph : DGLGraph
          The graph.
      feat : tf.Tensor
          The input node feature with shape :math:`(N, D)` where
          :math:`N` is the number of nodes in the graph.
  
      Returns
      -------
      tf.Tensor
          The output feature with shape :math:`(B, *)`, where
          :math:`B` refers to the batch size.
      """
      with graph.local_scope():
          gate = self.gate_nn(feat)
          assert (
              gate.shape[-1] == 1
          ), "The output of gate_nn should have size 1 at the last axis."
          feat = self.feat_nn(feat) if self.feat_nn else feat
  
          graph.ndata["gate"] = gate
          gate = softmax_nodes(graph, "gate")
          graph.ndata.pop("gate")
  
          graph.ndata["r"] = feat * gate
          readout = sum_nodes(graph, "r")
          graph.ndata.pop("r")
  
          return readout
  
imports: import tensorflow
  from tensorflow.keras import layers
  from ...readout import max_nodes, mean_nodes, softmax_nodes, sum_nodes, topk_nodes
label_desc: Use image node_id 2 for calling the GlobalAttentionPooling obj's underlying member method code with example usage: obj.call(graph, feat) and returns: readout