Make overlap_slices, etc., good for arbitrary number of dimensions