code: def test_spspmm(
      create_func1, create_func2, shape_n_m, shape_k, nnz1, nnz2
  ):
      dev = F.ctx()
      shape1 = shape_n_m
      shape2 = (shape_n_m[1], shape_k)
      A1 = create_func1(shape1, nnz1, dev)
      A2 = create_func2(shape2, nnz2, dev)
      A3 = matmul(A1, A2)
      grad = torch.randn_like(A3.val)
      A3.val.backward(grad)
  
      torch_A1 = sparse_matrix_to_torch_sparse(A1)
      torch_A2 = sparse_matrix_to_torch_sparse(A2)
      torch_A3 = _torch_sparse_mm(torch_A1, torch_A2)
      torch_A3_grad = sparse_matrix_to_torch_sparse(A3, grad)
      torch_A3.backward(torch_A3_grad)
  
      with torch.no_grad():
          assert torch.allclose(
              A3.to_dense(), torch_A3.to_dense(), atol=1e-05
          )
          assert torch.allclose(
              val_like(A1, A1.val.grad).to_dense(),
              torch_A1.grad.to_dense(),
              atol=1e-05,
          )
          assert torch.allclose(
              val_like(A2, A2.val.grad).to_dense(),
              torch_A2.grad.to_dense(),
              atol=1e-05,
          )
  
file_path: dgl/tests/python/pytorch/sparse/test_matmul.py
imports: import warnings
  import backend
  import pytest
  import torch
  from dgl.sparse import bspmm, diag, from_coo, val_like
  from dgl.sparse.matmul import matmul
  from .utils import clone_detach_and_grad, dense_mask, rand_coo, rand_csc, rand_csr, rand_stride, sparse_matrix_to_dense, sparse_matrix_to_torch_sparse
label_desc: Use image node_id 4 for calling a global function with example usage: test_spspmm(create_func1, create_func2, shape_n_m, shape_k, nnz1, nnz2) without return types