class_docstr: Dense Multi-Head Attention Module with Graph Attention Bias.
  
  Compute attention between nodes with attention bias obtained from graph
  structures, as introduced in `Do Transformers Really Perform Bad for
  Graph Representation? <https://arxiv.org/pdf/2106.05234>`__
  
  .. math::
  
      \text{Attn}=\text{softmax}(\dfrac{QK^T}{\sqrt{d}} \circ b)
  
  :math:`Q` and :math:`K` are feature representations of nodes. :math:`d`
  is the corresponding :attr:`feat_size`. :math:`b` is attention bias, which
  can be additive or multiplicative according to the operator :math:`\circ`.
  
  Parameters
  ----------
  feat_size : int
      Feature size.
  num_heads : int
      Number of attention heads, by which :attr:`feat_size` is divisible.
  bias : bool, optional
      If True, it uses bias for linear projection. Default: True.
  attn_bias_type : str, optional
      The type of attention bias used for modifying attention. Selected from
      'add' or 'mul'. Default: 'add'.
  
      * 'add' is for additive attention bias.
      * 'mul' is for multiplicative attention bias.
  attn_drop : float, optional
      Dropout probability on attention weights. Defalt: 0.1.
  
  Examples
  --------
  >>> import torch as th
  >>> from dgl.nn import BiasedMHA
  
  >>> ndata = th.rand(16, 100, 512)
  >>> bias = th.rand(16, 100, 100, 8)
  >>> net = BiasedMHA(feat_size=512, num_heads=8)
  >>> out = net(ndata, bias)
code: def __init__(
      self,
      feat_size,
      num_heads,
      bias=True,
      attn_bias_type="add",
      attn_drop=0.1,
  ):
      super().__init__()
      self.feat_size = feat_size
      self.num_heads = num_heads
      self.head_dim = feat_size // num_heads
      assert (
          self.head_dim * num_heads == feat_size
      ), "feat_size must be divisible by num_heads"
      self.scaling = self.head_dim**-0.5
      self.attn_bias_type = attn_bias_type
  
      self.q_proj = nn.Linear(feat_size, feat_size, bias=bias)
      self.k_proj = nn.Linear(feat_size, feat_size, bias=bias)
      self.v_proj = nn.Linear(feat_size, feat_size, bias=bias)
      self.out_proj = nn.Linear(feat_size, feat_size, bias=bias)
  
      self.dropout = nn.Dropout(p=attn_drop)
  
      self.reset_parameters()
  
file_path: dgl/python/dgl/nn/pytorch/gt/biased_mha.py
imports: import torch
  import torch.nn
  import torch.nn.functional
label_desc: Use image node_id 1 to create a new BiasedMHA object from inherited base classes: nn with example: obj = BiasedMHA(feat_size, num_heads, bias, attn_bias_type, attn_drop)