code: def test_spspmm(device, reduce, transpose, is_undirected):
      if is_undirected:
          kwargs = dict(
              device=device, sort_order="row", is_undirected=True
          )
          adj1 = EdgeIndex([[0, 1, 1, 2], [1, 0, 2, 1]], **kwargs)
      else:
          kwargs = dict(device=device, sort_order="row")
          adj1 = EdgeIndex([[0, 1, 1, 2], [2, 0, 1, 2]], **kwargs)
  
      adj1_dense = adj1.to_dense().t() if transpose else adj1.to_dense()
      adj2 = EdgeIndex(
          [[1, 0, 2, 1], [0, 1, 1, 2]], sort_order="col", device=device
      )
      adj2_dense = adj2.to_dense()
  
      if reduce in ["sum", "add"]:
          out, value = adj1.matmul(
              adj2, reduce=reduce, transpose=transpose
          )
          assert isinstance(out, EdgeIndex)
          assert out.is_sorted_by_row
          assert out._sparse_size == (3, 3)
          if not torch_geometric.typing.WITH_WINDOWS:
              assert out._indptr is not None
          assert torch.allclose(
              out.to_dense(value), adj1_dense @ adj2_dense
          )
      else:
          with pytest.raises(
              NotImplementedError, match="not yet supported"
          ):
              adj1.matmul(adj2, reduce=reduce, transpose=transpose)
  
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 29 for calling a global function with example usage: test_spspmm(device, reduce, transpose, is_undirected) without return types