def threshold_predictions(predictions, thr=0.999):
    """This method will threshold predictions.

    :param thr: the threshold (if None, no threshold will
                be applied).
    :return: thresholded predictions
    """
    if thr is None:
        return predictions[:]

    thresholded_preds = predictions[:]
    low_values_indices = thresholded_preds <= thr
    thresholded_preds[low_values_indices] = 0
    low_values_indices = thresholded_preds > thr
    thresholded_preds[low_values_indices] = 1
    return thresholded_preds