code: def test_undirected(dtype, device):
      kwargs = dict(dtype=dtype, device=device, is_undirected=True)
      adj = EdgeIndex([[0, 1, 1, 2], [1, 0, 2, 1]], **kwargs)
      assert isinstance(adj, EdgeIndex)
      assert adj.is_undirected
  
      assert adj.sparse_size() == (None, None)
      adj.get_num_rows()
      assert adj.sparse_size() == (3, 3)
      adj.validate()
  
      adj = EdgeIndex([[0, 1], [1, 0]], sparse_size=(3, None), **kwargs)
      assert adj.sparse_size() == (3, 3)
      adj.validate()
  
      adj = EdgeIndex([[0, 1], [1, 0]], sparse_size=(None, 3), **kwargs)
      assert adj.sparse_size() == (3, 3)
      adj.validate()
  
      with pytest.raises(
          ValueError, match="'EdgeIndex' is not undirected"
      ):
          EdgeIndex([[0, 1, 1, 2], [0, 0, 1, 1]], **kwargs).validate()
  
imports: import os.path
  import warnings
  from typing import List, Optional
  import pytest
  import torch
  from torch import Tensor, tensor
  import torch_geometric
  from torch_geometric import EdgeIndex
  from torch_geometric.edge_index import SUPPORTED_DTYPES, ReduceType, SortReturnType, _scatter_spmm, _torch_sparse_spmm, _TorchSPMM, set_tuple_item
  from torch_geometric.profile import benchmark
  from torch_geometric.testing import onlyCUDA, onlyLinux, withCUDA, withoutExtensions, withPackage
  from torch_geometric.typing import SparseTensor
  from torch_geometric.utils import scatter
label_desc: Use image node_id 6 for calling a global function with example usage: test_undirected(dtype, device) without return types