Not understand the error

Hi
I am facing this waning I don’t understand the warning what does it mean

C:\Users\NUC-i7 8gen\Anaconda3\lib\site-packages\torch\nn\modules\loss.py:431: UserWarning: Using a target size (torch.Size([32, 6])) that is different to the input size (torch.Size([32, 1, 6])). This will likely lead to incorrect results due to broadcasting. Please ensure they have the same size.
return F.mse_loss(input, target, reduction=self.reduction)
C:\Users\NUC-i7 8gen\Anaconda3\lib\site-packages\torch\nn\modules\loss.py:431: UserWarning: Using a target size (torch.Size([29, 6])) that is different to the input size (torch.Size([29, 1, 6])). This will likely lead to incorrect results due to broadcasting. Please ensure they have the same size.
return F.mse_loss(input, target, reduction=self.reduction)

and my training code is

for epoch in range(num_epochs):
    for inputs,labels in train_loader:
        
        inputs = inputs.float()
        labels = labels.float()
        
        # Feed Forward
        output = model(inputs)
        output = output.unsqueeze(1)
        
        # Loss Calculation
        loss_train = criterion(output, labels)
        train_loss.append(loss_train)
        
        # Clear the gradient buffer (we don't want to accumulate gradients)
        optimizer.zero_grad()
        
        # Backpropagation 
        loss_train.backward()
        
        # Weight Update: w <-- w - lr * gradient
        optimizer.step()
        
    #Accuracy
    # Since we are using a sigmoid, we will need to perform some thresholding
    output = (output>0.5).float()
    # Accuracy: (output == labels).float().sum() / output.shape[0]
    accuracy = (output == labels).float().mean()
    # Print statistics 
    print("Epoch {}/{}, Loss: {:.3f}, Accuracy: {:.3f}".format(epoch+1,num_epochs, loss_train, accuracy))

Any one can explain to me the warning’s concept.

Thanks in advance.

Since your output and target shape do not match, but are broadcastable, you might get a wrong result.
Have a look at this example:

x = torch.arange(1, 5).view(2, 2)
y = torch.ones(2, 2)
loss = x - y
print(loss)

x = x.unsqueeze(1)
loss = x - y
print(loss)

While you would most likely expect the first result using your tensors, you might end up with the second one.
To resolve this issue, you could squeeze dim1 in your model output:

output = model(data)
output = output.squeeze(1)
loss = criterion(output, target)