For you first trial
torch.save({
‘model_state_dict’: model.state_dict(),
}, os.path.join(self.checkpoint, ‘model_{}.pth’.format(task_id)))

If you load the checkpoint file and print its keys, you would see
checkpoint = torch.load('...<the path>...')
print(checkpoint.keys())
# output
>>> ['model_state_dict']

So the solution is:

directly saving the model and directly load

# save
torch.save(model.state_dict(), '...<path>...')
# load
model.load_state_dict(torch.load('...<path>...'))


save the model states with a key and load it with THAT key

# save
torch.save({
    'mymodel': model.state_dict()
    }, '...<path>...')
# load
model.load_state_dict(torch.load('...<path>...')['mymodel'])

And for the error AttributeError: ‘collections.OrderedDict’ object has no attribute ‘state_dict’, just use type(model) to check the type of model.