code: def softmax_nodes(graph, feat, *, ntype=None):
      r"""Perform graph-wise softmax on the node features.
  
      For each node :math:`v\in\mathcal{V}` and its feature :math:`x_v`,
      calculate its normalized feature as follows:
  
      .. math::
          z_v = \frac{\exp(x_v)}{\sum_{u\in\mathcal{V}}\exp(x_u)}
  
      If the graph is a batch of multiple graphs, each graph computes softmax
      independently. The result tensor has the same shape as the original node
      feature.
  
      Parameters
      ----------
      graph : DGLGraph.
          The input graph.
      feat : str
          The node feature name.
      ntype : str, optional
          The node type name. Can be omitted if there is only one node type in the graph.
  
      Returns
      -------
      Tensor
          Result tensor.
  
      Examples
      --------
  
      >>> import dgl
      >>> import torch as th
  
      Create two :class:`~dgl.DGLGraph` objects and initialize their
      node features.
  
      >>> g1 = dgl.graph(([0, 1], [1, 0]))              # Graph 1
      >>> g1.ndata['h'] = th.tensor([1., 1.])
      >>> g2 = dgl.graph(([0, 1], [1, 2]))              # Graph 2
      >>> g2.ndata['h'] = th.tensor([1., 1., 1.])
  
      Softmax over one graph:
  
      >>> dgl.softmax_nodes(g1, 'h')
      tensor([.5000, .5000])
  
      Softmax over a batched graph:
  
      >>> bg = dgl.batch([g1, g2])
      >>> dgl.softmax_nodes(bg, 'h')
      tensor([.5000, .5000, .3333, .3333, .3333])
  
      See Also
      --------
      softmax_edges
      """
      x = graph.nodes[ntype].data[feat]
      return segment.segment_softmax(graph.batch_num_nodes(ntype), 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 9 for calling a global function with example usage: softmax_nodes(graph, feat) and returns: segment