code: def _sanitize_value(x):
      
      if isinstance(x, _six.string_types + _six.integer_types + (float,)):
          return x
      elif _HAS_SKLEARN and _sp.issparse(x):
          return x.todense()
      elif isinstance(x, _np.ndarray):
          return x
      elif isinstance(x, tuple):
          return (_sanitize_value(v) for v in x)
      elif isinstance(x, list):
          return [_sanitize_value(v) for v in x]
      elif isinstance(x, dict):
          return dict( (_sanitize_value(k), _sanitize_value(v)) for k, v in x.items())
      else:
          assert False, str(x)
docs: Performs cleaning steps on the data so various type comparisons can
      be performed correctly.