The correct way for using a model for inference is
model = TheModelClass(*args, **kwargs)
model.load_state_dict(torch.load(PATH))
model.eval()

You have modified this  part which I guess is causing th error.
https://pytorch.org/tutorials/beginner/saving_loading_models.html 2