code: def _convert_to_subestimator(candidate):
      """Converts a candidate to an AutoEnsembleSubestimator."""
  
      if callable(candidate):
          return candidate
      if isinstance(candidate, AutoEnsembleSubestimator):
          return lambda config: candidate
  
      from tensorflow_estimator.python.estimator import (
          estimator as estimator_lib,
      )  # pylint: disable=g-direct-tensorflow-import,g-import-not-at-top
  
      if isinstance(
          candidate,
          (estimator_lib.Estimator, estimator_lib.EstimatorV2),
      ):
          return lambda config: AutoEnsembleSubestimator(candidate)
      raise ValueError(
          "subestimator in candidate_pool must have type tf.estimator.Estimator or "
          "adanet.AutoEnsembleSubestimator but got {}".format(
              candidate.__class__
          )
      )
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import collections
  import inspect
  from adanet import subnetwork
  from adanet import tf_compat
  import tensorflow.compat.v2
label_desc: Use image node_id 2 for calling a global function with example usage: _convert_to_subestimator(candidate) and returns: candidate, function, function