It seems you are defining out = 0 in the global scope, pass this integer then to the model in:
print(out.shape)
pred = model(out)

which I would assume should yield errors, since neither out.shape is defined nor would the model accept an int as the input, and later calculate the loss using out.
Besides that you are also overriding loss (the criterion) with the loss value, so wou might also want to fix this.