class_docstr: Implementation of graph attention networks (GAT)
  This is an implementation of the paper GRAPH ATTENTION NETWORKS
  (https://arxiv.org/abs/1710.10903).
  Args:
      input_size: The size of the inputs. 
      hidden_size: The hidden size for gat.
      activation: (default None) The activation for the output.
      num_heads: (default 1) The head number in gat.
      feat_drop: (default 0.6) Dropout rate for feature.
      attn_drop: (default 0.6) Dropout rate for attention.
      concat: (default True) Whether to concat output heads or average them.
class_docstr_tok: ["Implementation","of","graph","attention","networks","(","GAT",")","This","is","an","implementation","of","the","paper","GRAPH","ATTENTION","NETWORKS","(","https",":","\/\/arxiv.org\/abs\/1710.10903",")",".","Args",":","input_size",":","The","size","of","the","inputs",".","hidden_size",":","The","hidden","size","for","gat",".","activation",":","(","default","None",")","The","activation","for","the","output",".","num_heads",":","(","default","1",")","The","head","number","in","gat",".","feat_drop",":","(","default","0.6",")","Dropout","rate","for","feature",".","attn_drop",":","(","default","0.6",")","Dropout","rate","for","attention",".","concat",":","(","default","True",")","Whether","to","concat","output","heads","or","average","them","."]
docstr:  
  Args:
  
      graph: `pgl.Graph` instance.
      feature: A tensor with shape (num_nodes, input_size)
  
  Return:
      If `concat=True` then return a tensor with shape (num_nodes, hidden_size),
      else return a tensor with shape (num_nodes, hidden_size * num_heads) 
docstr_tok: ["Args",":","graph",":","`","pgl.Graph","`","instance",".","feature",":","A","tensor","with","shape","(","num_nodes",",","input_size",")","Return",":","If","`","concat=True","`","then","return","a","tensor","with","shape","(","num_nodes",",","hidden_size",")",",","else","return","a","tensor","with","shape","(","num_nodes",",","hidden_size","*","num_heads",")"]
code: def forward(self, graph, feature, pos, edge_feat=None):
      """
  
      Args:
  
          graph: `pgl.Graph` instance.
          feature: A tensor with shape (num_nodes, input_size)
  
      Return:
          If `concat=True` then return a tensor with shape (num_nodes, hidden_size),
          else return a tensor with shape (num_nodes, hidden_size * num_heads)
      """
  
      if self.feat_drop > 1e-15:
          feature = self.feat_dropout(feature)
  
      feature = self.linear(feature)
      feature = paddle.reshape(
          feature, [-1, self.num_heads, self.hidden_size]
      )
  
      attn_src = paddle.sum(feature * self.weight_src, axis=-1)
      attn_dst = paddle.sum(feature * self.weight_dst, axis=-1)
      if edge_feat is not None:
          msg = graph.send(
              self._send_attention,
              src_feat={"src": attn_src, "pos_src": pos, "h": feature},
              dst_feat={"dst": attn_dst, "pos_dst": pos},
              edge_feat={"edge_feat": edge_feat},
          )
      else:
          msg = graph.send(
              self._send_attention,
              src_feat={"src": attn_src, "pos_src": pos, "h": feature},
              dst_feat={"dst": attn_dst, "pos_dst": pos},
          )
      output = graph.recv(reduce_func=self._reduce_attention, msg=msg)
  
      if self.activation is not None:
          output = self.activation(output)
      return output
  
file_path: PGL/examples/NeurIPS2022-OGB-Challenge/MAG240M/models/gat_conv_peg.py
imports: import math
  import numpy
  import paddle
  import paddle.nn
  import paddle.nn.functional
  from pgl.utils.logger import log
  import pgl
  from pgl.nn import functional
label_desc: Use image node_id 4 for calling the GATConv obj's underlying member method code with example usage: obj.forward(graph, feature, pos, edge_feat) and returns: output