I had a same error, resolved by change variable assignment
model=model.load_state_dict(torch.load('model_data/finetuned_BERT_epoch_5.model', map_location='cpu'))
model.eval()

to
model.load_state_dict(torch.load('model_data/finetuned_BERT_epoch_5.model', map_location='cpu'))
model.eval()

Now it is working