code: def _parse_embedded_doc_fields(doc, dynamic):
      fields = []
  
      is_label = isinstance(doc, fol.Label)
      for name, field in doc._fields.items():
          # @todo remove once attributes are deprecated
          if is_label and name == "attributes":
              continue
  
          value = getattr(doc, name, None)
          if value is not None and not name.startswith("_"):
              kwargs = _get_field_kwargs(value, field, dynamic)
              kwargs["name"] = name
              fields.append(kwargs)
  
      if not dynamic:
          return fields
  
      for name in doc._dynamic_fields.keys():
          value = getattr(doc, name, None)
          if value is not None and not name.startswith("_"):
              db_field = (
                  name
                  if not isinstance(value, ObjectId)
                  else "_" + name
              )
  
              kwargs = get_implied_field_kwargs(value, dynamic=dynamic)
              kwargs["name"] = name
              kwargs["db_field"] = db_field
              fields.append(kwargs)
  
      return fields
  
imports: from datetime import date, datetime
  import inspect
  import json
  import numbers
  import six
  import sys
  from bson import Binary, json_util, ObjectId, SON
  import numpy
  import pytz
  import fiftyone
  import fiftyone.core.fields
  import fiftyone.core.media
  import fiftyone.core.utils
label_desc: Use image node_id 9 for calling a global function with example usage: _parse_embedded_doc_fields(doc, dynamic) and returns: fields, fields