def read_from(reader, nb_sample=None):
    from .utils import stack_dict

    data = dict()
    nb_seen = 0
    is_dict = True

    for data_batch in reader:
        if not isinstance(data_batch, dict):
            data_batch = _to_dict(data_batch)
            is_dict = False
        for key, value in six.iteritems(data_batch):
            values = data.setdefault(key, [])
            values.append(value)
        nb_seen += len(list(data_batch.values())[0])
        if nb_sample and nb_seen >= nb_sample:
            break

    data = stack_dict(data)
    if nb_sample:
        for key, value in six.iteritems(data):
            data[key] = value[:nb_sample]

    if not is_dict:
        data = [data[i] for i in range(len(data))]

    return data