code: def test_subgraph():
      sp_g, g = generate_graph(100)
      vertices = np.unique(np.random.randint(0, 100, size=(20)))
      subgs = mx.nd.contrib.dgl_subgraph(
          g, mx.nd.array(vertices, dtype=np.int64), return_mapping=True
      )
      subgs[0].check_format()
      subgs[1].check_format()
      assert_array_equal(subgs[0].indptr, subgs[1].indptr)
      assert_array_equal(subgs[0].indices, subgs[1].indices)
      sp_subg = subgs[1].asscipy()
      for i in range(len(subgs[0].indptr) - 1):
          subv1 = i
          v1 = vertices[subv1]
          row_start = int(subgs[0].indptr[subv1].asnumpy()[0])
          row_end = int(subgs[0].indptr[subv1 + 1].asnumpy()[0])
          if row_start >= len(subgs[0].indices):
              remain = subgs[0].indptr[subv1:].asnumpy()
              assert np.sum(remain == row_start) == len(remain)
              break
          row = subgs[0].indices[row_start:row_end]
          for _, subv2 in enumerate(row.asnumpy()):
              v2 = vertices[subv2]
              assert sp_g[v1, v2] == sp_subg[subv1, subv2]
  
file_path: mxnet/tests/python/unittest/test_dgl_graph.py
imports: from __future__ import print_function
  import numpy
  import scipy
  import mxnet
  import random
  import itertools
  from numpy.testing import assert_allclose, assert_array_equal
  from mxnet.test_utils import *
  import unittest
label_desc: Use image node_id 8 for calling a global function with example usage: test_subgraph() without return types