Of course, just make sure the order of the ground truth and the order of the predictions is the same. The right way to reshape could be:
# if your output is B x 2 x C x D x D
output.permute(0, 3, 4, 1, 2).contiguous().view(-1, C)