dims = tuple(np.multiply.reduceat(np.zeros(16, int) + 2, np.r_[0, np.sort(
    np.random.choice(16, np.random.randint(10)))]))
np.moveaxis(np.indices(dims), 0, -1)
Create an array where each element stores its indices