I guess the error is caused in:
model=BertForMaskedLM.from_pretrained(model_path)

which most likely does not expect a path to a state_dict, so check the docs for this method and make sure to pass the right arguments to it.