def add_labeled_images(
    dataset,
    samples,
    sample_parser,
    label_field=None,
    tags=None,
    expand_schema=True,
    dynamic=False,
    generator=False,
    progress=None,
):
    """Adds the given labeled images to the dataset.

    This operation will iterate over all provided samples, but the images will
    not be read (unless the sample parser requires it in order to compute image
    metadata).

    See :ref:`this guide <custom-sample-parser>` for more details about
    adding labeled images to a dataset by defining your own
    :class:`LabeledImageSampleParser`.

    Args:
        dataset: a :class:`fiftyone.core.dataset.Dataset`
        samples: an iterable of samples that can be parsed by ``sample_parser``
        sample_parser: a :class:`LabeledImageSampleParser` instance to use to
            parse the samples
        label_field (None): controls the field(s) in which imported labels are
            stored. If the parser produces a single
            :class:`fiftyone.core.labels.Label` instance per sample, this
            argument specifies the name of the field to use; the default is
            ``"ground_truth"``. If the parser 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
        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 not sample_parser.has_image_path:
        raise ValueError(
            "Sample parser must have `has_image_path == True` to add its "
            "samples to the dataset"
        )

    if not isinstance(sample_parser, LabeledImageSampleParser):
        raise ValueError(
            "`sample_parser` must be a subclass of %s; found %s"
            % (
                etau.get_class_name(LabeledImageSampleParser),
                etau.get_class_name(sample_parser),
            )
        )

    if isinstance(label_field, dict):
        label_key = lambda k: label_field.get(k, k)
    elif label_field is not None:
        label_key = lambda k: label_field + "_" + k
    else:
        label_field = "ground_truth"
        label_key = lambda k: k

    if etau.is_str(tags):
        tags = [tags]
    elif tags is not None:
        tags = list(tags)

    def parse_sample(sample):
        sample_parser.with_sample(sample)

        image_path = sample_parser.get_image_path()

        if sample_parser.has_image_metadata:
            metadata = sample_parser.get_image_metadata()
        else:
            metadata = None

        label = sample_parser.get_label()

        sample = Sample(filepath=image_path, metadata=metadata, tags=tags)

        if isinstance(label, dict):
            sample.update_fields({label_key(k): v for k, v in label.items()})
        elif label is not None:
            sample[label_field] = label

        return sample

    # Optimization: if we can deduce exactly what fields will be added during
    # import, we declare them now and set `expand_schema` to False
    try:
        can_expand_now = issubclass(sample_parser.label_cls, fol.Label)
    except:
        can_expand_now = False

    if expand_schema and can_expand_now:
        dataset._ensure_label_field(label_field, sample_parser.label_cls)
        expand_schema = False

    _samples = map(parse_sample, samples)
    return dataset.add_samples(
        _samples,
        expand_schema=expand_schema,
        dynamic=dynamic,
        generator=generator,
        progress=progress,
        num_samples=samples,
    )
Adds the given labeled images to the dataset.

    This operation will iterate over all provided samples, but the images will
    not be read (unless the sample parser requires it in order to compute image
    metadata).

    See :ref:`this guide <custom-sample-parser>` for more details about
    adding labeled images to a dataset by defining your own
    :class:`LabeledImageSampleParser`.

    Args:
        dataset: a :class:`fiftyone.core.dataset.Dataset`
        samples: an iterable of samples that can be parsed by ``sample_parser``
        sample_parser: a :class:`LabeledImageSampleParser` instance to use to
            parse the samples
        label_field (None): controls the field(s) in which imported labels are
            stored. If the parser produces a single
            :class:`fiftyone.core.labels.Label` instance per sample, this
            argument specifies the name of the field to use; the default is
            ``"ground_truth"``. If the parser 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
        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/parsers.py