How to save model checkpoints to resume training

I am confused how to save model for the purpose of resume training
I have a function

def fit(model,train,val):
    return loss

I configure model as follow
criterion = nn.BCEWithLogitsLoss()

Then I call function as

Do I need to return optimizer and model from my fit function to save checkpoint as follow

state = {
        'epoch': epoch,
        'state_dict': model.state_dict(),
        'optimizer': opt.state_dict(),

Your approach looks correct and is also explained in this tutorial.

sorry, its not clear to me. I am not sure whether model variable out of function is updated or we need to return model object