code: def test_add_random_metapaths() -> None:
      data = generate_data()
  
      # Test transform options:
      metapaths = [[("p", "c"), ("c", "p")]]
      torch.manual_seed(12345)
  
      transform = AddRandomMetaPaths(metapaths)
      assert str(transform) == (
          "AddRandomMetaPaths(sample_ratio=1.0, " "walks_per_node=[1])"
      )
      meta1 = transform(data)
  
      transform = AddRandomMetaPaths(
          metapaths, drop_orig_edge_types=True
      )
      assert str(transform) == (
          "AddRandomMetaPaths(sample_ratio=1.0, " "walks_per_node=[1])"
      )
      meta2 = transform(data)
  
      transform = AddRandomMetaPaths(
          metapaths, drop_orig_edge_types=True, keep_same_node_type=True
      )
      assert str(transform) == (
          "AddRandomMetaPaths(sample_ratio=1.0, " "walks_per_node=[1])"
      )
      meta3 = transform(data)
  
      transform = AddRandomMetaPaths(
          metapaths,
          drop_orig_edge_types=True,
          keep_same_node_type=True,
          drop_unconnected_node_types=True,
      )
      assert str(transform) == (
          "AddRandomMetaPaths(sample_ratio=1.0, " "walks_per_node=[1])"
      )
      meta4 = transform(data)
  
      transform = AddRandomMetaPaths(
          metapaths,
          sample_ratio=0.8,
          drop_orig_edge_types=True,
          keep_same_node_type=True,
          drop_unconnected_node_types=True,
      )
      assert str(transform) == (
          "AddRandomMetaPaths(sample_ratio=0.8, " "walks_per_node=[1])"
      )
      meta5 = transform(data)
  
      transform = AddRandomMetaPaths(
          metapaths,
          walks_per_node=5,
          drop_orig_edge_types=True,
          keep_same_node_type=True,
          drop_unconnected_node_types=True,
      )
      assert str(transform) == (
          "AddRandomMetaPaths(sample_ratio=1.0, " "walks_per_node=[5])"
      )
      meta6 = transform(data)
  
      assert meta1["metapath_0"].edge_index.size() == (2, 5)
      assert meta2["metapath_0"].edge_index.size() == (2, 5)
      assert meta3["metapath_0"].edge_index.size() == (2, 5)
      assert meta4["metapath_0"].edge_index.size() == (2, 5)
      assert meta5["metapath_0"].edge_index.size() == (2, 4)
      assert meta6["metapath_0"].edge_index.size() == (2, 7)
  
      assert all([i in meta1.edge_types for i in data.edge_types])
      assert meta2.edge_types == [("p", "metapath_0", "p")]
      assert meta3.edge_types == [
          ("p", "to", "p"),
          ("p", "metapath_0", "p"),
      ]
      assert meta4.edge_types == [
          ("p", "to", "p"),
          ("p", "metapath_0", "p"),
      ]
  
      assert meta3.node_types == ["p", "a", "c"]
      assert meta4.node_types == ["p"]
  
      # Test 4-hop metapath:
      metapaths = [
          [("a", "p"), ("p", "c")],
          [("a", "p"), ("p", "c"), ("c", "p"), ("p", "a")],
      ]
      transform = AddRandomMetaPaths(metapaths)
      assert str(transform) == (
          "AddRandomMetaPaths(sample_ratio=1.0, "
          "walks_per_node=[1, 1])"
      )
  
      meta1 = transform(data)
      new_edge_types = [
          ("a", "metapath_0", "c"),
          ("a", "metapath_1", "a"),
      ]
      assert meta1["metapath_0"].edge_index.size() == (2, 2)
      assert meta1["metapath_1"].edge_index.size() == (2, 2)
  
      # Test `metapath_dict` information:
      assert list(meta1.metapath_dict.values()) == metapaths
      assert list(meta1.metapath_dict.keys()) == new_edge_types
  
      transform = AddRandomMetaPaths(metapaths, walks_per_node=[2, 5])
      assert str(transform) == (
          "AddRandomMetaPaths(sample_ratio=1.0, "
          "walks_per_node=[2, 5])"
      )
  
      meta2 = transform(data)
      new_edge_types = [
          ("a", "metapath_0", "c"),
          ("a", "metapath_1", "a"),
      ]
      assert meta2["metapath_0"].edge_index.size() == (2, 2)
      assert meta2["metapath_1"].edge_index.size() == (2, 3)
  
file_path: pytorch_geometric/test/transforms/test_add_metapaths.py
imports: import torch
  from torch import tensor
  from torch_geometric.data import HeteroData
  from torch_geometric.transforms import AddMetaPaths, AddRandomMetaPaths
  from torch_geometric.utils import coalesce
label_desc: Use image node_id 5 for calling a global function with example usage: test_add_random_metapaths() without return types