code: def check_instances(
      estimators=None, preprocessing=None, namespace=None
  ):
      """Ensure estimators and preprocessing pipelines are correctly formatted
  
      Utility for formating estimator iterable and preprocessing iterable into
      formats accepted by a the :class:`Layer`.
  
      Parameters
      ----------
      estimators : iterable, optional
          estimator instances.
  
      preprocessing : iterable, optional
          preprocessing pipeline instances.
      """
      if not namespace:
          namespace = list()
      assert_correct_format(estimators, preprocessing)
      preprocessing = _check_instances(preprocessing)
      if estimators is not None and not isinstance(
          estimators, (dict, list)
      ):
          estimators = [estimators]
  
      if preprocessing:
          if isinstance(preprocessing, list):
              # Preprocessing but there's not case: force create
              preprocessing = {"pr": preprocessing}
              estimators = {"pr": estimators} if estimators else dict()
          preprocessing = [
              (n, l) for n, l in sorted(preprocessing.items())
          ]
          namespace += [n for n, l in preprocessing]
  
      if estimators:
          estimators = _check_instances(estimators, namespace=namespace)
          estimators = _flatten(estimators)
  
      out_prep, out_est, cases = list(), list(), list()
      if preprocessing:
          for preprocess_name, tr in sorted(preprocessing):
              if tr:
                  out_prep.append(
                      (preprocess_name, [(n, clone(t)) for n, t in tr])
                  )
                  cases.append(preprocess_name)
      if estimators:
          for preprocess_name, learner_name, est in estimators:
              pr_name = (
                  preprocess_name if preprocess_name in cases else None
              )
              out_est.append((pr_name, learner_name, clone(est)))
  
      return out_prep, out_est
  
file_path: mlens/mlens/utils/formatting.py
imports: from __future__ import division, print_function
  from collections import Counter
  from .checks import assert_valid_estimator, assert_correct_format
  from .exceptions import LayerSpecificationError
  from ..externals.sklearn.base import clone
label_desc: Use image node_id 5 for calling a global function with example usage: check_instances(estimators, preprocessing, namespace) and returns: out_prep,  out_est