code: def softmax(X, copy=True):
      """
      Calculate the softmax function.
  
      The softmax function is calculated by
      np.exp(X) / np.sum(np.exp(X), axis=1)
  
      This will cause overflow when large values are exponentiated.
      Hence the largest value in each row is subtracted from each data
      point to prevent this.
  
      Parameters
      ----------
      X : array-like of float of shape (M, N)
          Argument to the logistic function.
  
      copy : bool, default=True
          Copy X or not.
  
      Returns
      -------
      out : ndarray of shape (M, N)
          Softmax function evaluated at every point in x.
      """
      if copy:
          X = mt.copy(X)
      max_prob = mt.max(X, axis=1).reshape((-1, 1))
      X = X - max_prob
      X = mt.exp(X)
      sum_prob = mt.sum(X, axis=1).reshape((-1, 1))
      X = X / sum_prob
      return X
  
imports: import numpy
  from ...None import tensor
label_desc: Use image node_id 3 for calling a global function with example usage: softmax(X, copy) and returns: X