Yes, it’s sequence length or seconds.
Assuming you meant seq_length instead of batch_size, this is how my code looks now:
    import torch
    import torch.nn as nn
    import helpers.dataset as dataset
    
    
    input_size = 128
    hidden_size = 128
    num_layers = 2
    output_size = 128
    batch_size = 1
    num_epochs = 2
    learning_rate = 0.01
    num_classes = 128
    
    # Dataset
    train_dataset = dataset.pianoroll_dataset_batch('./datasets/training/piano_roll_fs1')  # pianoroll_dataset_batch instance
    # Data loader
    train_loader = torch.utils.data.DataLoader(dataset=train_dataset, batch_size=batch_size, shuffle=False,
                                               drop_last=True)  # Drop-last
    
    
    class RNN(nn.Module):
        def __init__(self, input_size, hidden_size, num_classes=128, n_layers=num_layers):
            super(RNN, self).__init__()
            self.input_size = input_size
            self.hidden_size = hidden_size
            self.num_classes = num_classes
            self.n_layers = n_layers
            self.rnn = nn.RNN(input_size=input_size, hidden_size=hidden_size, num_layers=n_layers, batch_first=False)
    
        def forward(self, input_sequence, hidden):
    
            output, hidden = self.rnn(input_sequence, hidden)
    
            # Output reshaped to shape=(seq_length, num_classes)
            return output.reshape(seq_len, num_classes), hidden
    
        def init_hidden(self):
            pass
    
    
    model = RNN(input_size, hidden_size, num_layers)
    # Loss and optimizer
    criterion = nn.BCEWithLogitsLoss()
    optimizer = torch.optim.Adam(model.parameters(), lr=learning_rate)
    
    # Init hidden state with shape=(num_layers*num_directions, batch_size, hidden_size)
    hidden = torch.Tensor(num_layers * 1, batch_size, hidden_size)
    for i, (features, _, targets) in enumerate(train_loader):
        # Seconds in each input stream
        seq_len = features.size(1)
    
        # The input dimensions are reshaped to (seq_len, batch, input_size)
        features = features.reshape(seq_len, -1, input_size)
        targets = targets.reshape(seq_len, num_classes)
    
        # Forward pass
        outputs, hidden = model(features, hidden)  # Runs forward()
        loss = criterion(outputs, targets)
    
        # Backward and optimize
        optimizer.zero_grad()
        loss.backward(retain_graph=True)
        optimizer.step()
    
        print('i: {}, Loss: {:.4f}'.format(i + 1, loss.item()))
    
        if i % 10 == 0:
            print(outputs)

I needed to add retain_graph=True in loss.backward().