class_docstr: The Heterogenous Graph Attention Operator from the
  `"Heterogenous Graph Attention Network"
  <https://arxiv.org/pdf/1903.07293.pdf>`_ paper.
  
  .. note::
  
      For an example of using HANConv, see `examples/hetero/han_imdb.py
      <https://github.com/pyg-team/pytorch_geometric/blob/master/examples/
      hetero/han_imdb.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`)
      negative_slope (float, optional): LeakyReLU angle of the negative
          slope. (default: :obj:`0.2`)
      dropout (float, optional): Dropout probability of the normalized
          attention coefficients which exposes each node to a stochastically
          sampled neighborhood during training. (default: :obj:`0`)
      **kwargs (optional): Additional arguments of
          :class:`torch_geometric.nn.conv.MessagePassing`.
class_docstr_tok: ["The","Heterogenous","Graph","Attention","Operator","from","the","`","``","Heterogenous","Graph","Attention","Network","''","<","https",":","\/\/arxiv.org\/pdf\/1903.07293.pdf",">","`","_","paper",".","..","note",":",":","For","an","example","of","using","HANConv",",","see","`","examples\/hetero\/han_imdb.py","<","https",":","\/\/github.com\/pyg-team\/pytorch_geometric\/blob\/master\/examples\/","hetero\/han_imdb.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","`",")","negative_slope","(","float",",","optional",")",":","LeakyReLU","angle","of","the","negative","slope",".","(","default",":",":","obj",":","`","0.2","`",")","dropout","(","float",",","optional",")",":","Dropout","probability","of","the","normalized","attention","coefficients","which","exposes","each","node","to","a","stochastically","sampled","neighborhood","during","training",".","(","default",":",":","obj",":","`","0","`",")","*","*","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 node feature
          information 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`.
      return_semantic_attention_weights (bool, optional): If set to
          :obj:`True`, will additionally return the semantic-level
          attention weights for each destination node type.
          (default: :obj:`False`)
docstr_tok: ["Runs","the","forward","pass","of","the","module",".","Args",":","x_dict","(","Dict","[","str",",","torch.Tensor","]",")",":","A","dictionary","holding","node","feature","information","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","`",".","return_semantic_attention_weights","(","bool",",","optional",")",":","If","set","to",":","obj",":","`","True","`",",","will","additionally","return","the","semantic-level","attention","weights","for","each","destination","node","type",".","(","default",":",":","obj",":","`","False","`",")"]
code: def forward(
      self,
      x_dict: Dict[NodeType, Tensor],
      edge_index_dict: Dict[EdgeType, Adj],
      return_semantic_attention_weights: bool = False,
  ) -> Union[
      Dict[NodeType, OptTensor],
      Tuple[Dict[NodeType, OptTensor], Dict[NodeType, OptTensor]],
  ]:
      r"""Runs the forward pass of the module.
  
      Args:
          x_dict (Dict[str, torch.Tensor]): A dictionary holding node feature
              information 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`.
          return_semantic_attention_weights (bool, optional): If set to
              :obj:`True`, will additionally return the semantic-level
              attention weights for each destination node type.
              (default: :obj:`False`)
      """
      H, D = self.heads, self.out_channels // self.heads
      x_node_dict, out_dict = {}, {}
  
      # Iterate over node types:
      for node_type, x in x_dict.items():
          x_node_dict[node_type] = self.proj[node_type](x).view(
              -1, H, D
          )
          out_dict[node_type] = []
  
      # Iterate over edge types:
      for edge_type, edge_index in edge_index_dict.items():
          src_type, _, dst_type = edge_type
          edge_type = "__".join(edge_type)
          lin_src = self.lin_src[edge_type]
          lin_dst = self.lin_dst[edge_type]
          x_src = x_node_dict[src_type]
          x_dst = x_node_dict[dst_type]
          alpha_src = (x_src * lin_src).sum(dim=-1)
          alpha_dst = (x_dst * lin_dst).sum(dim=-1)
          # propagate_type: (x: PairTensor, alpha: PairTensor)
          out = self.propagate(
              edge_index, x=(x_src, x_dst), alpha=(alpha_src, alpha_dst)
          )
  
          out = F.relu(out)
          out_dict[dst_type].append(out)
  
      # iterate over node types:
      semantic_attn_dict = {}
      for node_type, outs in out_dict.items():
          out, attn = group(outs, self.q, self.k_lin)
          out_dict[node_type] = out
          semantic_attn_dict[node_type] = attn
  
      if return_semantic_attention_weights:
          return out_dict, semantic_attn_dict
  
      return out_dict
  
file_path: pytorch_geometric/torch_geometric/nn/conv/han_conv.py
imports: from typing import Dict, List, Optional, Tuple, Union
  import torch
  import torch.nn.functional
  from torch import Tensor, nn
  from torch_geometric.nn.conv import MessagePassing
  from torch_geometric.nn.dense import Linear
  from torch_geometric.nn.inits import glorot, reset
  from torch_geometric.typing import PairTensor
  from torch_geometric.typing import Adj, EdgeType, Metadata, NodeType, OptTensor
  from torch_geometric.utils import softmax
label_desc: Use image node_id 3 for calling the HANConv obj's underlying member method code with example usage: obj.forward(x_dict, edge_index_dict, return_semantic_attention_weights) and returns: out_dict, out_dict,  semantic_attn_dict