Hi, I have a suggestion for your implementation.
Wouldn’t it be more apt to store context as well along with the model during saving & loading a general checkpoint for inference and/or resuming training?
torch.save({
            'epoch': epoch,
            'model_state_dict': model.state_dict(),
            'optimizer_state_dict': optimizer.state_dict(),
            'loss': loss,
            ...
            }, PATH)