code: def test_csrmask_backward(idtype, dtype):
      a, A = _random_simple_graph(
          idtype, dtype, F.ctx(), 3, 4, 6, "A", "B", "AB"
      )
      b, B = _random_simple_graph(
          idtype, dtype, F.ctx(), 3, 4, 6, "A", "B", "AB"
      )
      A_row, A_col = A.edges(order="eid")
      B_row, B_col = B.edges(order="eid")
      A_row = F.asnumpy(A_row)
      A_col = F.asnumpy(A_col)
      B_row = F.asnumpy(B_row)
      B_col = F.asnumpy(B_col)
      a_dense = F.attach_grad(F.tensor(a.todense(), dtype=dtype))
  
      A.edata["w"] = F.attach_grad(A.edata["w"])
  
      with F.record_grad():
          # Test for two element case
          C1 = F.csrmask(A._graph, A.edata["w"], B._graph)
          if dgl.backend.backend_name == "tensorflow":
              import tensorflow as tf
  
              C2 = tf.gather_nd(a_dense, tf.stack([B_row, B_col], 1))
          else:
              C2 = a_dense[B_row, B_col]
          assert F.allclose(C1, C2, rtol=1e-4, atol=1e-4)
  
          F.backward(F.reduce_sum(C1) + F.reduce_sum(C2))
          a_dense_grad = F.asnumpy(F.grad(a_dense))[A_row, A_col]
          A_spspmm_grad = F.asnumpy(F.grad(A.edata["w"]))
          assert np.allclose(
              a_dense_grad, A_spspmm_grad, rtol=1e-4, atol=1e-4
          )
  
file_path: dgl/tests/python/common/test_sparse_ops-csr.py
imports: import backend
  import dgl
  import numpy
  import pytest
  import scipy.sparse
  from utils import parametrize_idtype
label_desc: Use image node_id 7 for calling a global function with example usage: test_csrmask_backward(idtype, dtype) without return types