I want to compute sum of cross entropy over all classes for each prediction, where the input is batch (size n), and the output is batch (size n).

The simplest way is for loop (for 1000 classes):
def sum_of_CE_lost(input):
  CE = torch.nn.CrossEntropyLoss()
  L = 0
  for x in range(1000):
    L = L + CE(logit_unknown,tensor( np.ones( input.shape[0] ) *x , dtype=torch.int64 ).cuda() )
  loss = L.sum()
  return loss

However, it is very slow. What is a better way? How can we parallelized it for GPU (CUDA)?
input is prediction of imagenet_resnet50 on bathc, i.e., shape of input is [batch_size, number-of_classes]