code: def test_docstring(docstring):
      # We ignore differences in whitespace in the doctest output, and enable
      # the use of an ellipsis "..." to match any string in the doctest
      # output. An ellipsis is useful for, e.g., memory addresses or
      # imprecise floating point values.
      optionflags = doctest.ELLIPSIS | doctest.NORMALIZE_WHITESPACE
      runner = doctest.DocTestRunner(optionflags=optionflags)
  
      # These global names are pre-defined and can be used in doctests
      # without first importing them.
      globals = dict(cudf=cudf, np=np, cuml=cuml, dask_cudf=dask_cudf)
      docstring.globs = globals
  
      # Capture stdout and include failing outputs in the traceback.
      doctest_stdout = io.StringIO()
      with contextlib.redirect_stdout(doctest_stdout):
          runner.run(docstring)
          results = runner.summarize()
      assert not results.failed, (
          f"{results.failed} of {results.attempted} doctests failed for "
          f"{docstring.name}:\n{doctest_stdout.getvalue()}"
      )
  
file_path: cuml/python/cuml/tests/dask/test_dask_doctest.py
imports: import pytest
  from cuml.internals.safe_imports import cpu_only_import
  import contextlib
  import doctest
  import inspect
  import io
  import cuml
  import cuml.dask
  from cuml.internals.safe_imports import gpu_only_import
label_desc: Use image node_id 4 for calling a global function with example usage: test_docstring(docstring) without return types