code: def safe_indexing(X, indices):
      """Return items or rows from X using indices.
  
      Allows simple indexing of lists or arrays.
  
      Parameters
      ----------
      X : array-like, sparse-matrix, list.
          Data from which to sample rows or items.
  
      indices : array-like, list
          Indices according to which X will be subsampled.
      """
      if hasattr(X, "iloc"):
          # Pandas Dataframes and Series
          try:
              return X.iloc[indices]
          except ValueError:
              # Cython typed memoryviews internally used in pandas do not support
              # readonly buffers.
              warnings.warn(
                  "Copying input dataframe for slicing.",
                  DataConversionWarning,
              )
              return X.copy().iloc[indices]
      elif hasattr(X, "shape"):
          if hasattr(X, "take") and (
              hasattr(indices, "dtype") and indices.dtype.kind == "i"
          ):
              # This is often substantially faster than X[indices]
              return X.take(indices, axis=0)
          else:
              return X[indices]
      else:
          return [X[idx] for idx in indices]
  
imports: from collections import Sequence
  import numpy
  from scipy.sparse import issparse
  import warnings
  from .murmurhash import murmurhash3_32
  from .validation import as_float_array, assert_all_finite, check_random_state, column_or_1d, check_array, check_consistent_length, check_X_y, indexable, check_symmetric
  from .deprecation import deprecated
  from .class_weight import compute_class_weight, compute_sample_weight
  from ..externals.joblib import cpu_count
  from ..exceptions import ConvergenceWarning
  from ..exceptions import DataConversionWarning
label_desc: Use image node_id 3 for calling a global function with example usage: safe_indexing(X, indices) and returns: X, unknown, X, X, X