# Tensorflow's .shuffle(BUFFER_SIZE)

I came across the following function in Tensorflow's tutorial on Machine Translation:

BUFFER_SIZE = 32000
BATCH_SIZE = 64
data_size = 30000
train_dataset = train_dataset.shuffle(BUFFER_SIZE).batch(BATCH_SIZE, drop_remainder=True)


I went through several blogs to understand .shuffle(BUFFER_SIZE), but what puzzles me is the fact that a BUFFER_SIZE > DATA_SIZE results in a perfectly uniform shuffling. Neither do I understand what they mean by 'uniform shuffling', nor do I understand how a BUFFER_SIZE> DATA_SIZE is even possible.

From what I understand, tensorflow keeps a BUFFER_SIZE of elements, selects a random element and adds the next input element into the buffer. This makes sense if the BUFFER_SIZE is <= DATA_SIZE. But, what happens to the buffer in case we have more number of elements than the size of the dataset? Do we not have some NULL elements? How does it result in uniform shuffling?

Could anyone please explain to me with an example of how BUFFER_SIZE > DATA_SIZE results in a uniform shuffling? And, what exactly do we mean by uniform shuffling?

Shuffling begins by making a buffer of size BUFFER_SIZE (which starts empty but has enough room to store that many elements). The buffer is then filled until it has no more capacity with elements from the dataset, then an element is chosen uniformly at random. This means that each example in the buffer is equally likely to be chosen, with probability 1/BUFFER_SIZE. Then, a new example is loaded to fill the slot in the buffer that was emptied. This continues until there is nothing left to load.