code: def _count_expanded_fields(collection: foc.SampleCollection) -> int:
      schema = collection._root_dataset.get_field_schema()
      count = 0
      for field in schema.values():
          while isinstance(field, fof.ListField):
              field = field.field
  
          if (
              isinstance(field, fof.EmbeddedDocumentField)
              and field.document_type is not None
              and not issubclass(field.document_type, fol.Label)
          ):
              count += len(field.fields)
          else:
              count += 1
  
      return count
  
imports: from datetime import date, datetime
  import typing
  import strawberry
  import fiftyone.core.aggregations
  import fiftyone.core.collections
  import fiftyone.core.fields
  import fiftyone.core.labels
  import fiftyone.core.media
  from fiftyone.core.utils import datetime_to_timestamp
  import fiftyone.core.view
  from fiftyone.server.constants import LIST_LIMIT
  from fiftyone.server.filters import GroupElementFilter, SampleFilter
  from fiftyone.server.inputs import SelectedLabel
  from fiftyone.server.scalars import BSON, BSONArray
  from fiftyone.server.utils import from_dict, meets_type
  import fiftyone.server.view
label_desc: Use image node_id 2 for calling a global function with example usage: _count_expanded_fields(collection) and returns: count