code: def readout_edges(graph, feat, weight=None, *, op="sum", etype=None):
      """Sum the edge feature :attr:`feat` in :attr:`graph`, optionally
      multiplies it by a edge :attr:`weight`.
  
      The function is commonly used as a *readout* function on a batch of graphs
      to generate graph-level representation. Thus, the result tensor shape
      depends on the batch size of the input graph. Given a graph of batch size
      :math:`B`, and a feature size of :math:`D`, the result shape will be
      :math:`(B, D)`, with each row being the aggregated edge features of each
      graph.
  
      Parameters
      ----------
      graph : DGLGraph.
          The input graph.
      feat : str
          The edge feature name.
      weight : str, optional
          The edge weight feature name. If None, no weighting will be performed,
          otherwise, weight each edge feature with field :attr:`feat`.
          for summation. The weight feature shape must be compatible with
          an element-wise multiplication with the feature tensor.
      op : str, optional
          Readout operator. Can be 'sum', 'max', 'min', 'mean'.
      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., 2.])
      >>> g2 = dgl.graph(([0, 1], [1, 2]))              # Graph 2
      >>> g2.edata['h'] = th.tensor([2., 3.])
  
      Sum over one graph:
  
      >>> dgl.readout_edges(g1, 'h')
      tensor([3.])  # 1 + 2
  
      Sum over a batched graph:
  
      >>> bg = dgl.batch([g1, g2])
      >>> dgl.readout_edges(bg, 'h')
      tensor([3., 5.])  # [1 + 2, 2 + 3]
  
      Weighted sum:
  
      >>> bg.edata['w'] = th.tensor([.1, .2, .1, .5])
      >>> dgl.readout_edges(bg, 'h', 'w')
      tensor([.5, 1.7])
  
      Readout by max:
  
      >>> dgl.readout_edges(bg, 'w', op='max')
      tensor([2., 3.])
  
      See Also
      --------
      readout_nodes
      """
      x = graph.edges[etype].data[feat]
      if weight is not None:
          x = x * graph.edges[etype].data[weight]
      return segment.segment_reduce(
          graph.batch_num_edges(etype), x, reducer=op
      )
  
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 2 for calling a global function with example usage: readout_edges(graph, feat, weight) and returns: segment