code: def test_batch_unbatch_frame(idtype):
      """Test module of node/edge frames of batched/unbatched DGLGraphs.
      Also address the bug mentioned in https://github.com/dmlc/dgl/issues/1475.
      """
      t1 = tree1(idtype)
      t2 = tree2(idtype)
      N1 = t1.num_nodes()
      E1 = t1.num_edges()
      N2 = t2.num_nodes()
      E2 = t2.num_edges()
      D = 10
      t1.ndata["h"] = F.randn((N1, D))
      t1.edata["h"] = F.randn((E1, D))
      t2.ndata["h"] = F.randn((N2, D))
      t2.edata["h"] = F.randn((E2, D))
  
      b1 = dgl.batch([t1, t2])
      b2 = dgl.batch([t2])
      b1.ndata["h"][:N1] = F.zeros((N1, D))
      b1.edata["h"][:E1] = F.zeros((E1, D))
      b2.ndata["h"][:N2] = F.zeros((N2, D))
      b2.edata["h"][:E2] = F.zeros((E2, D))
      assert not F.allclose(t1.ndata["h"], F.zeros((N1, D)))
      assert not F.allclose(t1.edata["h"], F.zeros((E1, D)))
      assert not F.allclose(t2.ndata["h"], F.zeros((N2, D)))
      assert not F.allclose(t2.edata["h"], F.zeros((E2, D)))
  
      g1, g2 = dgl.unbatch(b1)
      (_g2,) = dgl.unbatch(b2)
      assert F.allclose(g1.ndata["h"], F.zeros((N1, D)))
      assert F.allclose(g1.edata["h"], F.zeros((E1, D)))
      assert F.allclose(g2.ndata["h"], t2.ndata["h"])
      assert F.allclose(g2.edata["h"], t2.edata["h"])
      assert F.allclose(_g2.ndata["h"], F.zeros((N2, D)))
      assert F.allclose(_g2.edata["h"], F.zeros((E2, D)))
  
file_path: dgl/tests/python/common/test_batch-graph.py
imports: import unittest
  import backend
  import dgl
  import numpy
  from utils import parametrize_idtype
label_desc: Use image node_id 5 for calling a global function with example usage: test_batch_unbatch_frame(idtype) without return types