code: def _check_labels(vertex_ordered_labels, expected_vertex_comps):
      """
      vertex_ordered_labels is a list of labels, ordered by the position of the
      vertex ID value, as returned by pylibcugraph.CC algos. For example:
      [9, 9, 7]
      means vertex 0 is labelled 9, vertex 1 is labelled 9, and vertex 2 is
      labelled 7.
  
      expected_vertex_comps is a list of components, where each component is a
      list of vertex IDs the component contains. Each component corresponds to
      some label For example:
      [[0, 1], [2]]
      is two components, the first
      containing vertices 0, 1, and the other 2.  [0, 1] has the label 9 and [2]
      has the label 7.
  
      This asserts if the vertex_ordered_labels do not correspond to the
      expected_vertex_comps.
      """
      # Group the vertex_ordered_labels list into components based on labels by
      # creating a dictionary of labels to lists of vertices with that label.
      d = {}
      for vertex, label in enumerate(vertex_ordered_labels):
          d.setdefault(label, []).append(vertex)
  
      assert len(d.keys()) == len(
          expected_vertex_comps
      ), "number of different labels does not match expected"
  
      # Compare the actual components (created from the dictionary above) to
      # expected.
      actual_vertex_comps = sorted(d.values())
      assert actual_vertex_comps == sorted(expected_vertex_comps)
  
file_path: cugraph/python/pylibcugraph/pylibcugraph/tests/test_connected_components.py
imports: from pathlib import Path
  import pytest
  import numpy
  import pandas
  import cupy
  from scipy.sparse import coo_matrix, csr_matrix
  from pylibcugraph import ResourceHandle, GraphProperties, SGGraph
  from pylibcugraph.testing import utils
label_desc: Use image node_id 2 for calling a global function with example usage: _check_labels(vertex_ordered_labels, expected_vertex_comps) without return types