code: def edge_sparsemax(
      graph: dgl.DGLGraph, logits, eids=ALL, norm_by="dst"
  ):
      r"""
      Description
      -----------
      Compute edge sparsemax. For a node :math:`i`, edge sparsemax is an operation that computes
  
      .. math::
        a_{ij} = \text{ReLU}(z_{ij} - \tau(\z_{i,:}))
  
      where :math:`z_{ij}` is a signal of edge :math:`j\rightarrow i`, also
      called logits in the context of sparsemax. :math:`\tau` is a function
      that can be found at the `From Softmax to Sparsemax <https://arxiv.org/pdf/1602.02068.pdf>`
      paper.
  
      NOTE: currently only homogeneous graphs are supported.
  
      Parameters
      ----------
      graph : DGLGraph
          The graph to perform edge sparsemax on.
      logits : torch.Tensor
          The input edge feature.
      eids : torch.Tensor or ALL, optional
          A tensor of edge index on which to apply edge sparsemax. If ALL, apply edge
          sparsemax on all edges in the graph. Default: ALL.
      norm_by : str, could be 'src' or 'dst'
          Normalized by source nodes of destination nodes. Default: `dst`.
  
      Returns
      -------
      Tensor
          Sparsemax value.
      """
      # we get edge index tensors here since it is
      # hard to get edge index with HeteroGraphIndex
      # object without other information like edge_type.
      row, col = graph.all_edges(order="eid")
      assert norm_by in ["dst", "src"]
      end_n_ids = col if norm_by == "dst" else row
      if not is_all(eids):
          eids = astype(eids, graph.idtype)
          end_n_ids = end_n_ids[eids]
      return EdgeSparsemaxFunction.apply(
          graph._graph, logits, eids, end_n_ids, norm_by
      )
  
file_path: dgl/examples/pytorch/hgp_sl/functions.py
imports: import dgl
  import torch
  from dgl.backend import astype
  from dgl.base import ALL, is_all
  from dgl.heterograph_index import HeteroGraphIndex
  from dgl.sparse import _gsddmm, _gspmm
  from torch import Tensor
  from torch.autograd import Function
label_desc: Use image node_id 3 for calling a global function with example usage: edge_sparsemax(graph, logits, eids, norm_by) and returns: EdgeSparsemaxFunction