code: def _convert_df_to_output_type(df, input_type, return_labels):
      """
      Given a cudf.DataFrame df, convert it to a new type appropriate for the
      graph algos in this module, based on input_type.
      return_labels is only used for return values from cupy/scipy input types.
      """
      if input_type in [Graph]:
          return df
  
      elif is_nx_graph_type(input_type):
          return df_score_to_dictionary(df, "labels", "vertex")
  
      elif is_matrix_type(input_type):
          # Convert DF of 2 columns (labels, vertices) to the SciPy-style return
          # value:
          #   n_components: int
          #       The number of connected components (number of unique labels).
          #   labels: ndarray
          #       The length-N array of labels of the connected components.
          n_components = df["labels"].nunique()
          sorted_df = df.sort_values("vertex")
          if return_labels:
              if is_cp_matrix_type(input_type):
                  labels = cp.from_dlpack(
                      sorted_df["labels"].to_dlpack()
                  )
              else:
                  labels = sorted_df["labels"].to_numpy()
              return (n_components, labels)
          else:
              return n_components
  
      else:
          raise TypeError(
              f"input type {input_type} is not a supported type."
          )
  
file_path: cugraph/python/cugraph/cugraph/components/connectivity.py
imports: from cugraph.utilities import df_score_to_dictionary, ensure_cugraph_obj, is_matrix_type, is_cp_matrix_type, is_nx_graph_type, cupy_package
  from cugraph.structure import Graph
  from cugraph.components import connectivity_wrapper
  import cudf
  from pylibcugraph import weakly_connected_components
  from pylibcugraph import 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_labels) and returns: df, df_score_to_dictionary, n_components,  labels, n_components