def METHOD_NAME(x, axis=None):
    if x.dtype is not np.float64:
        x = x.astype(np.float64)
    if axis is None:
        axis = tuple(range(1, x.ndim))
    shift = np.max(x, axis=axis, keepdims=True)
    y = np.exp(x - shift)
    return y / np.sum(y, axis=axis, keepdims=True)