code: def check_instances(instances):
      """Helper to ensure all instances are named.
  
      Check if ``instances`` is formatted as expected, and if not convert
      formatting or throw traceback error if impossible to anticipate formatting.
  
      Parameters
      ----------
      instances : iterable
          instance iterable to test.
  
      Returns
      -------
      formatted : list or dict
          formatted ``instances`` object. Will be formatted as a dict if
          preprocessing cases are detected, otherwise as a list. The dict will
          contain lists identical to those in the single preprocessing case.
          Each list is of the form ``[('name', instance)]`` and no names overlap.
  
      Raises
      ------
      ValueError:
          Raises error if formatting fails, which is most likely due to wrong
          ordering of tuple entries, or wrong argument in the wrong position.
      """
      is_iterable = isinstance(instances, (list, tuple, dict))
      if not is_iterable:
          instances = [instances]
      if not instances or None in instances:
          return None
  
      if _assert_format(instances):
          out = instances
      elif isinstance(instances, list):
          out = _format_instances(instances)
      else:
          # We need to check the instance list of each case
          out = {}
          for case, case_list in instances.items():
              out["-".join(case.lower().split())] = _format_instances(
                  case_list
              )
      return out
  
file_path: mlens/mlens/model_selection/_base_functions.py
imports: from __future__ import division
  from collections import Counter
  from ..parallel import EvalLearner, EvalTransformer, Pipeline
  from ..utils.formatting import _assert_format
  from ..utils.checks import assert_valid_estimator
  from ..externals.sklearn.base import clone
label_desc: Use image node_id 6 for calling a global function with example usage: check_instances(instances) and returns: out, None