import torch


def tagging_criterion(pred_labeled, y_labeled):
    """The loss function for tagging task (with float tensor input)

    Args:
        pred_labeled (Tensor): the predicted float tensor
        y_labeled (Tensor): the groundtruth float tensor

    Returns:
        Tensor: the cross entropy loss with the 0'th dimention ignored
    """
    # cross-entropy, ignore the 0 class
    loss_x = torch.sum(-y_labeled[:, 1:] * pred_labeled[:, 1:].log(), -1).mean()
    return loss_x