code: def softmax_edges(graph, feat, *, etype=None):
      r"""Perform graph-wise softmax on the edge features.
  
      For each edge :math:`e\in\mathcal{E}` and its feature :math:`x_e`,
      calculate its normalized feature as follows:
  
      .. math::
          z_e = \frac{\exp(x_e)}{\sum_{e'\in\mathcal{E}}\exp(x_{e'})}
  
      If the graph is a batch of multiple graphs, each graph computes softmax
      independently. The result tensor has the same shape as the original edge
      feature.
  
      Parameters
      ----------
      graph : DGLGraph.
          The input graph.
      feat : str
          The edge feature name.
      etype : str or (str, str, str), optional
          The type names of the edges. The allowed type name formats are:
  
          * ``(str, str, str)`` for source node type, edge type and destination node type.
          * or one ``str`` edge type name if the name can uniquely identify a
            triplet format in the graph.
  
          Can be omitted if the graph has only one type of edges.
  
      Returns
      -------
      Tensor
          Result tensor.
  
      Examples
      --------
  
      >>> import dgl
      >>> import torch as th
  
      Create two :class:`~dgl.DGLGraph` objects and initialize their
      edge features.
  
      >>> g1 = dgl.graph(([0, 1], [1, 0]))              # Graph 1
      >>> g1.edata['h'] = th.tensor([1., 1.])
      >>> g2 = dgl.graph(([0, 1, 0], [1, 2, 2]))        # Graph 2
      >>> g2.edata['h'] = th.tensor([1., 1., 1.])
  
      Softmax over one graph:
  
      >>> dgl.softmax_edges(g1, 'h')
      tensor([.5000, .5000])
  
      Softmax over a batched graph:
  
      >>> bg = dgl.batch([g1, g2])
      >>> dgl.softmax_edges(bg, 'h')
      tensor([.5000, .5000, .3333, .3333, .3333])
  
      See Also
      --------
      softmax_nodes
      """
      x = graph.edges[etype].data[feat]
      return segment.segment_softmax(graph.batch_num_edges(etype), x)
  
file_path: dgl/python/dgl/readout.py
imports: from __future__ import absolute_import
  from .None import backend
  from .base import dgl_warning, DGLError
  from .ops import segment
label_desc: Use image node_id 10 for calling a global function with example usage: softmax_edges(graph, feat) and returns: segment