I guess the squeeze operation is not needed and will create an error, e.g. if the last batch contains only one sample:
loss = loss(predicted.squeeze(), output)

Based on the comment predicted should have a shape of [10, 5]. If that’s the shape before applying the squeeze operation, just remove it and pass the tensors directly to the criterion:
loss = criterion(predicted, output)

Also, rename the loss function to criterion or any other name, as you are overriding it with the loss tensor.
Unrelated to this issue, but call the model directly to execute the forward pass as:
predicted = network(input)

instead of the .forward method.
PS: you can post code snippets by wrapping them into three backticks ```, which makes debugging easier.