parameters: (x)
return_statement: return x
docstring: Compute the softmax function for each row of the input x.
      It is crucial that this function is optimized for speed because
      it will be used frequently in later code. 
  
      Arguments:
      x -- A D dimensional vector or N x D dimensional numpy matrix.
      Return:
      x -- You are allowed to modify x in-place
docstring_summary: Compute the softmax function for each row of the input x.
      It is crucial that this function is optimized for speed because
      it will be used frequently in later code.
docstring_tokens: Compute the softmax function for each row of the input x . It is crucial that this function is optimized for speed because it will be used frequently in later code .
function: def softmax(x):
      """Compute the softmax function for each row of the input x.
      It is crucial that this function is optimized for speed because
      it will be used frequently in later code. 
  
      Arguments:
      x -- A D dimensional vector or N x D dimensional numpy matrix.
      Return:
      x -- You are allowed to modify x in-place
      """
      orig_shape = x.shape
  
      if len(x.shape) > 1:
          # Matrix
          tmp = np.max(x, axis=1)
          x -= tmp.reshape((x.shape[0], 1))
          x = np.exp(x)
          tmp = np.sum(x, axis=1)
          x /= tmp.reshape((x.shape[0], 1))
      else:
          # Vector
          tmp = np.max(x)
          x -= tmp
          x = np.exp(x)
          tmp = np.sum(x)
          x /= tmp
  
      assert x.shape == orig_shape
      return x
function_tokens: def softmax ( x ) : orig_shape = x . shape if len ( x . shape ) > 1 : # Matrix tmp = np . max ( x , axis = 1 ) x -= tmp . reshape ( ( x . shape [ 0 ] , 1 ) ) x = np . exp ( x ) tmp = np . sum ( x , axis = 1 ) x /= tmp . reshape ( ( x . shape [ 0 ] , 1 ) ) else : # Vector tmp = np . max ( x ) x -= tmp x = np . exp ( x ) tmp = np . sum ( x ) x /= tmp assert x . shape == orig_shape return x