code: def check_scoring(estimator, scoring=None, allow_none=False):
      """Determine scorer from user options.
  
      A TypeError will be thrown if the estimator cannot be scored.
  
      Parameters
      ----------
      estimator : estimator object implementing 'fit'
          The object to use to fit the data.
  
      scoring : string, callable or None, optional, default: None
          A string (see model evaluation documentation) or
          a scorer callable object / function with signature
          ``scorer(estimator, X, y)``.
  
      allow_none : boolean, optional, default: False
          If no scoring is specified and the estimator has no score function, we
          can either return None or raise an exception.
  
      Returns
      -------
      scoring : callable
          A scorer callable object / function with signature
          ``scorer(estimator, X, y)``.
      """
      has_scoring = scoring is not None
      if not hasattr(estimator, "fit"):
          raise TypeError(
              "estimator should be an estimator implementing "
              "'fit' method, %r was passed" % estimator
          )
      if isinstance(scoring, six.string_types):
          return get_scorer(scoring)
      elif has_scoring:
          # Heuristic to ensure user has not passed a metric
          module = getattr(scoring, "__module__", None)
          if (
              hasattr(module, "startswith")
              and module.startswith("sklearn.metrics.")
              and not module.startswith("sklearn.metrics.scorer")
              and not module.startswith("sklearn.metrics.tests.")
          ):
              raise ValueError(
                  "scoring value %r looks like it is a metric "
                  "function rather than a scorer. A scorer should "
                  "require an estimator as its first parameter. "
                  "Please use `make_scorer` to convert a metric "
                  "to a scorer." % scoring
              )
          return get_scorer(scoring)
      elif hasattr(estimator, "score"):
          return _passthrough_scorer
      elif allow_none:
          return None
      else:
          raise TypeError(
              "If no scoring is specified, the estimator passed should "
              "have a 'score' method. The estimator %r does not."
              % estimator
          )
  
imports: from abc import ABCMeta, abstractmethod
  import warnings
  import numpy
  from .None import r2_score, median_absolute_error, mean_absolute_error, mean_squared_error, accuracy_score, f1_score, roc_auc_score, average_precision_score, precision_score, recall_score, log_loss
  from .cluster import adjusted_rand_score
  from ..utils.multiclass import type_of_target
  from ..externals import six
  from ..base import is_regressor
label_desc: Use image node_id 3 for calling a global function with example usage: check_scoring(estimator, scoring, allow_none) and returns: get_scorer, get_scorer, _passthrough_scorer, None