What I implemented was
def batch_pad(batch):
    batch = [item.t() for item in batch]
    batch = torch.nn.utils.rnn.pad_sequence(batch, batch_first=True, padding_value=0.)
    return batch.permute(0, 2, 1)

def collate_fn(batch):
    tensors = []
    targets = []
    
    for waveform, target in batch:
        tensors += [waveform]
        targets += [target]

    tensors = batch_pad(tensors)
    targets = batch_pad(targets)

    return tensors, targets

Or is there some way I can use batch_pad on both tensors and targets together?