def validate_tile_size(tile_size, img_size=None):
    """Validates tile size argument provided for slicing.

    Parameters
    ----------
    tile_size : tuple
        Size of each tile in pixels, as a 2-tuple: (width, height).
    img_size : tuple, optional
        Size of original image in pixels, as a 2-tuple: (width, height).

    Returns
    ----------
    None

    Raises
    ----------
    ValueError
        If `tile_size` does not hold exactly `2` values
        If `tile_size` does not comply with `img_size`
    TypeError
        If `tile_size` or `img_size` are not of type tuple.
    """
    if img_size is None:
        if isinstance(tile_size, tuple):
            if len(tile_size) != 2:
                raise ValueError(
                    'Tile size must be a tuple of size 2 i.e., (w, h). The tuple provided was {}'
                    .format(tile_size))
        else:
            raise TypeError(
                'Tile size must be a tuple. The argument was of type {}'.
                format(type(tile_size)))
    elif isinstance(img_size, tuple):
        if sum(tile_size) >= sum(img_size) or tile_size[0] > img_size[0
            ] or tile_size[1] > img_size[1]:
            raise ValueError(
                'Tile size cannot exceed image size. Tile size was {} while image size was {}'
                .format(tile_size, img_size))
    else:
        raise TypeError(
            'Image size must be a tuple. The argument was of type {}'.
            format(type(img_size)))
