code: def _run_custom_imports(
      sample_collection,
      export_dir,
      dataset_type,
      num_unlabeled=None,
      max_samples=None,
      **kwargs,
  ):
      # Generate a temporary export
      sample_collection.export(
          export_dir=export_dir, dataset_type=dataset_type, **kwargs
      )
  
      # Test unlabeled sample handling when importing
      if num_unlabeled is not None:
          # Some formats require `include_all_data` in order to load unlabeled
          # samples. If the format doesn't support this flag, it will be ignored
          _dataset = fo.Dataset.from_dir(
              dataset_dir=export_dir,
              dataset_type=dataset_type,
              include_all_data=True,
          )
  
          label_field = _dataset._get_label_fields()[0]
  
          num_samples = len(_dataset)
          num_labeled = len(_dataset.exists(label_field))
  
          assert num_samples == num_labeled + num_unlabeled
  
      # Test `shuffle` and `max_samples` when importing
      if max_samples is not None:
          _dataset = fo.Dataset.from_dir(
              dataset_dir=export_dir,
              dataset_type=dataset_type,
              max_samples=max_samples,
              shuffle=True,
          )
          assert len(_dataset) == max_samples
          for s in _dataset:
              print(s.filepath)
  
imports: import random
  import os
  import numpy
  import pytest
  import eta.core.utils
  import fiftyone
  import fiftyone.utils.image
  import fiftyone.brain
  import fiftyone.zoo
  from fiftyone import ViewField
label_desc: Use image node_id 9 for calling a global function with example usage: _run_custom_imports(sample_collection, export_dir, dataset_type, num_unlabeled, max_samples) without return types