class_docstr: Heterogeneous graph transformer convolution from `Heterogeneous Graph Transformer
  <https://arxiv.org/abs/2003.01332>`__
  
  Given a graph :math:`G(V, E)` and input node features :math:`H^{(l-1)}`,
  it computes the new node features as follows:
  
  Compute a multi-head attention score for each edge :math:`(s, e, t)` in the graph:
  
  .. math::
  
    Attention(s, e, t) = \text{Softmax}\left(||_{i\in[1,h]}ATT-head^i(s, e, t)\right) \\
    ATT-head^i(s, e, t) = \left(K^i(s)W^{ATT}_{\phi(e)}Q^i(t)^{\top}\right)\cdot
      \frac{\mu_{(\tau(s),\phi(e),\tau(t)}}{\sqrt{d}} \\
    K^i(s) = \text{K-Linear}^i_{\tau(s)}(H^{(l-1)}[s]) \\
    Q^i(t) = \text{Q-Linear}^i_{\tau(t)}(H^{(l-1)}[t]) \\
  
  Compute the message to send on each edge :math:`(s, e, t)`:
  
  .. math::
  
    Message(s, e, t) = ||_{i\in[1, h]} MSG-head^i(s, e, t) \\
    MSG-head^i(s, e, t) = \text{M-Linear}^i_{\tau(s)}(H^{(l-1)}[s])W^{MSG}_{\phi(e)} \\
  
  Send messages to target nodes :math:`t` and aggregate:
  
  .. math::
  
    \tilde{H}^{(l)}[t] = \sum_{\forall s\in \mathcal{N}(t)}\left( Attention(s,e,t)
    \cdot Message(s,e,t)\right)
  
  Compute new node features:
  
  .. math::
  
    H^{(l)}[t]=\text{A-Linear}_{\tau(t)}(\sigma(\tilde(H)^{(l)}[t])) + H^{(l-1)}[t]
  
  Parameters
  ----------
  in_size : int
      Input node feature size.
  head_size : int
      Output head size. The output node feature size is ``head_size * num_heads``.
  num_heads : int
      Number of heads. The output node feature size is ``head_size * num_heads``.
  num_ntypes : int
      Number of node types.
  num_etypes : int
      Number of edge types.
  dropout : optional, float
      Dropout rate.
  use_norm : optiona, bool
      If true, apply a layer norm on the output node feature.
  
  Examples
  --------
class_docstr_tok: ["Heterogeneous","graph","transformer","convolution","from","`","Heterogeneous","Graph","Transformer","<","https",":","\/\/arxiv.org\/abs\/2003.01332",">","`","__","Given","a","graph",":","math",":","`","G","(","V",",","E",")","`","and","input","node","features",":","math",":","`","H^","{","(","l-1",")","}","`",",","it","computes","the","new","node","features","as","follows",":","Compute","a","multi-head","attention","score","for","each","edge",":","math",":","`","(","s",",","e",",","t",")","`","in","the","graph",":","..","math",":",":","Attention","(","s",",","e",",","t",")","=","\\text","{","Softmax","}","\\left","(","||_","{","i\\in","[","1",",","h","]","}","ATT-head^i","(","s",",","e",",","t",")","\\right",")","\\\\","ATT-head^i","(","s",",","e",",","t",")","=","\\left","(","K^i","(","s",")","W^","{","ATT","}","_","{","\\phi","(","e",")","}","Q^i","(","t",")","^","{","\\top","}","\\right",")","\\cdot","\\frac","{","\\mu_","{","(","\\tau","(","s",")",",","\\phi","(","e",")",",","\\tau","(","t",")","}","}","{","\\sqrt","{","d","}","}","\\\\","K^i","(","s",")","=","\\text","{","K-Linear","}","^i_","{","\\tau","(","s",")","}","(","H^","{","(","l-1",")","}","[","s","]",")","\\\\","Q^i","(","t",")","=","\\text","{","Q-Linear","}","^i_","{","\\tau","(","t",")","}","(","H^","{","(","l-1",")","}","[","t","]",")","\\\\","Compute","the","message","to","send","on","each","edge",":","math",":","`","(","s",",","e",",","t",")","`",":","..","math",":",":","Message","(","s",",","e",",","t",")","=","||_","{","i\\in","[","1",",","h","]","}","MSG-head^i","(","s",",","e",",","t",")","\\\\","MSG-head^i","(","s",",","e",",","t",")","=","\\text","{","M-Linear","}","^i_","{","\\tau","(","s",")","}","(","H^","{","(","l-1",")","}","[","s","]",")","W^","{","MSG","}","_","{","\\phi","(","e",")","}","\\\\","Send","messages","to","target","nodes",":","math",":","`","t","`","and","aggregate",":","..","math",":",":","\\tilde","{","H","}","^","{","(","l",")","}","[","t","]","=","\\sum_","{","\\forall","s\\in","\\mathcal","{","N","}","(","t",")","}","\\left","(","Attention","(","s",",","e",",","t",")","\\cdot","Message","(","s",",","e",",","t",")","\\right",")","Compute","new","node","features",":","..","math",":",":","H^","{","(","l",")","}","[","t","]","=\\text","{","A-Linear","}","_","{","\\tau","(","t",")","}","(","\\sigma","(","\\tilde","(","H",")","^","{","(","l",")","}","[","t","]",")",")","+","H^","{","(","l-1",")","}","[","t","]","Parameters","--","--","--","--","--","in_size",":","int","Input","node","feature","size",".","head_size",":","int","Output","head","size",".","The","output","node","feature","size","is","``","head_size","*","num_heads","``",".","num_heads",":","int","Number","of","heads",".","The","output","node","feature","size","is","``","head_size","*","num_heads","``",".","num_ntypes",":","int","Number","of","node","types",".","num_etypes",":","int","Number","of","edge","types",".","dropout",":","optional",",","float","Dropout","rate",".","use_norm",":","optiona",",","bool","If","true",",","apply","a","layer","norm","on","the","output","node","feature",".","Examples","--","--","--","--"]
docstr: Message function.
docstr_tok: ["Message","function","."]
code: def message(self, edges):
      """Message function."""
      a, m = [], []
      etype = edges.data["etype"]
      k = torch.unbind(edges.src["k"], dim=1)
      q = torch.unbind(edges.dst["q"], dim=1)
      v = torch.unbind(edges.src["v"], dim=1)
      for i in range(self.num_heads):
          kw = self.relation_att[i](
              k[i], etype, self.presorted
          )  # (E, O)
          a.append(
              (kw * q[i]).sum(-1)
              * self.relation_pri[i][etype]
              / self.sqrt_d
          )  # (E,)
          m.append(
              self.relation_msg[i](v[i], etype, self.presorted)
          )  # (E, O)
      return {"a": torch.stack(a, dim=1), "m": torch.stack(m, dim=1)}
  
file_path: dgl/python/dgl/nn/pytorch/conv/hgtconv.py
imports: import math
  import torch
  import torch.nn
  from ....None import function
  from ..linear import TypedLinear
  from ..softmax import edge_softmax
label_desc: Use image node_id 3 for calling the HGTConv obj's underlying member method code with example usage: obj.message(edges) and returns: dict