code: def _safe_indexing(X, indices, *, axis=0):
      """Return rows, items or columns of X using indices.
  
      .. warning::
  
          This utility is documented, but **private**. This means that
          backward compatibility might be broken without any deprecation
          cycle.
  
      Parameters
      ----------
      X : array-like, sparse-matrix, list, pandas.DataFrame, pandas.Series
          Data from which to sample rows, items or columns. `list` are only
          supported when `axis=0`.
      indices : bool, int, str, slice, array-like
          - If `axis=0`, boolean and integer array-like, integer slice,
            and scalar integer are supported.
          - If `axis=1`:
              - to select a single column, `indices` can be of `int` type for
                all `X` types and `str` only for dataframe. The selected subset
                will be 1D, unless `X` is a sparse matrix in which case it will
                be 2D.
              - to select multiples columns, `indices` can be one of the
                following: `list`, `array`, `slice`. The type used in
                these containers can be one of the following: `int`, 'bool' and
                `str`. However, `str` is only supported when `X` is a dataframe.
                The selected subset will be 2D.
      axis : int, default=0
          The axis along which `X` will be subsampled. `axis=0` will select
          rows while `axis=1` will select columns.
  
      Returns
      -------
      subset
          Subset of X on axis 0 or 1.
  
      Notes
      -----
      CSR, CSC, and LIL sparse matrices are supported. COO sparse matrices are
      not supported.
      """
      if indices is None:
          return X
  
      if axis not in (0, 1):
          raise ValueError(
              "'axis' should be either 0 (to index rows) or 1 (to index "
              " column). Got {} instead.".format(axis)
          )
  
      indices_dtype = _determine_key_type(indices)
  
      if axis == 0 and indices_dtype == "str":
          raise ValueError(
              "String indexing is not supported with 'axis=0'"
          )
  
      if axis == 1 and X.ndim != 2:
          raise ValueError(
              "'X' should be a 2D NumPy array, 2D sparse matrix or pandas "
              "dataframe when indexing the columns (i.e. 'axis=1'). "
              "Got {} instead with {} dimension(s).".format(
                  type(X), X.ndim
              )
          )
  
      if axis == 1 and indices_dtype == "str" and not hasattr(X, "loc"):
          raise ValueError(
              "Specifying the columns using strings is only supported for "
              "pandas DataFrames"
          )
  
      if hasattr(X, "iloc"):
          return _pandas_indexing(X, indices, indices_dtype, axis=axis)
      elif hasattr(X, "shape"):
          return _array_indexing(X, indices, indices_dtype, axis=axis)
      else:
          return _list_indexing(X, indices, indices_dtype)
  
imports: import functools
  import logging
  import numbers
  import time
  import warnings
  from collections import Counter
  from contextlib import suppress
  from itertools import compress
  from traceback import format_exc
  import numpy
  import scipy.sparse
  from catboost import CatBoostClassifier, CatBoostRegressor
  from joblib import Parallel, logger
  from scipy.sparse import issparse
  from sklearn import config_context, get_config
  from sklearn.base import clone, is_classifier
  from sklearn.exceptions import FitFailedWarning, NotFittedError
  from sklearn.metrics import check_scoring
  from sklearn.metrics._scorer import _MultimetricScorer
  from sklearn.model_selection import check_cv
  from sklearn.utils.fixes import np_version, parse_version
  from sklearn.utils.validation import indexable
label_desc: Use image node_id 12 for calling a global function with example usage: _safe_indexing(X, indices) and returns: X, _pandas_indexing, _array_indexing, _list_indexing