code: def test_from_dglgraph_heterogeneous():
      dgl_g = dgl.heterograph(
          {
              ("author", "writes", "paper"): (
                  [1, 2, 3, 4, 5, 2],
                  [1, 2, 3, 4, 5, 4],
              ),
              ("author", "affiliated_with", "institution"): (
                  [1, 2, 3, 4, 5],
                  [1, 2, 3, 4, 5],
              ),
              ("paper", "has_topic", "field"): (
                  [1, 2, 3, 4, 5],
                  [1, 2, 3, 4, 5],
              ),
              ("paper", "cites", "paper"): (
                  [2, 3, 4, 5, 6, 1],
                  [1, 2, 3, 4, 5, 4],
              ),
          }
      )
      # Check if the original edge id exist in edge attributes when the
      # original_edge_id is set to False.
      gb_g = gb.from_dglgraph(
          dgl_g, is_homogeneous=False, include_original_edge_id=False
      )
      assert (
          gb_g.edge_attributes is None
          or gb.ORIGINAL_EDGE_ID not in gb_g.edge_attributes
      )
  
      gb_g = gb.from_dglgraph(
          dgl_g, is_homogeneous=False, include_original_edge_id=True
      )
  
      # `reverse_node_id` is used to map the node id in FusedCSCSamplingGraph to the
      # node id in Hetero-DGLGraph.
      num_ntypes = gb_g.node_type_offset.diff()
      reverse_node_id = torch.cat(
          [torch.arange(num) for num in num_ntypes]
      )
  
      # Get the COO representation of the FusedCSCSamplingGraph.
      num_columns = gb_g.csc_indptr.diff()
      rows = reverse_node_id[gb_g.indices]
      columns = reverse_node_id[
          torch.arange(gb_g.total_num_nodes).repeat_interleave(
              num_columns
          )
      ]
  
      # Check the order of etypes in DGLGraph is the same as FusedCSCSamplingGraph.
      assert (
          # Since the etypes in FusedCSCSamplingGraph is "srctype:etype:dsttype",
          # we need to split the string and get the middle part.
          list(
              map(
                  lambda ss: ss.split(":")[1],
                  gb_g.edge_type_to_id.keys(),
              )
          )
          == dgl_g.etypes
      )
  
      # Use ORIGINAL_EDGE_ID to check if the edge mapping is correct.
      for edge_idx in range(gb_g.total_num_edges):
          hetero_graph_idx = gb_g.type_per_edge[edge_idx]
          original_edge_id = gb_g.edge_attributes[gb.ORIGINAL_EDGE_ID][
              edge_idx
          ]
          edge_type = dgl_g.etypes[hetero_graph_idx]
          dgl_edge_pairs = dgl_g.edges(etype=edge_type)
          assert dgl_edge_pairs[0][original_edge_id] == rows[edge_idx]
          assert (
              dgl_edge_pairs[1][original_edge_id] == columns[edge_idx]
          )
  
      assert gb_g.total_num_nodes == dgl_g.num_nodes()
      assert gb_g.total_num_edges == dgl_g.num_edges()
      assert torch.equal(
          gb_g.node_type_offset, torch.tensor([0, 6, 12, 18, 25])
      )
      assert torch.equal(
          gb_g.type_per_edge,
          torch.tensor(
              [
                  3,
                  3,
                  3,
                  3,
                  3,
                  0,
                  0,
                  0,
                  0,
                  0,
                  1,
                  2,
                  1,
                  2,
                  1,
                  2,
                  1,
                  1,
                  2,
                  2,
                  1,
                  2,
              ]
          ),
      )
      assert gb_g.node_type_to_id == {
          "author": 0,
          "field": 1,
          "institution": 2,
          "paper": 3,
      }
      assert gb_g.edge_type_to_id == {
          "author:affiliated_with:institution": 0,
          "author:writes:paper": 1,
          "paper:cites:paper": 2,
          "paper:has_topic:field": 3,
      }
  
imports: import os
  import pickle
  import re
  import tempfile
  import unittest
  import backend
  import dgl
  import dgl.graphbolt
  import pytest
  import torch
  import torch.multiprocessing
  from dgl.graphbolt.base import etype_str_to_tuple
  from scipy import sparse
  from ..None import gb_test_utils
label_desc: Use image node_id 27 for calling a global function with example usage: test_from_dglgraph_heterogeneous() without return types