def METHOD_NAME(self, pred_start, pred_end, gt_start, gt_end):
    def bi_loss(pred_score, gt_label, datatype):
        pred_score = paddle.reshape(x=pred_score, shape=[-1])
        gt_label = paddle.reshape(x=gt_label, shape=[-1])
        gt_label.stop_gradient = True
        pmask = paddle.cast(x=(gt_label > 0.5), dtype=datatype)
        num_entries = paddle.cast(paddle.shape(pmask), dtype=datatype)
        num_positive = paddle.cast(paddle.sum(pmask), dtype=datatype)
        ratio = num_entries / num_positive
        coef_0 = 0.5 * ratio / (ratio - 1)
        coef_1 = 0.5 * ratio
        epsilon = 0.000001
        loss_pos = paddle.multiply(paddle.log(pred_score + epsilon), pmask)
        loss_pos = coef_1 * paddle.mean(loss_pos)
        loss_neg = paddle.multiply(paddle.log(1.0 - pred_score + epsilon),
                                   (1.0 - pmask))
        loss_neg = coef_0 * paddle.mean(loss_neg)
        loss = -1 * (loss_pos + loss_neg)
        return loss
    loss_start = bi_loss(pred_start, gt_start, pred_start.dtype)
    loss_end = bi_loss(pred_end, gt_end, pred_start.dtype)
    loss = loss_start + loss_end
    return loss