Efficiently find indices of all values in an array,{i: np.where(arr == i)[0] for i in np.unique(arr)}