code: def _check_X(X):
      """Use check_array only when necessary, e.g. on lists and other non-array-likes."""
      if (
          hasattr(X, "__array__")
          or hasattr(X, "__dataframe__")
          or sparse.issparse(X)
      ):
          return X
      return check_array(X, force_all_finite="allow-nan", dtype=object)
  
imports: import warnings
  from collections import Counter
  from itertools import chain
  from numbers import Integral, Real
  import numpy
  from scipy import sparse
  from ..base import TransformerMixin, _fit_context, clone
  from ..pipeline import _fit_transform_one, _name_estimators, _transform_one
  from ..preprocessing import FunctionTransformer
  from ..utils import Bunch, _get_column_indices, _safe_indexing
  from ..utils._estimator_html_repr import _VisualBlock
  from ..utils._metadata_requests import METHODS
  from ..utils._param_validation import HasMethods, Hidden, Interval, StrOptions
  from ..utils._set_output import _get_container_adapter, _get_output_config, _safe_set_output
  from ..utils.metadata_routing import MetadataRouter, MethodMapping, _raise_for_params, _routing_enabled, process_routing
  from ..utils.metaestimators import _BaseComposition
  from ..utils.parallel import Parallel, delayed
  from ..utils.validation import _check_feature_names_in, _get_feature_names, _is_pandas_df, _num_samples, check_array, check_is_fitted
label_desc: Use image node_id 1 for calling a global function with example usage: _check_X(X) and returns: check_array, X