def slice_dim(slc, axis):
    """Return slice object that indexes along an arbitrary axis.
    Args:
        slc: the object used for slicing e.g. a slice object, an int or a sequence
        axis: the axis to slice
    """
    if axis < 0:
        return (Ellipsis, slc) + (slice(None),) * (-axis - 1)
    else:
        return (slice(None),) * axis + (slc, Ellipsis)
