class_docstr: The Heterogeneous Graph Transformer (HGT) operator from the
  `"Heterogeneous Graph Transformer" <https://arxiv.org/abs/2003.01332>`_
  paper.
  
  .. note::
  
      For an example of using HGT, see `examples/hetero/hgt_dblp.py
      <https://github.com/pyg-team/pytorch_geometric/blob/master/examples/
      hetero/hgt_dblp.py>`_.
  
  Args:
      in_channels (int or Dict[str, int]): Size of each input sample of every
          node type, or :obj:`-1` to derive the size from the first input(s)
          to the forward method.
      out_channels (int): Size of each output sample.
      metadata (Tuple[List[str], List[Tuple[str, str, str]]]): The metadata
          of the heterogeneous graph, *i.e.* its node and edge types given
          by a list of strings and a list of string triplets, respectively.
          See :meth:`torch_geometric.data.HeteroData.metadata` for more
          information.
      heads (int, optional): Number of multi-head-attentions.
          (default: :obj:`1`)
      **kwargs (optional): Additional arguments of
          :class:`torch_geometric.nn.conv.MessagePassing`.
class_docstr_tok: ["The","Heterogeneous","Graph","Transformer","(","HGT",")","operator","from","the","`","``","Heterogeneous","Graph","Transformer","''","<","https",":","\/\/arxiv.org\/abs\/2003.01332",">","`","_","paper",".","..","note",":",":","For","an","example","of","using","HGT",",","see","`","examples\/hetero\/hgt_dblp.py","<","https",":","\/\/github.com\/pyg-team\/pytorch_geometric\/blob\/master\/examples\/","hetero\/hgt_dblp.py",">","`","_",".","Args",":","in_channels","(","int","or","Dict","[","str",",","int","]",")",":","Size","of","each","input","sample","of","every","node","type",",","or",":","obj",":","`","-1","`","to","derive","the","size","from","the","first","input","(","s",")","to","the","forward","method",".","out_channels","(","int",")",":","Size","of","each","output","sample",".","metadata","(","Tuple","[","List","[","str","]",",","List","[","Tuple","[","str",",","str",",","str","]","]","]",")",":","The","metadata","of","the","heterogeneous","graph",",","*","i.e",".","*","its","node","and","edge","types","given","by","a","list","of","strings","and","a","list","of","string","triplets",",","respectively",".","See",":","meth",":","`","torch_geometric.data.HeteroData.metadata","`","for","more","information",".","heads","(","int",",","optional",")",":","Number","of","multi-head-attentions",".","(","default",":",":","obj",":","`","1","`",")","*","*","kwargs","(","optional",")",":","Additional","arguments","of",":","class",":","`","torch_geometric.nn.conv.MessagePassing","`","."]
docstr: Runs the forward pass of the module.
  
  Args:
      x_dict (Dict[str, torch.Tensor]): A dictionary holding input node
          features  for each individual node type.
      edge_index_dict (Dict[Tuple[str, str, str], torch.Tensor]): A
          dictionary holding graph connectivity information for each
          individual edge type, either as a :class:`torch.Tensor` of
          shape :obj:`[2, num_edges]` or a
          :class:`torch_sparse.SparseTensor`.
  
  :rtype: :obj:`Dict[str, Optional[torch.Tensor]]` - The output node
      embeddings for each node type.
      In case a node type does not receive any message, its output will
      be set to :obj:`None`.
docstr_tok: ["Runs","the","forward","pass","of","the","module",".","Args",":","x_dict","(","Dict","[","str",",","torch.Tensor","]",")",":","A","dictionary","holding","input","node","features","for","each","individual","node","type",".","edge_index_dict","(","Dict","[","Tuple","[","str",",","str",",","str","]",",","torch.Tensor","]",")",":","A","dictionary","holding","graph","connectivity","information","for","each","individual","edge","type",",","either","as","a",":","class",":","`","torch.Tensor","`","of","shape",":","obj",":","`","[","2",",","num_edges","]","`","or","a",":","class",":","`","torch_sparse.SparseTensor","`",".",":","rtype",":",":","obj",":","`","Dict","[","str",",","Optional","[","torch.Tensor","]","]","`","-","The","output","node","embeddings","for","each","node","type",".","In","case","a","node","type","does","not","receive","any","message",",","its","output","will","be","set","to",":","obj",":","`","None","`","."]
code: def forward(
      self,
      x_dict: Dict[NodeType, Tensor],
      edge_index_dict: Dict[EdgeType, Adj],  # Support both.
  ) -> Dict[NodeType, Optional[Tensor]]:
      r"""Runs the forward pass of the module.
  
      Args:
          x_dict (Dict[str, torch.Tensor]): A dictionary holding input node
              features  for each individual node type.
          edge_index_dict (Dict[Tuple[str, str, str], torch.Tensor]): A
              dictionary holding graph connectivity information for each
              individual edge type, either as a :class:`torch.Tensor` of
              shape :obj:`[2, num_edges]` or a
              :class:`torch_sparse.SparseTensor`.
  
      :rtype: :obj:`Dict[str, Optional[torch.Tensor]]` - The output node
          embeddings for each node type.
          In case a node type does not receive any message, its output will
          be set to :obj:`None`.
      """
      F = self.out_channels
      H = self.heads
      D = F // H
  
      k_dict, q_dict, v_dict, out_dict = {}, {}, {}, {}
  
      # Compute K, Q, V over node types:
      kqv_dict = self.kqv_lin(x_dict)
      for key, val in kqv_dict.items():
          k, q, v = torch.tensor_split(val, 3, dim=1)
          k_dict[key] = k.view(-1, H, D)
          q_dict[key] = q.view(-1, H, D)
          v_dict[key] = v.view(-1, H, D)
  
      q, dst_offset = self._cat(q_dict)
      k, v, src_offset = self._construct_src_node_feat(
          k_dict, v_dict, edge_index_dict
      )
  
      edge_index, edge_attr = construct_bipartite_edge_index(
          edge_index_dict,
          src_offset,
          dst_offset,
          edge_attr_dict=self.p_rel,
      )
  
      out = self.propagate(
          edge_index, k=k, q=q, v=v, edge_attr=edge_attr
      )
  
      # Reconstruct output node embeddings dict:
      for node_type, start_offset in dst_offset.items():
          end_offset = start_offset + q_dict[node_type].size(0)
          if node_type in self.dst_node_types:
              out_dict[node_type] = out[start_offset:end_offset]
  
      # Transform output node embeddings:
      a_dict = self.out_lin(
          {
              k: torch.nn.functional.gelu(v) if v is not None else v
              for k, v in out_dict.items()
          }
      )
  
      # Iterate over node types:
      for node_type, out in out_dict.items():
          out = a_dict[node_type]
  
          if out.size(-1) == x_dict[node_type].size(-1):
              alpha = self.skip[node_type].sigmoid()
              out = alpha * out + (1 - alpha) * x_dict[node_type]
          out_dict[node_type] = out
  
      return out_dict
  
imports: import math
  from typing import Dict, List, Optional, Tuple, Union
  import torch
  from torch import Tensor
  from torch.nn import Parameter
  from torch_geometric.nn.conv import MessagePassing
  from torch_geometric.nn.dense import HeteroDictLinear, HeteroLinear
  from torch_geometric.nn.inits import ones
  from torch_geometric.nn.parameter_dict import ParameterDict
  from torch_geometric.typing import Adj, EdgeType, Metadata, NodeType
  from torch_geometric.utils import softmax
  from torch_geometric.utils.hetero import construct_bipartite_edge_index
label_desc: Use image node_id 5 for calling the HGTConv obj's underlying member method code with example usage: obj.forward(x_dict, edge_index_dict) and returns: out_dict