def extract_batch(data, key=None, batch_size=0, batch_id=0):
    """Extract a batch from a list of data

    Parameters
    ----------
    data: list
        List of data from which to extract the batch
    key: callable
        A function transforming an element of data into a sortable key.
    batch_size: int
        Size of a batch
    batch_id: int
        Batch identifier
    """
    if batch_size == 0:
        return data
    if key is None:
        key = lambda i: i
    start = batch_id * batch_size
    end = start + batch_size
    return list(sorted(data, key=key))[start:end]