class_docstr: Apply dot product version of self attention in `Graph Attention Network
  <https://arxiv.org/pdf/1710.10903.pdf>`__
  
      .. math::
          h_i^{(l+1)} = \sum_{j\in \mathcal{N}(i)} \alpha_{i, j} h_j^{(l)}
  
      where :math:`\alpha_{ij}` is the attention score bewteen node :math:`i` and node :math:`j`:
  
      .. math::
          \alpha_{i, j} &= \mathrm{softmax_i}(e_{ij}^{l})
  
          e_{ij}^{l} &= ({W_i^{(l)} h_i^{(l)}})^T \cdot {W_j^{(l)} h_j^{(l)}}
  
      where :math:`W_i` and :math:`W_j` transform node :math:`i`'s and node :math:`j`'s
      features into the same dimension, so that when compute note features' similarity,
      it can use dot-product.
  
  Parameters
  ----------
  in_feats : int, or pair of ints
      Input feature size; i.e, the number of dimensions of :math:`h_i^{(l)}`.
      DotGatConv can be applied on homogeneous graph and unidirectional
      `bipartite graph <https://docs.dgl.ai/generated/dgl.bipartite.html?highlight=bipartite>`__.
      If the layer is to be applied to a unidirectional bipartite graph, ``in_feats``
      specifies the input feature size on both the source and destination nodes.  If
      a scalar is given, the source and destination node feature size would take the
      same value.
  out_feats : int
      Output feature size; i.e, the number of dimensions of :math:`h_i^{(l+1)}`.
  num_heads : int
      Number of head in Multi-Head Attention
  allow_zero_in_degree : bool, optional
      If there are 0-in-degree nodes in the graph, output for those nodes will be invalid
      since no message will be passed to those nodes. This is harmful for some applications
      causing silent performance regression. This module will raise a DGLError if it detects
      0-in-degree nodes in input graph. By setting ``True``, it will suppress the check
      and let the users handle it by themselves. Default: ``False``.
  
  Note
  ----
  Zero in-degree nodes will lead to invalid output value. This is because no message
  will be passed to those nodes, the aggregation function will be appied on empty input.
  A common practice to avoid this is to add a self-loop for each node in the graph if
  it is homogeneous, which can be achieved by:
  
  >>> g = ... # a DGLGraph
  >>> g = dgl.add_self_loop(g)
  
  Calling ``add_self_loop`` will not work for some graphs, for example, heterogeneous graph
  since the edge type can not be decided for self_loop edges. Set ``allow_zero_in_degree``
  to ``True`` for those cases to unblock the code and handle zero-in-degree nodes manually.
  A common practise to handle this is to filter out the nodes with zero-in-degree when use
  after conv.
  
  Examples
  --------
  >>> import dgl
  >>> import numpy as np
  >>> import torch as th
  >>> from dgl.nn import DotGatConv
  
  >>> # Case 1: Homogeneous graph
  >>> g = dgl.graph(([0,1,2,3,2,5], [1,2,3,4,0,3]))
  >>> g = dgl.add_self_loop(g)
  >>> feat = th.ones(6, 10)
  >>> dotgatconv = DotGatConv(10, 2, num_heads=3)
  >>> res = dotgatconv(g, feat)
  >>> res
  tensor([[[ 3.4570,  1.8634],
          [ 1.3805, -0.0762],
          [ 1.0390, -1.1479]],
          [[ 3.4570,  1.8634],
          [ 1.3805, -0.0762],
          [ 1.0390, -1.1479]],
          [[ 3.4570,  1.8634],
          [ 1.3805, -0.0762],
          [ 1.0390, -1.1479]],
          [[ 3.4570,  1.8634],
          [ 1.3805, -0.0762],
          [ 1.0390, -1.1479]],
          [[ 3.4570,  1.8634],
          [ 1.3805, -0.0762],
          [ 1.0390, -1.1479]],
          [[ 3.4570,  1.8634],
          [ 1.3805, -0.0762],
          [ 1.0390, -1.1479]]], grad_fn=<BinaryReduceBackward>)
  
  >>> # Case 2: Unidirectional bipartite graph
  >>> u = [0, 1, 0, 0, 1]
  >>> v = [0, 1, 2, 3, 2]
  >>> g = dgl.heterograph({('_N', '_E', '_N'):(u, v)})
  >>> u_feat = th.tensor(np.random.rand(2, 5).astype(np.float32))
  >>> v_feat = th.tensor(np.random.rand(4, 10).astype(np.float32))
  >>> dotgatconv = DotGatConv((5,10), 2, 3)
  >>> res = dotgatconv(g, (u_feat, v_feat))
  >>> res
  tensor([[[-0.6066,  1.0268],
          [-0.5945, -0.4801],
          [ 0.1594,  0.3825]],
          [[ 0.0268,  1.0783],
          [ 0.5041, -1.3025],
          [ 0.6568,  0.7048]],
          [[-0.2688,  1.0543],
          [-0.0315, -0.9016],
          [ 0.3943,  0.5347]],
          [[-0.6066,  1.0268],
          [-0.5945, -0.4801],
          [ 0.1594,  0.3825]]], grad_fn=<BinaryReduceBackward>)
code: def __init__(
      self, in_feats, out_feats, num_heads, allow_zero_in_degree=False
  ):
      super(DotGatConv, self).__init__()
      self._in_src_feats, self._in_dst_feats = expand_as_pair(in_feats)
      self._out_feats = out_feats
      self._allow_zero_in_degree = allow_zero_in_degree
      self._num_heads = num_heads
  
      if isinstance(in_feats, tuple):
          self.fc_src = nn.Linear(
              self._in_src_feats,
              self._out_feats * self._num_heads,
              bias=False,
          )
          self.fc_dst = nn.Linear(
              self._in_dst_feats,
              self._out_feats * self._num_heads,
              bias=False,
          )
      else:
          self.fc = nn.Linear(
              self._in_src_feats,
              self._out_feats * self._num_heads,
              bias=False,
          )
  
file_path: dgl/python/dgl/nn/pytorch/conv/dotgatconv.py
imports: from torch import nn
  from ....None import function
  from ....base import DGLError
  from ....utils import expand_as_pair
  from ...functional import edge_softmax
label_desc: Use image node_id 1 to create a new DotGatConv object from inherited base classes: nn with example: obj = DotGatConv(in_feats, out_feats, num_heads, allow_zero_in_degree)