def import_samples(
    dataset,
    dataset_importer,
    label_field=None,
    tags=None,
    expand_schema=True,
    dynamic=False,
    add_info=True,
    generator=False,
    progress=None,
):
    """Adds the samples from the given :class:`DatasetImporter` to the dataset.

    See :ref:`this guide <custom-dataset-importer>` for more details about
    importing datasets in custom formats by defining your own
    :class:`DatasetImporter`.

    Args:
        dataset: a :class:`fiftyone.core.dataset.Dataset`
        dataset_importer: a :class:`DatasetImporter`
        label_field (None): controls the field(s) in which imported labels are
            stored. Only applicable if ``dataset_importer`` is a
            :class:`LabeledImageDatasetImporter` or
            :class:`LabeledVideoDatasetImporter`. If the importer produces a
            single :class:`fiftyone.core.labels.Label` instance per
            sample/frame, this argument specifies the name of the field to use;
            the default is ``"ground_truth"``. If the importer produces a
            dictionary of labels per sample, this argument can be either a
            string prefix to prepend to each label key or a dict mapping label
            keys to field names; the default in this case is to directly use
            the keys of the imported label dictionaries as field names
        tags (None): an optional tag or iterable of tags to attach to each
            sample
        expand_schema (True): whether to dynamically add new sample fields
            encountered to the dataset schema. If False, an error is raised
            if a sample's schema is not a subset of the dataset schema
        dynamic (False): whether to declare dynamic attributes of embedded
            document fields that are encountered
        add_info (True): whether to add dataset info from the importer (if
            any) to the dataset
        generator (False): whether to yield ID batches as a generator as
            samples are added to the dataset
        progress (None): whether to render a progress bar (True/False), use the
            default value ``fiftyone.config.show_progress_bars`` (None), or a
            progress callback function to invoke instead

    Returns:
        a list of IDs of the samples that were added to the dataset
    """
    if etau.is_str(tags):
        tags = [tags]
    elif tags is not None:
        tags = list(tags)

    dataset_importer = _handle_legacy_formats(dataset_importer)

    # Batch imports
    if isinstance(dataset_importer, BatchDatasetImporter):
        # @todo support `expand_schema=False` here?
        if not expand_schema:
            logger.warning(
                "`expand_schema=False` is not supported for %s instances",
                BatchDatasetImporter,
            )

        if not add_info:
            logger.warning(
                "`add_info=False` is not supported for %s instances",
                BatchDatasetImporter,
            )

        with dataset_importer:
            return dataset_importer.import_samples(
                dataset, tags=tags, progress=progress
            )

    #
    # Non-batch imports
    #

    def _do_import_samples():
        with dataset_importer:
            parse_sample, _expand_schema, _dynamic = _build_parse_sample_fcn(
                dataset,
                dataset_importer,
                label_field,
                tags,
                expand_schema,
                dynamic,
            )

            if isinstance(dataset_importer, GroupDatasetImporter):
                samples = _generate_group_samples(
                    dataset_importer, parse_sample
                )
            else:
                samples = map(parse_sample, iter(dataset_importer))

            for ids in dataset.add_samples(
                samples,
                expand_schema=_expand_schema,
                dynamic=_dynamic,
                generator=True,
                progress=progress,
                num_samples=dataset_importer,
            ):
                yield ids

            if add_info and dataset_importer.has_dataset_info:
                info = dataset_importer.get_dataset_info()
                if info:
                    parse_dataset_info(dataset, info)

            if isinstance(dataset_importer, LegacyFiftyOneDatasetImporter):
                dataset_importer.import_extras(dataset)

    if generator:
        return _do_import_samples()

    sample_ids = []
    for ids in _do_import_samples():
        sample_ids.extend(ids)

    return sample_ids
Adds the samples from the given :class:`DatasetImporter` to the dataset.

    See :ref:`this guide <custom-dataset-importer>` for more details about
    importing datasets in custom formats by defining your own
    :class:`DatasetImporter`.

    Args:
        dataset: a :class:`fiftyone.core.dataset.Dataset`
        dataset_importer: a :class:`DatasetImporter`
        label_field (None): controls the field(s) in which imported labels are
            stored. Only applicable if ``dataset_importer`` is a
            :class:`LabeledImageDatasetImporter` or
            :class:`LabeledVideoDatasetImporter`. If the importer produces a
            single :class:`fiftyone.core.labels.Label` instance per
            sample/frame, this argument specifies the name of the field to use;
            the default is ``"ground_truth"``. If the importer produces a
            dictionary of labels per sample, this argument can be either a
            string prefix to prepend to each label key or a dict mapping label
            keys to field names; the default in this case is to directly use
            the keys of the imported label dictionaries as field names
        tags (None): an optional tag or iterable of tags to attach to each
            sample
        expand_schema (True): whether to dynamically add new sample fields
            encountered to the dataset schema. If False, an error is raised
            if a sample's schema is not a subset of the dataset schema
        dynamic (False): whether to declare dynamic attributes of embedded
            document fields that are encountered
        add_info (True): whether to add dataset info from the importer (if
            any) to the dataset
        generator (False): whether to yield ID batches as a generator as
            samples are added to the dataset
        progress (None): whether to render a progress bar (True/False), use the
            default value ``fiftyone.config.show_progress_bars`` (None), or a
            progress callback function to invoke instead

    Returns:
        a list of IDs of the samples that were added to the dataset
    
fiftyone/utils/data/importers.py