code: def test_addsub_coo(val_shape, opname):
      op = getattr(operator, opname)
      func = getattr(dglsp, opname)
      ctx = F.ctx()
      row = torch.tensor([1, 0, 2]).to(ctx)
      col = torch.tensor([0, 3, 2]).to(ctx)
      val = torch.randn(row.shape + val_shape).to(ctx)
      A = dglsp.from_coo(row, col, val)
  
      row = torch.tensor([1, 0]).to(ctx)
      col = torch.tensor([0, 2]).to(ctx)
      val = torch.randn(row.shape + val_shape).to(ctx)
      B = dglsp.from_coo(row, col, val, shape=A.shape)
  
      C1 = op(A, B).to_dense()
      C2 = func(A, B).to_dense()
      dense_C = op(A.to_dense(), B.to_dense())
  
      assert torch.allclose(dense_C, C1)
      assert torch.allclose(dense_C, C2)
  
      with pytest.raises(TypeError):
          op(A, 2)
      with pytest.raises(TypeError):
          op(2, A)
  
file_path: dgl/tests/python/pytorch/sparse/test_elementwise_op.py
imports: import operator
  import backend
  import dgl.sparse
  import pytest
  import torch
  from dgl.sparse import diag, power
label_desc: Use image node_id 3 for calling a global function with example usage: test_addsub_coo(val_shape, opname) without return types