def get_loss_direction(a, b):
    """
    Return a tensor with values in {-1, 0, 1} implementing the following function
    `f(a, b) = (a + b - b * (1 - a)) - 1`.

    The desired effect is
     * a=1, b=1 -> 1
     * a=1, b=0 -> 0
     * a=0, b=1 -> -1
     * a=0, b=0 -> -1

    :param a: A [d1, ..., dN] tensor with values in {0, 1}
    :param b: A [d1, ..., dN] tensor with values in {0, 1}
    :return: A [d1, ..., dN] tensor with values in {-1, 0, 1}
    """
    return (a + b - b * (1 - a)) - 1