For crossentropy loss function why output and target size cannot be the same

nn.CrossEntropyLoss is used for multi-class classification use cases, i.e. each sample belongs to a single target class.
In your example, num_items in the output would correspond to the number of classes.
Each row would give you the logits of this sample to belong to the class at column x.
Based on this, the target should only contain the target class indices, which are used to calculate the cross entropy loss.

If your targets might take arbitrary values for each element of your output, you might want to use some loss function like nn.MSELoss.