def score_fn(mask: np.ndarray, tr_err: float, object_size: float, threshold: float = 0.75, lbd: float = 5):
    """
    Mask scoring function.

    :param mask: The mask.
    :param tr_err: The error in transform-robustness.
    :param object_size: The size of the object.
    :param threshold: The threshold at which to heavily penalize.
    :param lbd: lambda weight multiplier.
    :return: Score of the mask.
    """
    if tr_err > threshold:
        return 10000000

    return lbd * mask.sum() / 3 / (object_size) + tr_err

    Mask scoring function.

    :param mask: The mask.
    :param tr_err: The error in transform-robustness.
    :param object_size: The size of the object.
    :param threshold: The threshold at which to heavily penalize.
    :param lbd: lambda weight multiplier.
    :return: Score of the mask.
    
art/attacks/evasion/graphite/utils.py