Since you are recreating a tensor in self.predict, you are detaching the output from the computation graph.
Try to use output = model(x) to train your model, i.e. pass it to your criterion instead of y_pred.