code: def get_X(doc, vec=None, vectorized=False, to_dense=False):
      if vec is None or vectorized:
          if isinstance(doc, np.ndarray):
              X = np.array([doc])
          elif pandas_available and isinstance(doc, pd.Series):
              # Convert to a DataFrame with a single row
              X = doc.to_frame().transpose()
          else:
              X = doc
      else:
          X = vec.transform([doc])
      if to_dense and sp.issparse(X):
          X = X.toarray()
      return X
  
imports: from __future__ import absolute_import
  from distutils.version import LooseVersion
  from typing import Any, Optional, List, Tuple
  import numpy
  import scipy.sparse
  from sklearn.multiclass import OneVsRestClassifier
  from eli5.sklearn.unhashing import invert_hashing_and_fit, handle_hashing_vec
  from eli5._feature_names import FeatureNames
label_desc: Use image node_id 12 for calling a global function with example usage: get_X(doc, vec, vectorized, to_dense) and returns: X