def _check_target_size(size):
    """
    Common check to enforce type and sanity check on size tuples
    Args:
        size: Should be a tuple of size 2 (width, height)

    Returns:
        Raises a ValueError if ``size`` doesn't satisfy the required conditions.
    """

    if not isinstance(size, (list, tuple)):
        raise ValueError("`target_size` must be a tuple of length 2 `(width,height)`")
    if len(size) != 2:
        raise ValueError("`target_size` must be a tuple of length 2 `(width,height)`")
    if size[0] < 0 or size[1] < 0:
        raise ValueError("Width and height must be >= 0")

    return True