code: def test_build_tensor_hetergraph(self):
      np.random.seed(1)
      dim = 4
      num_nodes = paddle.to_tensor(15)
  
      edges = {}
      # for test no successor
      c2p = [
          (1, 4),
          (0, 5),
          (1, 9),
          (1, 8),
          (2, 8),
          (2, 5),
          (3, 6),
          (3, 7),
          (3, 4),
          (3, 8),
      ]
      edges["c2p"] = paddle.to_tensor(np.array(c2p))
      p2c = [(v, u) for u, v in c2p]
      edges["p2c"] = paddle.to_tensor(np.array(p2c))
  
      p2a = [
          (4, 10),
          (4, 11),
          (4, 12),
          (4, 14),
          (4, 13),
          (6, 12),
          (6, 11),
          (6, 14),
          (7, 12),
          (7, 11),
          (8, 14),
          (9, 10),
      ]
      edges["p2a"] = paddle.to_tensor(np.array(p2a))
      a2p = [(v, u) for u, v in p2a]
      edges["a2p"] = paddle.to_tensor(np.array(a2p))
  
      node_types = (
          ["c" for _ in range(4)]
          + ["p" for _ in range(6)]
          + ["a" for _ in range(5)]
      )
      node_types = [(i, t) for i, t in enumerate(node_types)]
  
      hg = pgl.HeterGraph(edges=edges, node_types=node_types)
  
      self.assertTrue(hg.is_tensor())
      print()
      self.assertEqual(
          hg.indegree(paddle.to_tensor(5)).numpy(), np.array([2])
      )
      self.assertEqual(
          hg.indegree(paddle.to_tensor(5), "c2p").numpy(), np.array([2])
      )
      self.assertEqual(
          hg.outdegree(paddle.to_tensor(4)).numpy(), np.array([7])
      )
      self.assertEqual(
          hg.outdegree(paddle.to_tensor(4), "p2a").numpy(),
          np.array([5]),
      )
      #  print(hg.outdegree(paddle.to_tensor(4)).numpy())
      for batch in hg.node_batch_iter(3, n_type="c"):
          break
  
file_path: PGL/tests/test_hetergraph.py
imports: import os
  import unittest
  import numpy
  import paddle
  import pgl
  import shutil
label_desc: Use image node_id 2 for calling the HeterGraphTest obj's underlying member method code with example usage: obj.test_build_tensor_hetergraph() without return types