code: def test_creatsubdatasets(topds_path=None, n=2):
      from datalad.api import create
      from datalad.distribution.dataset import Dataset
  
      ds = Dataset(topds_path).create()
      paths = [op.join(topds_path, "subds%d" % i) for i in range(n)]
      paths.extend(
          op.join(topds_path, "subds%d" % i, "subsub%d" % k)
          for i in range(n)
          for k in range(2)
      )
      # To allow for parallel execution without hitting the problem of
      # a lock in the super dataset, we create all subdatasets, and then
      # save them all within their superdataset
      create_ = partial(
          create,  # cfg_proc="yoda",
          result_xfm=None,
          return_type="generator",
      )
      # if we flip the paths so to go from the end, create without --force should fail
      # and we should get the exception (the first one encountered!)
      # Note: reraise_immediately is of "concern" only for producer. since we typically
      # rely on outside code to do the killing!
      assert_raises(
          IncompleteResultsError,
          list,
          ProducerConsumer(paths[::-1], create_, jobs=5),
      )
      # we are in a dirty state, let's just remove all those for a clean run
      rmtree(topds_path)
  
      # and this one followed by save should be good IFF we provide our dependency checker
      ds = Dataset(topds_path).create()
      list(
          ProducerConsumer(
              paths,
              create_,
              safe_to_consume=no_parentds_in_futures,
              jobs=5,
          )
      )
      ds.save(paths)
      assert_repo_status(ds.repo)
  
file_path: datalad/datalad/support/tests/test_parallel.py
imports: import logging
  from functools import partial
  from time import sleep, time
  import pytest
  from datalad import lgr
  from datalad.support import path
  from datalad.support.exceptions import IncompleteResultsError
  from datalad.support.parallel import ProducerConsumer, ProducerConsumerProgressLog, no_parentds_in_futures
  from datalad.tests.utils_pytest import assert_equal, assert_greater, assert_greater_equal, assert_raises, assert_repo_status, known_failure_osx, on_osx, on_windows, rmtree, skip_if, slow, with_tempfile
label_desc: Use image node_id 5 for calling a global function with example usage: test_creatsubdatasets(topds_path, n) without return types