code: def test_sub_sparse_diag(val_shape):
      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)
  
      shape = (3, 4)
      val_shape = (shape[0],) + val_shape
      D = dglsp.diag(torch.randn(val_shape).to(ctx), shape=shape)
  
      diff1 = (A - D).to_dense()
      diff2 = (D - A).to_dense()
      diff3 = dglsp.sub(A, D).to_dense()
      diff4 = dglsp.sub(D, A).to_dense()
      dense_diff = A.to_dense() - D.to_dense()
  
      assert torch.allclose(dense_diff, diff1)
      assert torch.allclose(dense_diff, -diff2)
      assert torch.allclose(dense_diff, diff3)
      assert torch.allclose(dense_diff, -diff4)
  
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 8 for calling a global function with example usage: test_sub_sparse_diag(val_shape) without return types