Hi KFrank,
thanks for your fast reply!
I read the post you mentioned and try to implement it. The first aspect I recognised was that my target vector must have the shape of (Batchsize, C) now instead of (Batchsize, ). So instead of the ground truth value, I have to pass in the corresponding line of the distance matrix. Did I get it right?
Attached you can find my first draft: I made some modifications from your code since, as far as I know the usage of  Variabel is deprected:
def softXEnt (input, target):
    logprobs = torch.nn.functional.log_softmax (input, dim = 1)
    return  -(target * logprobs).sum() / input.shape[0]

# input values are logits
# 4 possible classes and 2 samples 
inputBad = torch.tensor([[3,5,2.5,6], [7,5.5,2,0]])
inputGood = torch.tensor([[0,0,0,1], [1,0,0,0]], dtype=torch.float)

# ground truth is [4,1]
# Recap the distance matrix is:
# 0 , 1 , 4 , 5
# 1 , 0 , 3 , 8
# 4 , 3 , 0 , 2
# 5 , 8 , 2 , 0

# For softmax we need a float tensor
penalize_target = torch.tensor([[5 , 8 , 2 , 0], [0 , 1 , 4 , 5]], dtype=torch.float)
target = torch.nn.functional.softmax(penalize_target, dim = 1)

print("SoftXEnt result bad prediction")
print(softXEnt (inputBad, target))
print("SoftXEnt result good prediction")
print(softXEnt(inputGood, target))

And the output is.
SoftXEnt result bad prediction
tensor(4.0218)
SoftXEnt result good prediction
tensor(1.7411)

As we can see, the pad predication is stronger penalized than the good prediction of the classificator. However, shouldn’t the good prediction result in a tensor(0.0) since the prediction is equal to the ground truth?
Thanks! Looking forward to your opinion!
Best
roxor