From the docs 92
ignore_index (int, optional) – Specifies a target value that is ignored and does not contribute to the input gradient. When size_average is True, the loss is averaged over non-ignored targets.
Also from the docs the formula for CrossEntropyLoss is
loss(x, class) = -log(exp(x[class]) / (\sum_j exp(x[j])))
Now some basic math


exp(x[class]) is always positive

\sum_j exp(x[j]) is always greater than exp(x[class])

so exp(x[class]) / (\sum_j exp(x[j])) is always in the range [0, 1]

log(anything in the range [0, 1]) is in the range (-inf, 0]

Hence -log(exp(x[class]) / (\sum_j exp(x[j]))) is in the range [0, +inf)