code: def test_to_hetero_with_bases():
      metadata = (
          ["paper", "author"],
          [
              ("paper", "cites", "paper"),
              ("paper", "written_by", "author"),
              ("author", "writes", "paper"),
          ],
      )
  
      x_dict = {
          "paper": torch.randn(100, 16),
          "author": torch.randn(100, 8),
      }
      edge_index_dict = {
          ("paper", "cites", "paper"): torch.randint(
              100, (2, 200), dtype=torch.long
          ),
          ("paper", "written_by", "author"): torch.randint(
              100, (2, 200), dtype=torch.long
          ),
          ("author", "writes", "paper"): torch.randint(
              100, (2, 200), dtype=torch.long
          ),
      }
      edge_attr_dict = {
          ("paper", "cites", "paper"): torch.randn(200, 8),
          ("paper", "written_by", "author"): torch.randn(200, 8),
          ("author", "writes", "paper"): torch.randn(200, 8),
      }
  
      model = Net1()
      in_channels = {"x": 16, "edge_attr": 8}
      model = to_hetero_with_bases(
          model,
          metadata,
          num_bases=4,
          in_channels=in_channels,
          debug=False,
      )
      out = model(x_dict, edge_attr_dict)
      assert isinstance(out, tuple) and len(out) == 2
      assert isinstance(out[0], dict) and len(out[0]) == 2
      assert out[0]["paper"].size() == (100, 32)
      assert out[0]["author"].size() == (100, 32)
      assert isinstance(out[1], dict) and len(out[1]) == 3
      assert out[1][("paper", "cites", "paper")].size() == (200, 16)
      assert out[1][("paper", "written_by", "author")].size() == (
          200,
          16,
      )
      assert out[1][("author", "writes", "paper")].size() == (200, 16)
      assert sum(p.numel() for p in model.parameters()) == 1264
  
      model = Net2()
      in_channels = {"x": 16}
      model = to_hetero_with_bases(
          model,
          metadata,
          num_bases=4,
          in_channels=in_channels,
          debug=False,
      )
      out = model(x_dict, edge_index_dict)
      assert isinstance(out, dict) and len(out) == 2
      assert out["paper"].size() == (100, 32)
      assert out["author"].size() == (100, 32)
      assert sum(p.numel() for p in model.parameters()) == 5948
  
      model = Net3()
      in_channels = {"x": 16, "edge_attr": 8}
      model = to_hetero_with_bases(
          model,
          metadata,
          num_bases=4,
          in_channels=in_channels,
          debug=False,
      )
      out = model(x_dict, edge_index_dict, edge_attr_dict)
      assert isinstance(out, dict) and len(out) == 2
      assert out["paper"].size() == (100, 32)
      assert out["author"].size() == (100, 32)
  
      model = Net4()
      in_channels = {"x0": 16}
      model = to_hetero_with_bases(
          model,
          metadata,
          num_bases=4,
          in_channels=in_channels,
          debug=False,
      )
      out = model(x_dict, edge_index_dict)
      assert isinstance(out, dict) and len(out) == 2
      assert out["paper"].size() == (100, 32)
      assert out["author"].size() == (100, 32)
  
      model = Net5(num_layers=2)
      in_channels = {"x": 16}
      model = to_hetero_with_bases(
          model,
          metadata,
          num_bases=4,
          in_channels=in_channels,
          debug=False,
      )
      out = model(x_dict, edge_index_dict)
      assert isinstance(out, dict) and len(out) == 2
      assert out["paper"].size() == (100, 16)
      assert out["author"].size() == (100, 16)
  
      model = Net6(num_layers=2)
      in_channels = {"x": 16}
      model = to_hetero_with_bases(
          model,
          metadata,
          num_bases=4,
          in_channels=in_channels,
          debug=False,
      )
      out = model(x_dict, edge_index_dict)
      assert isinstance(out, dict) and len(out) == 2
      assert out["paper"].size() == (100, 16)
      assert out["author"].size() == (100, 16)
  
      model = Net7()
      in_channels = {"x": 16}
      model = to_hetero_with_bases(
          model,
          metadata,
          num_bases=4,
          in_channels=in_channels,
          debug=False,
      )
      out = model(x_dict, edge_index_dict)
      assert isinstance(out, dict) and len(out) == 2
      assert out["paper"].size() == (100, 32)
      assert out["author"].size() == (100, 32)
  
imports: from typing import Tuple
  import pytest
  import torch
  from torch import Tensor
  from torch.nn import Linear, ReLU, Sequential
  import torch_geometric.typing
  from torch_geometric.nn import GINEConv, MessagePassing, RGCNConv, SAGEConv, to_hetero_with_bases
  from torch_geometric.typing import SparseTensor
label_desc: Use image node_id 1 for calling a global function with example usage: test_to_hetero_with_bases() without return types