def overflow_safe_mean(arr, axis=None):
    """Computes mean values across an array with reduced overflow risk (NO WARRANTIES, THOUGH - STILL MAY OVERFLOW).

    Parameters
    ----------
    arr: array-like
    axis: int or tuple, optional

    Returns
    -------
    mean: array-like
    """
    if axis is None:
        return arr.mean()
    if isinstance(axis, int):
        return arr.mean(axis=axis)
    for ax in sorted(axis, reverse=True):
        arr = arr.mean(axis=ax)
    return arr