code: def _tosequence(X):
      """Turn X into a sequence or ndarray, avoiding a copy if possible."""
      if isinstance(X, Mapping):  # single sample
          return [X]
      else:
          return tosequence(X)
  
imports: from array import array
  from collections import Mapping
  from operator import itemgetter
  import numpy
  import scipy.sparse
  from ..base import BaseEstimator, TransformerMixin
  from ..externals import six
  from ..externals.six.moves import xrange
  from ..utils import check_array, tosequence
  from ..utils.fixes import frombuffer_empty
label_desc: Use image node_id 1 for calling a global function with example usage: _tosequence(X) and returns: list, tosequence