code: def test_module_add_metapaths(idtype):
      g = dgl.heterograph(
          {
              ("person", "author", "paper"): ([0, 0, 1], [1, 2, 2]),
              ("paper", "accepted", "venue"): ([1], [0]),
              ("paper", "rejected", "venue"): ([2], [1]),
          },
          idtype=idtype,
          device=F.ctx(),
      )
      g.nodes["venue"].data["h"] = F.randn((g.num_nodes("venue"), 2))
      g.edges["author"].data["h"] = F.randn((g.num_edges("author"), 3))
  
      # Case1: keep_orig_edges is True
      metapaths = {
          "accepted": [
              ("person", "author", "paper"),
              ("paper", "accepted", "venue"),
          ],
          "rejected": [
              ("person", "author", "paper"),
              ("paper", "rejected", "venue"),
          ],
      }
      transform = dgl.AddMetaPaths(metapaths)
      new_g = transform(g)
      assert new_g.device == g.device
      assert new_g.idtype == g.idtype
      assert new_g.ntypes == g.ntypes
      assert set(new_g.canonical_etypes) == {
          ("person", "author", "paper"),
          ("paper", "accepted", "venue"),
          ("paper", "rejected", "venue"),
          ("person", "accepted", "venue"),
          ("person", "rejected", "venue"),
      }
      for nty in new_g.ntypes:
          assert new_g.num_nodes(nty) == g.num_nodes(nty)
      for ety in g.canonical_etypes:
          assert new_g.num_edges(ety) == g.num_edges(ety)
      assert F.allclose(
          g.nodes["venue"].data["h"], new_g.nodes["venue"].data["h"]
      )
      assert F.allclose(
          g.edges["author"].data["h"], new_g.edges["author"].data["h"]
      )
  
      src, dst = new_g.edges(etype=("person", "accepted", "venue"))
      eset = set(zip(list(F.asnumpy(src)), list(F.asnumpy(dst))))
      assert eset == {(0, 0)}
  
      src, dst = new_g.edges(etype=("person", "rejected", "venue"))
      eset = set(zip(list(F.asnumpy(src)), list(F.asnumpy(dst))))
      assert eset == {(0, 1), (1, 1)}
  
      # Case2: keep_orig_edges is False
      transform = dgl.AddMetaPaths(metapaths, keep_orig_edges=False)
      new_g = transform(g)
      assert new_g.device == g.device
      assert new_g.idtype == g.idtype
      assert new_g.ntypes == g.ntypes
      assert len(new_g.canonical_etypes) == 2
      for nty in new_g.ntypes:
          assert new_g.num_nodes(nty) == g.num_nodes(nty)
      assert F.allclose(
          g.nodes["venue"].data["h"], new_g.nodes["venue"].data["h"]
      )
  
      src, dst = new_g.edges(etype=("person", "accepted", "venue"))
      eset = set(zip(list(F.asnumpy(src)), list(F.asnumpy(dst))))
      assert eset == {(0, 0)}
  
      src, dst = new_g.edges(etype=("person", "rejected", "venue"))
      eset = set(zip(list(F.asnumpy(src)), list(F.asnumpy(dst))))
      assert eset == {(0, 1), (1, 1)}
  
imports: import math
  import os
  import unittest
  import backend
  import dgl
  import dgl.function
  import dgl.partition
  import networkx
  import numpy
  import pytest
  from scipy import sparse
  from utils import parametrize_idtype
  from utils.graph_cases import get_cases
label_desc: Use image node_id 39 for calling a global function with example usage: test_module_add_metapaths(idtype) without return types