You can search the forum for padding packed sequences.  But the gist of it is that the collate function takes a list of outputs from the Dataset, then you unpack that, get the lengths, then pad based on the maximum length in the batch.
def collate_spectrograms_fn(batch):
  # assuming sig has size (c, l, n_ftt)
  sigs, targets = zip(*batch)
  lengths = torch.tensor([sig.size(1) for sig in sigs], dtype=torch.long)
  max_len = lengths.max()
  sigs = [pad(sig, (0, 0, 0, ma_len - sig.size(1)) for sig in sigs]
  return torch.stack(sigs), torch.cat(targets), lengths

I haven’t tested that but that’s the general idea.