RuntimeError: input must have 3 dimensions, got 2. Help with GRU

class CustomDataset(Dataset):
def init(self, X_data, Y_data):
super(CustomDataset, self).init()
self.X_data = X_data
self.Y_data = Y_data
# Initializes the data and preprocessing.
def getitem(self, index):
return self.X_data[index,:,:], self.Y_data[index,:,:]
# Returns data (input and output) in batches.
def len (self):
return len(self.X_data[:,1,1])
# Returns the size of the input data.

def train_loop(dataloader, model, loss_fn, optimizer, lossvalue, recall, accuracy, f1score):
#size = len(dataloader.dataset)
size = dataloader.len()
for batch, (X, y) in enumerate(dataloader):
# Compute prediction and loss
pred = model(X)
loss = loss_fn(pred, y)
# Backpropagation
optimizer.zero_grad()
loss.backward()
optimizer.step()
if batch % 100 == 0:
loss, current = loss.item(), batch * len(X)
print(f"loss: {loss:>7f} [{current:>5d}/{size:>5d}]")
lossvalue.append(loss)
recall = recall.append(torchmetrics.functional.precision_recall(pred, y))
accuracy = accuracy.append(torchmetrics.functional.accuracy(pred, y))
f1score = f1score.append(torchmetrics.functional.f1(pred,y))

I am running a stacked gru. I have written the program to print the tensorshape before initializing the train dataload and got 3 dim (batch,seq,feature). I can’t seem to find what is wrong with my code? Help would be much appreciated