def repeat2dvect(arr, rep):
    lens = rep.sum(axis=-1)
maxlen = lens.max()
ret_val = np.zeros((arr.shape[0], maxlen))
mask = lens[:, (None)] > np.arange(maxlen)
ret_val[mask] = np.repeat(arr.ravel(), rep.ravel())
return ret_val
Повтор Numpy для 2d-массива