The code is unfortunately still not executable. After fixing some np.array/tensor issues as well as device mismatches, I get:
RuntimeError: The size of tensor a (4) must match the size of tensor b (20) at non-singleton dimension 0