code: def test_to_dgl_hetero_graph():
      data = HeteroData()
      data["v1"].x = torch.randn(4, 3)
      data["v2"].x = torch.randn(4, 3)
      data["v1", "v2"].edge_index = torch.tensor(
          [[0, 1, 2, 3], [0, 1, 2, 3]]
      )
      data["v1", "v2"].edge_attr = torch.randn(4, 2)
  
      g = to_dgl(data)
  
      assert data["v1", "v2"].num_edges == g.num_edges(
          ("v1", "to", "v2")
      )
      assert data["v1"].num_nodes == g.num_nodes("v1")
      assert data["v2"].num_nodes == g.num_nodes("v2")
      assert torch.equal(data["v1"].x, g.nodes["v1"].data["x"])
      assert torch.equal(data["v2"].x, g.nodes["v2"].data["x"])
      row, col = g.edges()
      assert torch.equal(row, data["v1", "v2"].edge_index[0])
      assert torch.equal(col, data["v1", "v2"].edge_index[1])
      assert torch.equal(
          g.edata["edge_attr"], data["v1", "v2"].edge_attr
      )
  
imports: import pytest
  import scipy.sparse
  import torch
  from torch_geometric.data import Data, HeteroData
  from torch_geometric.testing import get_random_edge_index, withPackage
  from torch_geometric.utils import from_cugraph, from_dgl, from_networkit, from_networkx, from_scipy_sparse_matrix, from_trimesh, sort_edge_index, subgraph, to_cugraph, to_dgl, to_networkit, to_networkx, to_scipy_sparse_matrix, to_trimesh
label_desc: Use image node_id 27 for calling a global function with example usage: test_to_dgl_hetero_graph() without return types