def log_sum_exp(x, axis=(- 1)):
    a = x.max(axis=axis, keepdims=True)
    out = (a + np.log(np.sum(np.exp((x - a)), axis=axis, keepdims=True)))
    return np.squeeze(out, axis=axis)
def log_sum_exp(x, axis=(- 1)):
    a = x.max(axis=axis, keepdims=True)
    out = (a + np.log(np.sum(np.exp((x - a)), axis=axis, keepdims=True)))
    return np.squeeze(out, axis=axis)