code: def _gen_copy_reduce_func(binary_op, reduce_op):
      name = "{}_{}".format(binary_op, reduce_op)
      binary_str = {
          "copy_u": "It copies node feature to edge as the message.",
          "copy_e": "It regards edge feature as message.",
      }
      x_str = {"copy_u": "source node", "copy_e": "edge"}
      docstring = lambda binary_op: _attach_zerodeg_note(
          """Generalized SpMM function. {}
      Then aggregates the message by {} on destination nodes.
  
      Parameters
      ----------
      g : DGLGraph
          The input graph
      x : tensor
          The {} features.
  
      Returns
      -------
      tensor
          The result tensor.
  
      Notes
      -----
      This function supports autograd (computing input gradients given the output gradient).
      """.format(
              binary_str[binary_op], reduce_op, x_str[binary_op]
          ),
          reduce_op,
      )
  
      def func(g, x):
          if binary_op == "copy_u":
              return gspmm(g, "copy_lhs", reduce_op, x, None)
          else:
              return gspmm(g, "copy_rhs", reduce_op, None, x)
  
      func.__name__ = name
      func.__doc__ = docstring(binary_op)
      return func
  
file_path: dgl/python/dgl/ops/spmm.py
imports: import sys
  from ..None import backend
  from ..backend import gspmm, gspmm_hetero
label_desc: Use image node_id 5 for calling a global function with example usage: _gen_copy_reduce_func(binary_op, reduce_op) and returns: func, gspmm, gspmm