@force_fp32(apply_to=('cls_score', 'bbox_pred', 'dis_pred'))
def loss(self, cls_score, bbox_pred, dis_pred, rois, labels, label_weights, bbox_targets, bbox_weights, dis_targets, reduction_override=None):
    losses = dict()
    if (cls_score is not None):
        avg_factor = max(torch.sum((label_weights > 0)).float().item(), 1.0)
        if (cls_score.numel() > 0):
            losses['loss_cls'] = self.loss_cls(cls_score, labels, label_weights, avg_factor=avg_factor, reduction_override=reduction_override)
            losses['acc'] = accuracy(cls_score, labels)
    if (bbox_pred is not None):
        bg_class_ind = self.num_classes
        pos_inds = ((labels >= 0) & (labels < bg_class_ind))
        if pos_inds.any():
            if self.reg_decoded_bbox:
                bbox_pred = self.bbox_coder.decode(rois[:, 1:], bbox_pred)
            if self.reg_class_agnostic:
                pos_bbox_pred = bbox_pred.view(bbox_pred.size(0), 4)[pos_inds.type(torch.bool)]
            else:
                pos_bbox_pred = bbox_pred.view(bbox_pred.size(0), (- 1), 4)[(pos_inds.type(torch.bool), labels[pos_inds.type(torch.bool)])]
            losses['loss_bbox'] = self.loss_bbox(pos_bbox_pred, bbox_targets[pos_inds.type(torch.bool)], bbox_weights[pos_inds.type(torch.bool)], avg_factor=bbox_targets.size(0), reduction_override=reduction_override)
        else:
            losses['loss_bbox'] = bbox_pred[pos_inds].sum()
    if (dis_pred is not None):
        pos_inds = (dis_targets != (- 1))
        if pos_inds.any():
            pos_dis_pred = dis_pred[pos_inds.type(torch.bool)]
            pos_dis_targets = dis_targets[pos_inds.type(torch.bool)]
            avg_factor = dis_pred.size(0)
            losses['loss_dis'] = self.loss_dis(pos_dis_pred, pos_dis_targets, avg_factor=avg_factor, reduction_override=reduction_override)
    return losses
@force_fp32(apply_to=('cls_score', 'bbox_pred', 'dis_pred'))
def loss(self, cls_score, bbox_pred, dis_pred, rois, labels, label_weights, bbox_targets, bbox_weights, dis_targets, reduction_override=None):
    losses = dict()
    if (cls_score is not None):
        avg_factor = max(torch.sum((label_weights > 0)).float().item(), 1.0)
        if (cls_score.numel() > 0):
            losses['loss_cls'] = self.loss_cls(cls_score, labels, label_weights, avg_factor=avg_factor, reduction_override=reduction_override)
            losses['acc'] = accuracy(cls_score, labels)
    if (bbox_pred is not None):
        bg_class_ind = self.num_classes
        pos_inds = ((labels >= 0) & (labels < bg_class_ind))
        if pos_inds.any():
            if self.reg_decoded_bbox:
                bbox_pred = self.bbox_coder.decode(rois[:, 1:], bbox_pred)
            if self.reg_class_agnostic:
                pos_bbox_pred = bbox_pred.view(bbox_pred.size(0), 4)[pos_inds.type(torch.bool)]
            else:
                pos_bbox_pred = bbox_pred.view(bbox_pred.size(0), (- 1), 4)[(pos_inds.type(torch.bool), labels[pos_inds.type(torch.bool)])]
            losses['loss_bbox'] = self.loss_bbox(pos_bbox_pred, bbox_targets[pos_inds.type(torch.bool)], bbox_weights[pos_inds.type(torch.bool)], avg_factor=bbox_targets.size(0), reduction_override=reduction_override)
        else:
            losses['loss_bbox'] = bbox_pred[pos_inds].sum()
    if (dis_pred is not None):
        pos_inds = (dis_targets != (- 1))
        if pos_inds.any():
            pos_dis_pred = dis_pred[pos_inds.type(torch.bool)]
            pos_dis_targets = dis_targets[pos_inds.type(torch.bool)]
            avg_factor = dis_pred.size(0)
            losses['loss_dis'] = self.loss_dis(pos_dis_pred, pos_dis_targets, avg_factor=avg_factor, reduction_override=reduction_override)
    return losses