The sparse loss functions (and their equivalent classes) return nans when there is -inf in the input.
import torch
import numpy as np
from entmax import entmax15_loss, sparsemax_loss
x = torch.rand(10, 5)
y = torch.randint(0, 4, [10])
x[:, 4] = -np.inf
entmax15_loss(x, y)
# tensor([nan, nan, nan, nan, nan, nan, nan, nan, nan, nan])
sparsemax_loss(x, y)
# tensor([nan, nan, nan, nan, nan, nan, nan, nan, nan, nan])