def METHOD_NAME(
    a: ndarray, axis: Optional[int], bitorder: BitOrder
) -> Tuple[ndarray, int]:
    if axis is None:
        if a.ndim > 1:
            a = a.ravel()
        sanitized_axis = 0
    elif axis < 0:
        sanitized_axis = axis + a.ndim
    else:
        sanitized_axis = axis
    if sanitized_axis < 0 or sanitized_axis >= a.ndim:
        raise ValueError(
            f"axis {axis} is out of bounds for array of dimension {a.ndim}"
        )
    if bitorder not in ("big", "little"):
        raise ValueError("'order' must be either 'little' or 'big'")
    return a, sanitized_axis