code: def test_khop_in_subgraph(idtype):
      g = dgl.graph(
          ([1, 1, 2, 3, 4], [0, 2, 0, 4, 2]),
          idtype=idtype,
          device=F.ctx(),
      )
      g.edata["w"] = F.tensor([[0, 1], [2, 3], [4, 5], [6, 7], [8, 9]])
      sg, inv = dgl.khop_in_subgraph(g, 0, k=2)
      assert sg.idtype == g.idtype
      u, v = sg.edges()
      edge_set = set(zip(list(F.asnumpy(u)), list(F.asnumpy(v))))
      assert edge_set == {(1, 0), (1, 2), (2, 0), (3, 2)}
      assert F.array_equal(
          sg.edata[dgl.EID], F.tensor([0, 1, 2, 4], dtype=idtype)
      )
      assert F.array_equal(
          sg.edata["w"], F.tensor([[0, 1], [2, 3], [4, 5], [8, 9]])
      )
      assert F.array_equal(F.astype(inv, idtype), F.tensor([0], idtype))
  
      # Test multiple nodes
      sg, inv = dgl.khop_in_subgraph(g, [0, 2], k=1)
      assert sg.num_edges() == 4
  
      sg, inv = dgl.khop_in_subgraph(g, F.tensor([0, 2], idtype), k=1)
      assert sg.num_edges() == 4
  
      # Test isolated node
      sg, inv = dgl.khop_in_subgraph(g, 1, k=2)
      assert sg.idtype == g.idtype
      assert sg.num_nodes() == 1
      assert sg.num_edges() == 0
      assert F.array_equal(F.astype(inv, idtype), F.tensor([0], idtype))
  
      g = dgl.heterograph(
          {
              ("user", "plays", "game"): ([0, 1, 1, 2], [0, 0, 2, 1]),
              ("user", "follows", "user"): ([0, 1, 1], [1, 2, 2]),
          },
          idtype=idtype,
          device=F.ctx(),
      )
      sg, inv = dgl.khop_in_subgraph(g, {"game": 0}, k=2)
      assert sg.idtype == idtype
      assert sg.num_nodes("game") == 1
      assert sg.num_nodes("user") == 2
      assert len(sg.ntypes) == 2
      assert len(sg.etypes) == 2
      u, v = sg["follows"].edges()
      edge_set = set(zip(list(F.asnumpy(u)), list(F.asnumpy(v))))
      assert edge_set == {(0, 1)}
      u, v = sg["plays"].edges()
      edge_set = set(zip(list(F.asnumpy(u)), list(F.asnumpy(v))))
      assert edge_set == {(0, 0), (1, 0)}
      assert F.array_equal(
          F.astype(inv["game"], idtype), F.tensor([0], idtype)
      )
  
      # Test isolated node
      sg, inv = dgl.khop_in_subgraph(g, {"user": 0}, k=2)
      assert sg.idtype == idtype
      assert sg.num_nodes("game") == 0
      assert sg.num_nodes("user") == 1
      assert sg.num_edges("follows") == 0
      assert sg.num_edges("plays") == 0
      assert F.array_equal(
          F.astype(inv["user"], idtype), F.tensor([0], idtype)
      )
  
      # Test multiple nodes
      sg, inv = dgl.khop_in_subgraph(
          g, {"user": F.tensor([0, 1], idtype), "game": 0}, k=1
      )
      u, v = sg["follows"].edges()
      edge_set = set(zip(list(F.asnumpy(u)), list(F.asnumpy(v))))
      assert edge_set == {(0, 1)}
      u, v = sg["plays"].edges()
      edge_set = set(zip(list(F.asnumpy(u)), list(F.asnumpy(v))))
      assert edge_set == {(0, 0), (1, 0)}
      assert F.array_equal(
          F.astype(inv["user"], idtype), F.tensor([0, 1], idtype)
      )
      assert F.array_equal(
          F.astype(inv["game"], idtype), F.tensor([0], idtype)
      )
  
imports: import unittest
  import backend
  import dgl
  import networkx
  import numpy
  import pytest
  import scipy.sparse
  from utils import parametrize_idtype
label_desc: Use image node_id 12 for calling a global function with example usage: test_khop_in_subgraph(idtype) without return types