code: def test_hetero_to_sparse_tensor(layout):
      edge_index = torch.tensor([[0, 1, 1, 2], [1, 0, 2, 1]])
  
      data = HeteroData()
      data["v"].num_nodes = 3
      data["w"].num_nodes = 3
      data["v", "v"].edge_index = edge_index
      data["v", "w"].edge_index = edge_index
  
      data = ToSparseTensor(layout=layout)(data)
  
      if layout is None and torch_geometric.typing.WITH_TORCH_SPARSE:
          row, col, value = data["v", "v"].adj_t.coo()
          assert row.tolist() == [0, 1, 1, 2]
          assert col.tolist() == [1, 0, 2, 1]
          assert value is None
  
          row, col, value = data["v", "w"].adj_t.coo()
          assert row.tolist() == [0, 1, 1, 2]
          assert col.tolist() == [1, 0, 2, 1]
          assert value is None
      else:
          adj_t = data["v", "v"].adj_t
          assert adj_t.layout == layout or torch.sparse_csr
          if layout != torch.sparse_coo:
              adj_t = adj_t.to_sparse_coo()
          assert adj_t.coalesce().indices().tolist() == [
              [0, 1, 1, 2],
              [1, 0, 2, 1],
          ]
          assert adj_t.coalesce().values().tolist() == [
              1.0,
              1.0,
              1.0,
              1.0,
          ]
  
          adj_t = data["v", "w"].adj_t
          assert adj_t.layout == layout or torch.sparse_csr
          if layout != torch.sparse_coo:
              adj_t = adj_t.to_sparse_coo()
          assert adj_t.coalesce().indices().tolist() == [
              [0, 1, 1, 2],
              [1, 0, 2, 1],
          ]
          assert adj_t.coalesce().values().tolist() == [
              1.0,
              1.0,
              1.0,
              1.0,
          ]
  
file_path: pytorch_geometric/test/transforms/test_to_sparse_tensor.py
imports: import pytest
  import torch
  import torch_geometric.typing
  from torch_geometric.data import Data, HeteroData
  from torch_geometric.transforms import ToSparseTensor
label_desc: Use image node_id 3 for calling a global function with example usage: test_hetero_to_sparse_tensor(layout) without return types