code: def test_spmm_basic(device, reduce):
      src = torch.randn(5, 4, device=device)
      other = torch.randn(4, 8, device=device)
  
      out1 = (src @ other) / (src.size(1) if reduce == "mean" else 1)
      out2 = spmm(src.to_sparse_csr(), other, reduce=reduce)
      assert out1.size() == (5, 8)
      assert torch.allclose(out1, out2, atol=1e-6)
      if torch_geometric.typing.WITH_TORCH_SPARSE:
          out3 = spmm(
              SparseTensor.from_dense(src), other, reduce=reduce
          )
          assert torch.allclose(out2, out3, atol=1e-6)
  
      # Test `mean` reduction with isolated nodes:
      src[0] = 0.0
      out1 = (src @ other) / (4.0 if reduce == "mean" else 1.0)
      out2 = spmm(src.to_sparse_csr(), other, reduce=reduce)
      assert out1.size() == (5, 8)
      assert torch.allclose(out1, out2, atol=1e-6)
      if torch_geometric.typing.WITH_TORCH_SPARSE:
          out3 = spmm(
              SparseTensor.from_dense(src), other, reduce=reduce
          )
          assert torch.allclose(out2, out3, atol=1e-6)
  
file_path: pytorch_geometric/test/utils/test_spmm.py
imports: import itertools
  import warnings
  import pytest
  import torch
  from torch import Tensor
  import torch_geometric.typing
  from torch_geometric.profile import benchmark
  from torch_geometric.testing import withCUDA, withPackage
  from torch_geometric.typing import SparseTensor
  from torch_geometric.utils import spmm, to_torch_coo_tensor
label_desc: Use image node_id 1 for calling a global function with example usage: test_spmm_basic(device, reduce) without return types