It seems you are passing the arguments in the wrong order.
While the function definition is:
def train(model, dataloaders, optimizer, criterion, ...)

you are using
train_model(model_ft, dataloaders_dict, criterion, optimizer_ft, ...)

Your code should work if you swap criterion and optimizer_ft.