If you are concerned about the behavior of Variable (which is reasonable, as it’s deprecated), remove it and rerun the code.
I couldn’t follow the entire explanation, but would recommend to also check, if model.eval() would solve the issue.
If not, feel free to post an executable, minimal code snippet to reproduce the issue.