code: def test_recursive_batch():
      data1 = Data(
          x={"1": torch.randn(10, 32), "2": torch.randn(20, 48)},
          edge_index=[
              get_random_edge_index(30, 30, 50),
              get_random_edge_index(30, 30, 70),
          ],
          num_nodes=30,
      )
  
      data2 = Data(
          x={"1": torch.randn(20, 32), "2": torch.randn(40, 48)},
          edge_index=[
              get_random_edge_index(60, 60, 80),
              get_random_edge_index(60, 60, 90),
          ],
          num_nodes=60,
      )
  
      batch = Batch.from_data_list([data1, data2])
  
      assert batch.num_graphs == len(batch) == 2
      assert batch.num_nodes == 90
  
      assert torch.allclose(
          batch.x["1"], torch.cat([data1.x["1"], data2.x["1"]], dim=0)
      )
      assert torch.allclose(
          batch.x["2"], torch.cat([data1.x["2"], data2.x["2"]], dim=0)
      )
      assert (
          batch.edge_index[0].tolist()
          == torch.cat(
              [data1.edge_index[0], data2.edge_index[0] + 30], dim=1
          ).tolist()
      )
      assert (
          batch.edge_index[1].tolist()
          == torch.cat(
              [data1.edge_index[1], data2.edge_index[1] + 30], dim=1
          ).tolist()
      )
      assert batch.batch.size() == (90,)
      assert batch.ptr.size() == (3,)
  
      out1 = batch[0]
      assert len(out1) == 3
      assert out1.num_nodes == 30
      assert torch.allclose(out1.x["1"], data1.x["1"])
      assert torch.allclose(out1.x["2"], data1.x["2"])
      assert out1.edge_index[0].tolist(), data1.edge_index[0].tolist()
      assert out1.edge_index[1].tolist(), data1.edge_index[1].tolist()
  
      out2 = batch[1]
      assert len(out2) == 3
      assert out2.num_nodes == 60
      assert torch.allclose(out2.x["1"], data2.x["1"])
      assert torch.allclose(out2.x["2"], data2.x["2"])
      assert out2.edge_index[0].tolist(), data2.edge_index[0].tolist()
      assert out2.edge_index[1].tolist(), data2.edge_index[1].tolist()
  
imports: import os.path
  import numpy
  import pytest
  import torch
  import torch_geometric
  from torch_geometric import EdgeIndex
  from torch_geometric.data import Batch, Data, HeteroData
  from torch_geometric.testing import get_random_edge_index, withPackage
  from torch_geometric.typing import SparseTensor
  from torch_geometric.utils import to_edge_index, to_torch_sparse_tensor
label_desc: Use image node_id 7 for calling a global function with example usage: test_recursive_batch() without return types