import torch


def reduce_sign_any(input_tensor, dim=-1):
    """A logical or of the signs of a tensor along an axis.

    Args:
    input_tensor: Tensor<float> of any shape.
    axis: the axis along which we want to compute a logical or of the signs of
        the values.

    Returns:
    A Tensor<float>, which as the same shape as the input tensor, but without the
    axis on which we reduced.
    """
    boolean_sign = torch.any(
        ((torch.sign(input_tensor) + 1) / 2.0).bool(), dim=dim
    )
    return boolean_sign.type(input_tensor.dtype) * 2.0 - 1.0