code: def safe_indexing(X, indices):
      """Return items or rows from X using indices.
      Allows simple indexing of lists or arrays.
      Borrowed from https://github.com/scikit-learn/scikit-learn/blob/master/sklearn/utils/__init__.py
  
      Parameters
      ----------
      X : array-like, sparse-matrix, list, pandas.DataFrame, pandas.Series.
          Data from which to sample rows or items.
      indices : array-like of int
          Indices according to which X will be subsampled.
  
      Returns
      -------
      subset
          Subset of X on first axis
      """
      if 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]
  
file_path: cornac/cornac/utils/common.py
imports: import numbers
  import numpy
  import scipy.sparse
  from .fast_sparse_funcs import inplace_csr_row_normalize_l1, inplace_csr_row_normalize_l2
label_desc: Use image node_id 6 for calling a global function with example usage: safe_indexing(X, indices) and returns: unknown, X, X