code: def convert_to_list(array, custom_err_msg=None):
      """Convert an array to a list.
  
      :param array: An array like python object.
      :type array: pd.DataFrame or pd.Series or np.ndarray or
                   pd.Index or scipy sparse array
      :param custom_err_msg: A custom error message to use.
      :type custom_err_msg: str
      :return: Python List.
      :rtype: list
      """
      if issparse(array):
          if array.shape[1] > 1000:
              if custom_err_msg is None:
                  raise ValueError(
                      "Exceeds maximum number of features for "
                      "visualization (1000)"
                  )
              else:
                  raise ValueError(custom_err_msg)
          return array.toarray().tolist()
      if isinstance(array, pd.DataFrame) or isinstance(
          array, pd.Series
      ):
          return array.values.tolist()
      if isinstance(array, np.ndarray) or isinstance(array, pd.Index):
          return array.tolist()
      return array
  
file_path: responsible-ai-toolbox/raiutils/raiutils/data_processing/data_processing_utils.py
imports: import datetime
  import json
  from typing import Any, Dict, List
  import numpy
  import pandas
  from scipy.sparse import issparse
  from sklearn.utils import check_consistent_length
label_desc: Use image node_id 1 for calling a global function with example usage: convert_to_list(array, custom_err_msg) and returns: array, array, array, array