code: def convert_output_to_cudf(input_G_or_matrix, cugraph_result):
      """
      Convert cugraph_result to a cudf DataFrame. The conversion is based on the
      type of input_G_or_matrix, since different input types result in different
      cugraph_result types (see cugraph_input_output_map).
      """
      input_type = type(input_G_or_matrix)
      expected_return_type = cuGraph_input_output_map[
          type(input_G_or_matrix)
      ]
      assert type(cugraph_result) is expected_return_type
  
      if expected_return_type is cudf.DataFrame:
          return cugraph_result
  
      # A CuPy/SciPy input means the return value will be a 2-tuple of:
      #   distance: cupy.ndarray
      #      ndarray of shortest distances between source and vertex.
      #   predecessor: cupy.ndarray
      #      ndarray of predecessors of a vertex on the path from source, which
      #      can be used to reconstruct the shortest paths.
      # or a 3-tuple of the above 2 plus
      #   sp_counter: cupy.ndarray
      #      for the i'th position in the array, the number of shortest paths
      #      leading to the vertex at position i in the (input) vertex array.
      elif expected_return_type is tuple:
          if input_type in cupy_types:
              assert type(cugraph_result[0]) is cp.ndarray
              assert type(cugraph_result[1]) is cp.ndarray
              if len(cugraph_result) == 3:
                  assert type(cugraph_result[2]) is cp.ndarray
          else:
              assert type(cugraph_result[0]) is np.ndarray
              assert type(cugraph_result[1]) is np.ndarray
              if len(cugraph_result) == 3:
                  assert type(cugraph_result[2]) is np.ndarray
  
          # Get unique verts from input since they are not incuded in output
          if type(input_G_or_matrix) in [
              cp_csr_matrix,
              cp_csc_matrix,
              sp_csr_matrix,
              sp_csc_matrix,
          ]:
              coo = input_G_or_matrix.tocoo(copy=False)
          else:
              coo = input_G_or_matrix
          verts = sorted(
              set(
                  [n.item() for n in coo.col]
                  + [n.item() for n in coo.row]
              )
          )
          dists = [n.item() for n in cugraph_result[0]]
          preds = [n.item() for n in cugraph_result[1]]
          assert len(verts) == len(dists) == len(preds)
  
          d = {"vertex": verts, "distance": dists, "predecessor": preds}
  
          if len(cugraph_result) == 3:
              counters = [n.item() for n in cugraph_result[2]]
              assert len(counters) == len(verts)
              d.update({"sp_counter": counters})
  
          return cudf.DataFrame(d)
  
      else:
          raise RuntimeError(
              f"unsupported return type: {expected_return_type}"
          )
  
imports: import gc
  import pytest
  import cupy
  import numpy
  from scipy.sparse import coo_matrix
  from scipy.sparse import csr_matrix
  from scipy.sparse import csc_matrix
  import cudf
  import cugraph
  from cupyx.scipy.sparse import coo_matrix
  from cupyx.scipy.sparse import csr_matrix
  from cupyx.scipy.sparse import csc_matrix
  from pylibcugraph.testing.utils import gen_fixture_params_product
  from cugraph.testing import utils, get_resultset, load_resultset, DEFAULT_DATASETS, SMALL_DATASETS
label_desc: Use image node_id 2 for calling a global function with example usage: convert_output_to_cudf(input_G_or_matrix, cugraph_result) and returns: cugraph_result, cudf