<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def import_from_dicts(data, samples=None, *args, **kwargs):
 """Import data from a iterable of dicts The algorithm will use the `samples` first `dict`s to determine the field names (if `samples` is `None` all `dict`s will be used). """


    data = iter(data)

    cached_rows, headers = [], []
    for index, row in enumerate(data, start=1):
        cached_rows.append(row)

        for key in row.keys():
            if key not in headers:
                headers.append(key)

        if samples and index == samples:
            break

    data_rows = (
        [row.get(header, None) for header in headers]
        for row in chain(cached_rows, data)
    )

    kwargs["samples"] = samples
    meta = {"imported_from": "dicts"}
    return create_table(chain([headers], data_rows), meta=meta, *args, **kwargs)