code: def test_edge_index():
      edge_index1 = EdgeIndex(
          [[0, 1, 1, 2], [1, 0, 2, 1]],
          sparse_size=(3, 3),
          sort_order="row",
          is_undirected=True,
      )
      edge_index2 = EdgeIndex(
          [[1, 0, 2, 1, 3, 2], [0, 1, 1, 2, 2, 3]],
          sparse_size=(4, 4),
          sort_order="col",
      )
  
      data1 = Data(edge_index=edge_index1)
      data2 = Data(edge_index=edge_index2)
  
      batch = Batch.from_data_list([data1, data2])
  
      assert len(batch) == 2
      assert batch.batch.equal(torch.tensor([0, 0, 0, 1, 1, 1, 1]))
      assert batch.ptr.equal(torch.tensor([0, 3, 7]))
      assert isinstance(batch.edge_index, EdgeIndex)
      assert batch.edge_index.equal(
          torch.tensor(
              [
                  [0, 1, 1, 2, 4, 3, 5, 4, 6, 5],
                  [1, 0, 2, 1, 3, 4, 4, 5, 5, 6],
              ]
          )
      )
      assert batch.edge_index.sparse_size() == (7, 7)
      assert batch.edge_index.sort_order is None
      assert not batch.edge_index.is_undirected
  
      for i, edge_index in enumerate([edge_index1, edge_index2]):
          data = batch[i]
          assert isinstance(data.edge_index, EdgeIndex)
          assert data.edge_index.equal(edge_index)
          assert (
              data.edge_index.sparse_size() == edge_index.sparse_size()
          )
          assert data.edge_index.sort_order == edge_index.sort_order
          assert (
              data.edge_index.is_undirected == edge_index.is_undirected
          )
  
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 2 for calling a global function with example usage: test_edge_index() without return types