code: def edge_softmax_real(gidx, score, eids=ALL, norm_by="dst"):
      if not is_all(eids):
          gidx = gidx.edge_subgraph([eids], True).graph
      if norm_by == "src":
          gidx = gidx.reverse()
      score_max = _gspmm(gidx, "copy_rhs", "max", None, score)[0]
      score = tf.math.exp(
          _gsddmm(gidx, "sub", score, score_max, "e", "v")
      )
      score_sum = _gspmm(gidx, "copy_rhs", "sum", None, score)[0]
      out = _gsddmm(gidx, "div", score, score_sum, "e", "v")
  
      def edge_softmax_backward(grad_out):
          sds = out * grad_out
          accum = gspmm(gidx, "copy_rhs", "sum", None, sds)
          grad_score = sds - gsddmm(gidx, "mul", out, accum, "e", "v")
          return grad_score
  
      return out, edge_softmax_backward
  
imports: import numpy
  import tensorflow
  from ..._sparse_ops import _bwd_segment_cmp, _csrmask, _csrmm, _csrsum, _gsddmm, _gspmm, _scatter_add, _segment_reduce
  from ...base import ALL, is_all
  from ...heterograph_index import create_unitgraph_from_csr
  from .tensor import asnumpy, context, copy_to, tensor, zerocopy_from_numpy
label_desc: Use image node_id 12 for calling a global function with example usage: edge_softmax_real(gidx, score, eids, norm_by) and returns: out,  edge_softmax_backward, grad_score