code: def cugraph_call(
      gpu_benchmark_callable,
      cugraph_algo,
      input_G_or_matrix,
      directed=None,
  ):
      """
      Test helper that calls cugraph_algo (which is either
      weakly_connected_components() or strongly_connected_components()) on the
      Graph or matrix object input_G_or_matrix, via the gpu_benchmark_callable
      benchmark callable (which may or may not perform benchmarking based on
      command-line options), verify the result type, and return a dictionary for
      comparison.
      """
      # if benchmarking is enabled, this call will be benchmarked (ie. run
      # repeatedly, run time averaged, etc.)
      result = gpu_benchmark_callable(
          cugraph_algo, input_G_or_matrix, directed
      )
  
      # dict of labels to list of vertices with that label
      label_vertex_dict = defaultdict(list)
  
      # Lookup results differently based on return type, and ensure return type
      # is correctly set based on input type.
      input_type = type(input_G_or_matrix)
      expected_return_type = cuGraph_input_output_map[input_type]
  
      if expected_return_type is cudf.DataFrame:
          assert type(result) is cudf.DataFrame
          for i in range(len(result)):
              label_vertex_dict[result["labels"][i]].append(
                  result["vertex"][i]
              )
  
      # NetworkX input results in returning a dictionary mapping vertices to
      # their labels.
      elif expected_return_type is dict:
          assert type(result) is dict
          for vert, label in result.items():
              label_vertex_dict[label].append(vert)
  
      # A CuPy/SciPy input means the return value will be a 2-tuple of:
      #   n_components: int
      #       The number of connected components (number of unique labels).
      #   labels: ndarray
      #       The length-N array of labels of the connected components.
      elif expected_return_type is tuple:
          assert type(result) is tuple
          assert type(result[0]) is int
          if input_type in cupy_types:
              assert type(result[1]) is cp.ndarray
          else:
              assert type(result[1]) is np.ndarray
  
          unique_labels = set([n.item() for n in result[1]])
          assert len(unique_labels) == result[0]
  
          # The returned dict used in the tests for checking correctness needs
          # the actual vertex IDs, which are not in the returned data (the
          # CuPy/SciPy connected_components return types cuGraph is converting
          # to does not include them). So, extract the vertices from the input
          # COO, order them to match the returned list of labels (which is just
          # a sort), and include them in the returned dict.
          if input_type 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]
              )
          )
          num_verts = len(verts)
          num_verts_assigned_labels = len(result[1])
          assert num_verts_assigned_labels == num_verts
  
          for i in range(num_verts):
              label = result[1][i].item()
              label_vertex_dict[label].append(verts[i])
  
      else:
          raise RuntimeError(
              f"unsupported return type: {expected_return_type}"
          )
  
      return label_vertex_dict
  
imports: import gc
  import time
  from collections import defaultdict
  import pytest
  import cupy
  import numpy
  import networkx
  from cupyx.scipy.sparse import coo_matrix
  from cupyx.scipy.sparse import csr_matrix
  from cupyx.scipy.sparse import csc_matrix
  from scipy.sparse import coo_matrix
  from scipy.sparse import csr_matrix
  from scipy.sparse import csc_matrix
  from cugraph.utilities import is_nx_graph_type
  import cudf
  import cugraph
  from cugraph.testing import utils, DEFAULT_DATASETS
  from cugraph.datasets import dolphins, netscience, email_Eu_core
label_desc: Use image node_id 4 for calling a global function with example usage: cugraph_call(gpu_benchmark_callable, cugraph_algo, input_G_or_matrix, directed) and returns: label_vertex_dict