mfluegge:

If I pick batch size = 4, that means I have created 4 subsequences and 2 batches


That would be right if you were using the cell implementations, if you want to use the LSTM implementation then it would be better to say that you have created “one batch of 4 subsequences of 2 timesteps each”, batch_size=4, seq_len=2.
Batches and subsequences get mixed up very easily. I don’t think I can reply to @Diego’s answer without confusing thing even more. So first some theory, then an example, then some code.
LSTM expects input of shape (seq_len, batch, input_size).

seq_len = the length of each subsequence.
batch = how many subsequences it will process in parallel.
input_size = how many values are there in each sequence at each timestep.

Now for an example

Suppose I have one big sequence of steps 0,1,2,…99 with f features at each timestep. The big sequence is a tensor of size (100, f).

If I want to train on subsequences of length 5 then I cut my big sequence into subsequences of length 5. In this case there are 20 subsequences. Then if I want to train with a batch size of 10, I take 10 of these subsequences.
In code… given a tensor sequence of shape (timesteps, features)
subsequences = sequence.split(desired_subsequence_length)
# each subsequence is of size (desired_subsequence_length, features)

# if the last subsequence is not of the same length, remove it.
if subsequences[-1].size(0) != desired_subsequence_length:
    subsequences = subsequences[:-1]
    # alternatively you could pad it, but I am not sure of the best method

for b in range(len(subsequences) / desired_batch_size):
    training_batch = torch.cat(subsequences[b:b+desired_batch_size], dim=1)
    # training_batch is of size (desired_subsequence_length, desired_batch_size, features)
    # the last batch might contain fewer subsequences, but that doesn't matter here
    model.reset_hidden()
    output = model(training_batch)
    ...

With the above code, you must reset the hidden state before each batch because the batches don’t follow on from one another properly. If you want an example with batches that follow on properly, I can give you one, but I’ll wait until these concepts are in place.