import math
def softmax(xs):
    if not xs: return []
    m = max(xs)
    exps = [math.exp(x - m) for x in xs]
    s = sum(exps)
    return [round(e/s, 4) for e in exps]
assert softmax([1, 1]) == [0.5, 0.5]
assert abs(sum(softmax([1, 2, 3])) - 1.0) < 0.0001
print("SELF-TEST PASS")