import torch


def binarize_thresholds(pred, thresholds=[0.5]):
    """
    Args:
        pred: model pred tensor with shape b x c x (X x Y)
        thresholds: list of floats i.e. [0.6,0.5,0.4]

    Returns:
        float tensor: binary values
    """

    C = len(thresholds)
    thresholds = torch.tensor(thresholds)
    thresholds = thresholds.reshape(1, C, 1, 1)
    thresholds.expand_as(pred)
    thresholds = thresholds.to(pred.device)
    res = pred > thresholds

    return res.float()