No, I think it was not the source of the error.
In this c++ code, “10” is batch size.
I have tested the jit model from this source (https://pytorch.org/tutorials/beginner/blitz/neural_networks_tutorial.html#sphx-glr-beginner-blitz-neural-networks-tutorial-py 1).
In C++, the shape of the input is (10,1,32,32).
It run successfully.
According to the error message, I think the error source may from this line
            out_final[:, i, :] = x1[:, 0, :]