code: def _calc_bc_subset(
      G, Gnx, normalized, weight, endpoints, k, seed, result_dtype
  ):
      # NOTE: Networkx API does not allow passing a list of vertices
      # And the sampling is operated on Gnx.nodes() directly
      # We first mimic acquisition of the nodes to compare with same sources
      random.seed(seed)  # It will be called again in nx's call
      sources = random.sample(list(Gnx.nodes()), k)
      print("\nsources are ", sources)
      df = cugraph.betweenness_centrality(
          G,
          k=sources,
          normalized=normalized,
          weight=weight,
          endpoints=endpoints,
          result_dtype=result_dtype,
      )
      sorted_df = (
          df.sort_values("vertex")
          .rename(
              columns={"betweenness_centrality": "cu_bc"}, copy=False
          )
          .reset_index(drop=True)
      )
  
      nx_bc = nx.betweenness_centrality(
          Gnx,
          k=k,
          normalized=normalized,
          weight=weight,
          endpoints=endpoints,
          seed=seed,
      )
  
      _, nx_bc = zip(*sorted(nx_bc.items()))
      nx_df = cudf.DataFrame({"ref_bc": nx_bc})
  
      merged_sorted_df = cudf.concat(
          [sorted_df, nx_df], axis=1, sort=False
      )
  
      return merged_sorted_df
  
imports: import gc
  import pytest
  import random
  import numpy
  import networkx
  import cudf
  import cupy
  import cugraph
  from cugraph.datasets import karate_disjoint
  from cugraph.testing import utils, SMALL_DATASETS
label_desc: Use image node_id 3 for calling a global function with example usage: _calc_bc_subset(G, Gnx, normalized, weight, endpoints, k, seed, result_dtype) and returns: merged_sorted_df