def dice_loss(inputs, targets, num_boxes):
        """
        From DETR source: https://github.com/facebookresearch/detr
        (detr/models/segmentation.py)
        """
        inputs = inputs.sigmoid()
        inputs = inputs.flatten(1)
        numerator = 2 * (inputs * targets).sum(1)
        denominator = inputs.sum(-1) + targets.sum(-1)
        loss = 1 - (numerator + 1) / (denominator + 1)
        return loss.sum() / num_boxes

        From DETR source: https://github.com/facebookresearch/detr
        (detr/models/segmentation.py)
        
art/estimators/object_detection/detr.py