TensorFlow 2 one-hot encoding of labels
The loss function handles the conversion. TensorFlow has a SparseCategoricalCrossentropy and a CategoricalCrossentropy loss function. The first expect your labels to be provided as integers, where the latter expects one-hot encodings. In the given example, they use the SparseCategoricalCrossentropy loss function, therefore it is ok to supply your labels as integers.