code: def _conv_array_to_sparse(arr):
      """
      Converts an array (or cudf.DataFrame) to a sparse array
      :param arr: scipy or cupy sparse matrix, cudf DataFrame,
                  dense numpy or cupy array
      :return: cupy sparse CSR matrix
      """
      if has_scipy():
          from scipy.sparse import isspmatrix as scipy_sparse_isspmatrix
      else:
          from cuml.internals.import_utils import (
              dummy_function_always_false as scipy_sparse_isspmatrix,
          )
      if scipy_sparse_isspmatrix(arr):
          ret = cupyx.scipy.sparse.csr_matrix(arr.tocsr())
      elif cupyx.scipy.sparse.isspmatrix(arr):
          ret = arr
      elif isinstance(arr, cudf.DataFrame):
          ret = _conv_df_to_sparse(arr)
      elif isinstance(arr, np.ndarray):
          cupy_ary = rmm_cupy_ary(cp.asarray, arr, dtype=arr.dtype)
          ret = cupyx.scipy.sparse.csr_matrix(cupy_ary)
  
      elif isinstance(arr, cp.ndarray):
          ret = cupyx.scipy.sparse.csr_matrix(arr)
      else:
          raise ValueError("Unexpected input type %s" % type(arr))
      return ret
  
file_path: cuml/python/cuml/dask/common/dask_arr_utils.py
imports: from cuml.common import rmm_cupy_ary, has_scipy
  from cuml.dask.common.part_utils import _extract_partitions
  from dask.distributed import default_client
  from cuml.dask.common.dask_df_utils import to_dask_cudf
  from cuml.internals.memory_utils import with_cupy_rmm
  import dask.dataframe
  import dask
  from cuml.internals.safe_imports import gpu_only_import
  from cuml.internals.safe_imports import cpu_only_import
label_desc: Use image node_id 3 for calling a global function with example usage: _conv_array_to_sparse(arr) and returns: ret