code: def test_sddmm(g, shp, lhs_target, rhs_target, msg, idtype):
      if lhs_target == rhs_target:
          return
      g = g.astype(idtype).to(F.ctx())
      if dgl.backend.backend_name == "mxnet" and g.num_edges() == 0:
          pytest.skip()  # mxnet do not support zero shape tensor
      print(g)
      print(g.idtype)
  
      len_lhs = select(
          lhs_target,
          g.number_of_src_nodes(),
          g.num_edges(),
          g.number_of_dst_nodes(),
      )
      lhs_shp = (len_lhs,) + shp[0]
      len_rhs = select(
          rhs_target,
          g.number_of_src_nodes(),
          g.num_edges(),
          g.number_of_dst_nodes(),
      )
      rhs_shp = (len_rhs,) + shp[1]
      feat_lhs = F.tensor(np.random.rand(*lhs_shp) + 1)
      feat_rhs = F.tensor(np.random.rand(*rhs_shp) + 1)
      print(
          "lhs shape: {}, rhs shape: {}".format(
              F.shape(feat_lhs), F.shape(feat_rhs)
          )
      )
  
      lhs_frame = select(lhs_target, g.srcdata, g.edata, g.dstdata)
      rhs_frame = select(rhs_target, g.srcdata, g.edata, g.dstdata)
      lhs_frame["x"] = F.attach_grad(F.clone(feat_lhs))
      rhs_frame["y"] = F.attach_grad(F.clone(feat_rhs))
      msg_func = lhs_target + "_" + msg + "_" + rhs_target
      print("SDDMM(message func: {})".format(msg_func))
  
      lhs = F.attach_grad(F.clone(feat_lhs))
      rhs = F.attach_grad(F.clone(feat_rhs))
      with F.record_grad():
          e = gsddmm(
              g,
              msg,
              lhs,
              rhs,
              lhs_target=lhs_target,
              rhs_target=rhs_target,
          )
          F.backward(F.reduce_sum(e))
          grad_lhs = F.grad(lhs)
          grad_rhs = F.grad(rhs)
  
      with F.record_grad():
          g.apply_edges(udf_apply_edges[msg_func])
          if g.num_edges() > 0:
              e1 = g.edata["m"]
              assert F.allclose(e, e1)
              print("forward passed")
  
              F.backward(F.reduce_sum(e1))
              if msg != "copy_rhs":
                  assert F.allclose(F.grad(lhs_frame["x"]), grad_lhs)
              if msg != "copy_lhs":
                  assert F.allclose(F.grad(rhs_frame["y"]), grad_rhs)
              print("backward passed")
  
      lhs_frame.pop("x")
      rhs_frame.pop("y")
      if "m" in g.edata:
          g.edata.pop("m")
  
imports: import random
  import unittest
  import backend
  import dgl
  import numpy
  import pytest
  import torch
  from dgl.ops import gather_mm, gsddmm, gspmm, segment_reduce
  from utils import parametrize_idtype
  from utils.graph_cases import get_cases
label_desc: Use image node_id 6 for calling a global function with example usage: test_sddmm(g, shp, lhs_target, rhs_target, msg, idtype) without return types