code: def test_to_sparse_tensor(device):
      kwargs = dict(device=device)
      adj = EdgeIndex([[0, 1, 1, 2], [1, 0, 2, 1]], **kwargs)
      out = adj.to_sparse_tensor()
      assert isinstance(out, SparseTensor)
      assert out.sizes() == [3, 3]
      row, col, _ = out.coo()
      assert row.equal(adj[0])
      assert col.equal(adj[1])
  
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 23 for calling a global function with example usage: test_to_sparse_tensor(device) without return types