many thanks for your reply. This is also something I have been trying:
lstm = []

for t in range(num_epochs):
    for inputs, targets in zip(X_train,y_train):
         optimiser.zero_grad()
         y_train_pred = model(inputs)    

         loss = criterion(y_train_pred, targets.reshape(targets.shape[0],1,1))
         loss.backward()
         optimiser.step()
    print("Epoch ", t, "MSE: ", loss.item())
    hist[t] = loss.item()

However using my actual dataset I got this error:
RuntimeError: input must have 3 dimensions, got 2
I should reshape my dataset to avoid this error?