If you check the code, there’s a lot of shuffling going on before each iteration.
Yes, say your chosen batch size is 32, some batches might not have 32 samples. However, if your dataset is large, these cases are negligible. I did a test with a 300k sentences or so. 99.7% of batches were full, and the rest were almost full maybe with an occasional outlier. There’s no performance loss.