code: def test_all_estimators_by_scitype(estimator_scitype, return_names):
      """Check that all_estimators return argument has correct type."""
      estimators = all_estimators(
          estimator_types=estimator_scitype,
          return_names=return_names,
      )
  
      estimator_classes = _get_type_tuple(estimator_scitype)
  
      assert isinstance(estimators, list)
      # there should be at least one estimator returned
      assert len(estimators) > 0
  
      # checks return type specification (see docstring)
      if return_names:
          for estimator in estimators:
              assert (
                  isinstance(estimator, tuple) and len(estimator) == 2
              )
              assert isinstance(estimator[0], str)
              assert issubclass(estimator[1], estimator_classes)
              assert estimator[0] == estimator[1].__name__
      else:
          for estimator in estimators:
              assert issubclass(estimator, estimator_classes)
  
file_path: sktime/sktime/registry/tests/test_lookup.py
imports: import pytest
  from sktime.base import BaseObject
  from sktime.registry import all_estimators, all_tags, scitype
  from sktime.registry._base_classes import BASE_CLASS_LOOKUP, BASE_CLASS_SCITYPE_LIST, TRANSFORMER_MIXIN_SCITYPE_LIST
  from sktime.registry._lookup import _check_estimator_types
label_desc: Use image node_id 3 for calling a global function with example usage: test_all_estimators_by_scitype(estimator_scitype, return_names) without return types