code: def test_to_bidirected():
      # homogeneous graph
      elist = [(0, 0), (0, 1), (1, 0), (1, 1), (2, 1), (2, 2)]
      num_edges = 7
      g = dgl.graph(tuple(zip(*elist)))
      elist.append((1, 2))
      elist = set(elist)
      big = dgl.to_bidirected(g)
      assert big.num_edges() == num_edges
      src, dst = big.edges()
      eset = set(zip(list(F.asnumpy(src)), list(F.asnumpy(dst))))
      assert eset == set(elist)
  
      # heterogeneous graph
      elist1 = [(0, 0), (0, 1), (1, 0), (1, 1), (2, 1), (2, 2)]
      elist2 = [(0, 0), (0, 1)]
      g = dgl.heterograph(
          {
              ("user", "wins", "user"): tuple(zip(*elist1)),
              ("user", "follows", "user"): tuple(zip(*elist2)),
          }
      )
      g.nodes["user"].data["h"] = F.ones((3, 1))
      elist1.append((1, 2))
      elist1 = set(elist1)
      elist2.append((1, 0))
      elist2 = set(elist2)
      big = dgl.to_bidirected(g)
      assert big.num_edges("wins") == 7
      assert big.num_edges("follows") == 3
      src, dst = big.edges(etype="wins")
      eset = set(zip(list(F.asnumpy(src)), list(F.asnumpy(dst))))
      assert eset == set(elist1)
      src, dst = big.edges(etype="follows")
      eset = set(zip(list(F.asnumpy(src)), list(F.asnumpy(dst))))
      assert eset == set(elist2)
  
      big = dgl.to_bidirected(g, copy_ndata=True)
      assert F.array_equal(
          g.nodes["user"].data["h"], big.nodes["user"].data["h"]
      )
  
imports: import math
  import os
  import unittest
  import backend
  import dgl
  import dgl.function
  import dgl.partition
  import networkx
  import numpy
  import pytest
  from scipy import sparse
  from utils import parametrize_idtype
  from utils.graph_cases import get_cases
label_desc: Use image node_id 9 for calling a global function with example usage: test_to_bidirected() without return types