code: def __init__(
      self, module: MessagePassing, num_relations: int, num_bases: int
  ):
      super().__init__()
  
      self.num_relations = num_relations
      self.num_bases = num_bases
  
      # We make use of a post-message computation hook to inject the
      # basis re-weighting for each individual edge type.
      # This currently requires us to set `conv.fuse = False`, which leads
      # to a materialization of messages.
      def hook(module, inputs, output):
          assert isinstance(module._edge_type, Tensor)
          if module._edge_type.size(0) != output.size(-2):
              raise ValueError(
                  f"Number of messages ({output.size(0)}) does not match "
                  f"with the number of original edges "
                  f"({module._edge_type.size(0)}). Does your message "
                  f"passing layer create additional self-loops? Try to "
                  f"remove them via 'add_self_loops=False'"
              )
          weight = module.edge_type_weight.view(-1)[module._edge_type]
          weight = weight.view([1] * (output.dim() - 2) + [-1, 1])
          return weight * output
  
      params = list(module.parameters())
      device = params[0].device if len(params) > 0 else "cpu"
  
      self.convs = torch.nn.ModuleList()
      for _ in range(num_bases):
          conv = copy.deepcopy(module)
          conv.fuse = (
              False  # Disable `message_and_aggregate` functionality.
          )
          # We learn a single scalar weight for each individual edge type,
          # which is used to weight the output message based on edge type:
          conv.edge_type_weight = Parameter(
              torch.empty(1, num_relations, device=device)
          )
          conv.register_message_forward_hook(hook)
          self.convs.append(conv)
  
      if self.num_bases > 1:
          self.reset_parameters()
  
imports: import copy
  import warnings
  from typing import Any, Dict, List, Optional, Union
  import torch
  from torch import Tensor
  from torch.nn import Module, Parameter
  from torch_geometric.nn.conv import MessagePassing
  from torch_geometric.nn.dense import Linear
  from torch_geometric.nn.fx import Transformer
  from torch_geometric.typing import EdgeType, Metadata, NodeType, SparseTensor
  from torch_geometric.utils.hetero import get_unused_node_types
label_desc: Use image node_id 1 to create a new HeteroBasisConv object from inherited base classes: torch.nn with example: obj = HeteroBasisConv(module, num_relations, num_bases)