code: def extract_knn_infos(knn_info, n_neighbors):
      """
      Extract the nearest neighbors distances and indices
      from the knn_info parameter.
  
      Parameters
      ----------
          knn_info : array / sparse array / tuple, optional (device or host)
          Either one of :
              - Tuple (indices, distances) of arrays of
                shape (n_samples, n_neighbors)
              - Pairwise distances dense array of shape (n_samples, n_samples)
              - KNN graph sparse array (preferably CSR/COO)
          n_neighbors: number of nearest neighbors
      """
      if knn_info is None:
          # no KNN was provided
          return None
  
      deepcopy = False
      if isinstance(knn_info, tuple):
          # dists and indices provided as a tuple
          results = knn_info
      else:
          isaKNNGraph = isinstance(
              knn_info,
              (
                  csr_matrix,
                  coo_matrix,
                  csc_matrix,
                  cp_csr_matrix,
                  cp_coo_matrix,
                  cp_csc_matrix,
              ),
          )
          if isaKNNGraph:
              # extract dists and indices from a KNN graph
              deepcopy = True
              results = extract_knn_graph(knn_info)
          else:
              # extract dists and indices from a pairwise distance matrix
              results = extract_pairwise_dists(knn_info, n_neighbors)
  
      if results is not None:
          knn_indices, knn_dists = results
  
          knn_indices_m, _, _, _ = input_to_cuml_array(
              knn_indices.flatten(),
              order="C",
              deepcopy=deepcopy,
              check_dtype=np.int64,
              convert_to_dtype=np.int64,
          )
  
          knn_dists_m, _, _, _ = input_to_cuml_array(
              knn_dists.flatten(),
              order="C",
              deepcopy=deepcopy,
              check_dtype=np.float32,
              convert_to_dtype=np.float32,
          )
  
          return knn_indices_m, knn_dists_m
      else:
          return None
  
file_path: cuml/python/cuml/common/sparsefuncs.py
imports: import math
  import cuml
  from cuml.internals.input_utils import input_to_cuml_array, input_to_cupy_array
  from cuml.internals.memory_utils import with_cupy_rmm
  from cuml.internals.import_utils import has_scipy
  from cuml.common.kernel_utils import cuda_kernel_factory
  from cuml.internals.safe_imports import cpu_only_import
  from cuml.internals.safe_imports import gpu_only_import
  from cuml.internals.safe_imports import gpu_only_import_from
label_desc: Use image node_id 10 for calling a global function with example usage: extract_knn_infos(knn_info, n_neighbors) and returns: None, knn_indices_m,  knn_dists_m, None