code: def _convert_df_to_output_type(df, input_type, return_predecessors):
      """
      Given a cudf.DataFrame df, convert it to a new type appropriate for the
      graph algos in this module, based on input_type.
  
      return_predecessors is only used for return values from cupy/scipy input
      types.
      """
      if input_type in [Graph, MultiGraph]:
          return df
  
      elif is_nx_graph_type(input_type):
          return df.to_pandas()
  
      elif is_matrix_type(input_type):
          # A CuPy/SciPy input means the return value will be a 2-tuple of:
          #   distance: cupy.ndarray
          #   predecessor: cupy.ndarray
          sorted_df = df.sort_values("vertex")
          if return_predecessors:
              if is_cp_matrix_type(input_type):
                  return (
                      cp.from_dlpack(sorted_df["distance"].to_dlpack()),
                      cp.from_dlpack(
                          sorted_df["predecessor"].to_dlpack()
                      ),
                  )
              else:
                  return (
                      sorted_df["distance"].to_numpy(),
                      sorted_df["predecessor"].to_numpy(),
                  )
          else:
              if is_cp_matrix_type(input_type):
                  return cp.from_dlpack(
                      sorted_df["distance"].to_dlpack()
                  )
              else:
                  return sorted_df["distance"].to_numpy()
      else:
          raise TypeError(
              f"input type {input_type} is not a supported type."
          )
  
file_path: cugraph/python/cugraph/cugraph/traversal/sssp.py
imports: import numpy
  import cudf
  from cugraph.structure import Graph, MultiGraph
  from cugraph.utilities import ensure_cugraph_obj, is_matrix_type, is_cp_matrix_type, is_nx_graph_type, cupy_package
  from pylibcugraph import sssp, ResourceHandle
label_desc: Use image node_id 2 for calling a global function with example usage: _convert_df_to_output_type(df, input_type, return_predecessors) and returns: df, df, cp,  cp, sorted_df,  sorted_df, cp, sorted_df