def loss_labels(self, outputs, targets, indices, num_masks):
        """Classification loss (NLL)
        targets dicts must contain the key "labels" containing a tensor of dim [nb_target_boxes]
        """
        targets_cpt, indices_cpt = [], []
        for t, indice in zip(targets, indices):
            if t['labels'].shape[0] != 0:
                targets_cpt.append(t)
                indices_cpt.append(indice)
        else:
            if indices_cpt == []:
                losses = {"loss_ce": paddle.to_tensor([0.0])}
                return losses

        assert "pred_logits" in outputs, "The 'pred_logits' need to be in outputs, but only got keys: {}".format(
            outputs.keys())

        src_logits = outputs["pred_logits"]
        idx = self._get_src_permutation_idx(indices)
        target_classes_o = paddle.concat(
            [t["labels"][J] for t, (_, J) in zip(targets_cpt, indices_cpt)])
        target_classes = paddle.full(
            src_logits.shape[:2], self.num_classes, dtype='int64')
        target_classes[idx] = target_classes_o

        loss_ce = F.cross_entropy(
            src_logits.transpose((0, 2, 1)).cast('float32'),
            target_classes,
            weight=self.empty_weight,
            axis=1,
            use_softmax=True,
            ignore_index=255)
        losses = {"loss_ce": loss_ce}
        return losses
Classification loss (NLL)
        targets dicts must contain the key "labels" containing a tensor of dim [nb_target_boxes]
        
paddleseg/models/losses/maskformer_loss.py