def flatten_schema(
    schema,
    ftype=None,
    embedded_doc_type=None,
    subfield=None,
    unwind=True,
    read_only=None,
    info_keys=None,
    created_after=None,
    include_private=False,
):
    """Returns a flat version of the given schema where all embedded document
    fields are included as top-level keys.

    Args:
        schema: a dict mapping field names to :class:`Field` instances
        ftype (None): an optional field type or iterable of types to which to
            restrict the returned schema. Must be subclass(es) of
            :class:`Field`
        embedded_doc_type (None): an optional embedded document type or
            iterable of types to which to restrict the returned schema. Must be
            subclass(es) of :class:`fiftyone.core.odm.BaseEmbeddedDocument`
        subfield (None): an optional subfield type or iterable of subfield
            types to which to restrict the returned schema. Must be
            subclass(es) of :class:`Field`
        unwind (True): whether to traverse into list fields
        read_only (None): whether to restrict to (True) or exclude (False)
            read-only fields. By default, all fields are included
        info_keys (None): an optional key or list of keys that must be in the
            field's ``info`` dict
        created_after (None): an optional ``datetime`` specifying a minimum
            creation date
        include_private (False): whether to include fields that start with
            ``_`` in the returned schema

    Returns:
        a dict mapping flattened paths to :class:`Field` instances
    """
    validate_constraints(
        ftype=ftype,
        embedded_doc_type=embedded_doc_type,
        subfield=subfield,
        read_only=read_only,
        info_keys=info_keys,
        created_after=created_after,
    )

    _schema = {}
    for name, field in schema.items():
        _flatten(
            _schema,
            "",
            name,
            field,
            ftype,
            embedded_doc_type,
            subfield,
            unwind,
            read_only,
            info_keys,
            created_after,
            include_private,
        )

    return _schema
Returns a flat version of the given schema where all embedded document
    fields are included as top-level keys.

    Args:
        schema: a dict mapping field names to :class:`Field` instances
        ftype (None): an optional field type or iterable of types to which to
            restrict the returned schema. Must be subclass(es) of
            :class:`Field`
        embedded_doc_type (None): an optional embedded document type or
            iterable of types to which to restrict the returned schema. Must be
            subclass(es) of :class:`fiftyone.core.odm.BaseEmbeddedDocument`
        subfield (None): an optional subfield type or iterable of subfield
            types to which to restrict the returned schema. Must be
            subclass(es) of :class:`Field`
        unwind (True): whether to traverse into list fields
        read_only (None): whether to restrict to (True) or exclude (False)
            read-only fields. By default, all fields are included
        info_keys (None): an optional key or list of keys that must be in the
            field's ``info`` dict
        created_after (None): an optional ``datetime`` specifying a minimum
            creation date
        include_private (False): whether to include fields that start with
            ``_`` in the returned schema

    Returns:
        a dict mapping flattened paths to :class:`Field` instances
    
fiftyone/core/fields.py