def loss_labels_openimage(self, outputs, targets, indices, num_masks, layer_id, extra):
        """Classification loss (NLL)
        targets dicts must contain the key "labels" containing a tensor of dim [nb_target_boxes]
        """
        if layer_id > self.top_x_layers['mask']:
            return {"loss_openimage_ce_0": 0}

        assert "pred_captions" in outputs

        if indices is None or len(targets) == 0 or (len(targets) > 0 and len(targets[0]['labels']) == 0):
            loss_ce = outputs['pred_captions'].sum() * 0.0
            losses = {"loss_openimage_ce_0": loss_ce}
            return losses

        # compute i2t loss
        loss_openimage_ce = 0
        losses = {}
        for b in range(len(indices)):
            pred_logit = outputs["pred_logits"][b][indices[b][0]]
            gt_logit = torch.zeros_like(pred_logit)
            select_idx = torch.stack((torch.arange(len(indices[b][1])), indices[b][1])).tolist()
            gt_logit[select_idx] = 1
            loss_openimage_ce += torch.sum(-gt_logit * F.log_softmax(pred_logit, dim=-1), dim=-1).mean()
        loss_openimage_ce = loss_openimage_ce / len(indices)
        losses.update({"loss_openimage_ce_0": loss_openimage_ce})
        return losses
Classification loss (NLL)
        targets dicts must contain the key "labels" containing a tensor of dim [nb_target_boxes]
        
modeling/modules/criterion.py