It might have to do with the fact that labels is a list, not an array. Therefore you cannot use array slicing on it. Try to convert labels to an array first:
labels_array = np.array(labels)
Get back to me if it does or doesn’t work.