def collator(batch_list):
    """
    Collate a bunch of multichannel signals based
    on the size of the longest sample. The samples are cut at the center
    """
    max_len = max([s[0].shape[-1] for s in batch_list])

    n_batch = len(batch_list)
    n_channels_data = batch_list[0][0].shape[0]
    n_channels_target = batch_list[0][1].shape[0]

    data = batch_list[0][0].new_zeros((n_batch, n_channels_data, max_len))
    target = batch_list[0][1].new_zeros((n_batch, n_channels_target, max_len))

    offsets = [(max_len - s[0].shape[-1]) // 2 for s in batch_list]

    for b, ((d, t), o) in enumerate(zip(batch_list, offsets)):
        data[b, :, o : o + d.shape[-1]] = d
        target[b, :, o : o + t.shape[-1]] = t

    # handle when extra things are provided (e.g. transcripts)
    rest_of_items = []
    for i in range(len(batch_list[0]) - 2):
        rest_of_items.append([b[i + 2] for b in batch_list])

    return data, target, *rest_of_items