code: def _npSoftmax(self, features, dim=-1, log=False):
      if dim == -1:
          dim = len(features.shape) - 1
      one_only_on_dim = list(features.shape)
      one_only_on_dim[dim] = 1
      is_fp16 = features.dtype == np.float16
      if is_fp16:
          # Do the compute in fp32 and cast the input back to fp32.
          features = features.astype(np.float32)
      e = np.exp(
          features
          - np.reshape(np.amax(features, axis=dim), one_only_on_dim)
      )
      softmax = e / np.reshape(np.sum(e, axis=dim), one_only_on_dim)
      if log:
          res = np.log(softmax)
      else:
          res = softmax
      if is_fp16:
          res = res.astype(np.float16)
      return res
  
imports: import unittest
  import numpy
  from tensorflow.python.framework import constant_op
  from tensorflow.python.framework import dtypes
  from tensorflow.python.framework import errors_impl
  from tensorflow.python.ops import array_ops
  from tensorflow.python.ops import math_ops
  from tensorflow.python.ops import nn_ops
  from tensorflow.python.platform import test
  from tensorflow.python.platform import tf_logging
label_desc: Use image node_id 1 for calling the SoftmaxTest obj's underlying member method code with example usage: obj._npSoftmax(features, dim, log) and returns: res