RNN will produce number of hidden states equal to the size of the longest input. Let’s assume we train RNN on sentences in some large corpus of text. If longest sentence in training data contains N words, then RNN will produce N hidden states.
Sentences fed into RNN in batches. But different sentences may have different lengths. Consider the following batch of 2 sentences:
Sentence 1: "I love cats"
Sentence 2: "I hope this answer helps"
(for brevity, I omit tensor-like representation of these sentences, with word embeddings etc).
This batch will produce 5 hidden states because 5 is the size of the longest sentence in the batch:
len(["i", "hope", "this", "answer", "helps"]) == 5
Now, RNN has to feed information into its first hidden state. It takes first elements from each sequence in batch and feeds them into the first hidden state: ["i", "i"].
Second hidden state will receive ["love", "hope"].
Third hidden state will receive ["cats", "this"].
But forth hidden state will receive just ["answer"] because first sequence "i love cats" ended at step #3.
batch_sizes is a list of sizes of inputs each hidden state receives. For this example, batch_sizes would be [2, 2, 2, 1, 1]. Each element in this list tells how many input elements go into corresponding hidden state of RNN.
I guess confusion stems from the fact that term batch is overloaded here. There is batch of sequences which goes into RNN, and then there is batch of inputs which goes into each step of the RNN.