def partition(xrange, sz, overlap=0, skip=[]):
    """Divide range into subsets specified by size, overlap, and indices to skip.

    Args:
        xrange (range)
        sz (int): target size of subset
        overlap (int): amount of overlap between subsets
        skip ([int]): indices to skip in start/end of subset

    Returns:
        list of subset ranges
    """
    subsets = []
    xs_start = xrange.start
    xs_next = min(xs_start + sz, xrange.stop)
    while xs_start < xs_next:
        xs_stop = xs_next
        while xs_stop in skip and xs_stop < xrange.stop:
            xs_stop += 1
        while xs_start in skip and xs_start + overlap < xs_stop:
            xs_start += 1
        xs_stop = min(xrange.stop, xs_stop + overlap)
        if xs_start < xs_stop:
            subsets.append(range(xs_start, xs_stop))
        xs_start = xs_next
        xs_next = min(xs_next + sz, xrange.stop)
    return subsets