I think the code for initializing the hidden states shown above does not make sense, because this is exactly what the LSTM does anyway if you only pass the inputs. In that case, the initial hidden states and cells are set to all zeroes for all sequences in the batch.
The only time one would need code like this is if one wants to do something different to initializing the hidden states to zeros for each sequence, e.g. initialize randomly, try to learn initial hidden states, use the last states from the previous sequence etc.
So having this code in a tutorial code is rather odd, in my opinion.
Or am I mistaken here?