code: def retrieve_rows(
      X: modALinput, I: Union[int, List[int], np.ndarray]
  ) -> Union[sp.csc_matrix, np.ndarray, pd.DataFrame]:
      """
      Returns the rows I from the data set X
  
      For a single index, the result is as follows:
      * 1xM matrix in case of scipy sparse NxM matrix X
      * pandas series in case of a pandas data frame
      * row in case of list or numpy format
      """
  
      try:
          return X[I]
      except:
          if sp.issparse(X):
              # Out of the sparse matrix formats (sp.csc_matrix, sp.csr_matrix, sp.bsr_matrix,
              # sp.lil_matrix, sp.dok_matrix, sp.coo_matrix, sp.dia_matrix), only sp.bsr_matrix, sp.coo_matrix
              # and sp.dia_matrix don't support indexing and need to be converted to a sparse format
              # that does support indexing. It seems conversion to CSR is currently most efficient.
  
              sp_format = X.getformat()
              return X.tocsr()[I].asformat(sp_format)
          elif isinstance(X, pd.DataFrame):
              return X.iloc[I]
          elif isinstance(X, list):
              return np.array(X)[I].tolist()
          elif isinstance(X, dict):
              X_return = {}
              for key, value in X.items():
                  X_return[key] = retrieve_rows(value, I)
              return X_return
  
      raise TypeError("%s datatype is not supported" % type(X))
  
file_path: modAL/modAL/utils/data.py
imports: from typing import List, Sequence, Union
  import numpy
  import pandas
  import scipy.sparse
label_desc: Use image node_id 4 for calling a global function with example usage: retrieve_rows(X, I) and returns: X, X, X, np, X_return