Here is the solution:
out = out.view(-1)

What was the mistake?
out is a (4,1) vector and y is a (4,) vector.
The subtraction out - y created a (4,4) vector as opposed to a (4,1) vector.
This caused all following calculations to be incorrect.