code: def softmax(p, axis=None, temperature=1):
      """Apply the softmax transform to an array of categorical distributions.
  
      Args:
        p: an array of categorical probability vectors, possibly unnormalized.
        axis: the axis that spans the categories (default: -1).
        temperature: if not 1, transform the distribution by dividing the log
            probabilities and renormalizing. Values greater than 1 increase entropy,
            values less than 1 decrease entropy. A value of 0 yields a deterministic
            distribution that chooses the mode.
  
      Returns:
        An array of categorical probability vectors, like `p` but tempered and
        normalized.
      """
      if axis is None:
          axis = p.ndim - 1
      if temperature == 0.0:
          # NOTE: in case of multiple equal maxima, returns uniform distribution.
          p = p == np.max(p, axis=axis, keepdims=True)
      else:
          # oldp = p
          logp = np.log(p)
          logp /= temperature
          logp -= logp.max(axis=axis, keepdims=True)
          p = np.exp(logp)
      p /= p.sum(axis=axis, keepdims=True)
      if np.isnan(p).any():
          pdb.set_trace()  # pylint: disable=forgotten-debug-statement
      return p
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import contextlib
  import datetime
  import numbers
  import pdb
  import tempfile
  import time
  import numpy
  import tensorflow.compat.v1
label_desc: Use image node_id 3 for calling a global function with example usage: softmax(p, axis, temperature) and returns: p