code: def _find_doctests_in_obj(obj, finder=None, criteria=None):
      """Find all doctests in an object.
  
      Parameters
      ----------
      obj : module or class
          The object to search for docstring examples.
      finder : doctest.DocTestFinder, optional
          The DocTestFinder object to use. If not provided, a DocTestFinder is
          constructed.
      criteria : callable, optional
          Callable indicating whether to recurse over members of the provided
          object. If not provided, names not defined in the object's ``__all__``
          property are ignored.
  
      Yields
      ------
      doctest.DocTest
          The next doctest found in the object.
      """
      if finder is None:
          finder = doctest.DocTestFinder()
      if criteria is None:
          criteria = _name_in_all
      for docstring in finder.find(obj):
          if docstring.examples:
              yield docstring
      for name, member in inspect.getmembers(obj):
          # Only recurse over members matching the criteria
          if not criteria(obj, name):
              continue
          # Recurse over the public API of modules (objects defined in the
          # module's __all__)
          if inspect.ismodule(member):
              yield from _find_doctests_in_obj(
                  member, finder, criteria=_name_in_all
              )
          # Recurse over the public API of classes (attributes not prefixed with
          # an underscore)
          if inspect.isclass(member):
              yield from _find_doctests_in_obj(
                  member, finder, criteria=_is_public_name
              )
          if inspect.isfunction(member):
              yield from _find_doctests_in_obj(member, finder)
  
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 3 for calling a global function with example usage: _find_doctests_in_obj(obj, finder, criteria) without return types