If you want to use feature from the previous iteration, you could store it in another variable so that it won’t be overwritten by the model(input_var) call.
Note that Variables are deprecated since PyTorch 0.4 so you can use tensors in newer versions.
Also, call nn.Modules directly via criterion(feature, ...) instead of the .forward method, as the latter approach won’t call into registered hooks and might yield unexpected behavior.