code: def _test_construct_graphs_node_ids():
      from dgl.data.csv_dataset_base import (
          DGLGraphConstructor,
          EdgeData,
          NodeData,
      )
  
      num_nodes = 100
      num_edges = 1000
  
      # node IDs are required to be unique
      node_ids = np.random.choice(np.arange(num_nodes / 2), num_nodes)
      src_ids = np.random.choice(node_ids, size=num_edges)
      dst_ids = np.random.choice(node_ids, size=num_edges)
      node_data = NodeData(node_ids, {})
      edge_data = EdgeData(src_ids, dst_ids, {})
      expect_except = False
      try:
          _, _ = DGLGraphConstructor.construct_graphs(
              node_data, edge_data
          )
      except:
          expect_except = True
      assert expect_except
  
      # node IDs are already labelled from 0~num_nodes-1
      node_ids = np.arange(num_nodes)
      np.random.shuffle(node_ids)
      _, idx = np.unique(node_ids, return_index=True)
      src_ids = np.random.choice(node_ids, size=num_edges)
      dst_ids = np.random.choice(node_ids, size=num_edges)
      node_feat = np.random.rand(num_nodes, 3)
      node_data = NodeData(node_ids, {"feat": node_feat})
      edge_data = EdgeData(src_ids, dst_ids, {})
      graphs, data_dict = DGLGraphConstructor.construct_graphs(
          node_data, edge_data
      )
      assert len(graphs) == 1
      assert len(data_dict) == 0
      g = graphs[0]
      assert g.is_homogeneous
      assert g.num_nodes() == len(node_ids)
      assert g.num_edges() == len(src_ids)
      assert F.array_equal(
          F.tensor(node_feat[idx], dtype=F.float32), g.ndata["feat"]
      )
  
      # node IDs are mixed with numeric and non-numeric values
      # homogeneous graph
      node_ids = [1, 2, 3, "a"]
      src_ids = [1, 2, 3]
      dst_ids = ["a", 1, 2]
      node_data = NodeData(node_ids, {})
      edge_data = EdgeData(src_ids, dst_ids, {})
      graphs, data_dict = DGLGraphConstructor.construct_graphs(
          node_data, edge_data
      )
      assert len(graphs) == 1
      assert len(data_dict) == 0
      g = graphs[0]
      assert g.is_homogeneous
      assert g.num_nodes() == len(node_ids)
      assert g.num_edges() == len(src_ids)
  
      # heterogeneous graph
      node_ids_user = [1, 2, 3]
      node_ids_item = ["a", "b", "c"]
      src_ids = node_ids_user
      dst_ids = node_ids_item
      node_data_user = NodeData(node_ids_user, {}, type="user")
      node_data_item = NodeData(node_ids_item, {}, type="item")
      edge_data = EdgeData(
          src_ids, dst_ids, {}, type=("user", "like", "item")
      )
      graphs, data_dict = DGLGraphConstructor.construct_graphs(
          [node_data_user, node_data_item], edge_data
      )
      assert len(graphs) == 1
      assert len(data_dict) == 0
      g = graphs[0]
      assert not g.is_homogeneous
      assert g.num_nodes("user") == len(node_ids_user)
      assert g.num_nodes("item") == len(node_ids_item)
      assert g.num_edges() == len(src_ids)
  
imports: import gzip
  import io
  import os
  import tarfile
  import tempfile
  import unittest
  import warnings
  import backend
  import dgl
  import dgl.data
  import numpy
  import pandas
  import pytest
  import yaml
  from dgl import DGLError
label_desc: Use image node_id 16 for calling a global function with example usage: _test_construct_graphs_node_ids() without return types