code: def test_betweenness_centrality_nx(graph_file, directed, edgevals):
      Gnx = utils.generate_nx_graph_from_file(
          graph_file, directed, edgevals
      )
  
      nx_bc = nx.betweenness_centrality(Gnx)
      cu_bc = cugraph.betweenness_centrality(Gnx)
  
      # Calculating mismatch
      networkx_bc = sorted(nx_bc.items(), key=lambda x: x[0])
      cugraph_bc = sorted(cu_bc.items(), key=lambda x: x[0])
      err = 0
      assert len(cugraph_bc) == len(networkx_bc)
      for i in range(len(cugraph_bc)):
          if (
              abs(cugraph_bc[i][1] - networkx_bc[i][1]) > 0.01
              and cugraph_bc[i][0] == networkx_bc[i][0]
          ):
              err = err + 1
              print(f"{cugraph_bc[i][1]} and {networkx_bc[i][1]}")
              print(f"{cugraph_bc[i][0]} and {networkx_bc[i][0]}")
      print("Mismatches:", err)
      assert err < (0.01 * len(cugraph_bc))
  
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 12 for calling a global function with example usage: test_betweenness_centrality_nx(graph_file, directed, edgevals) without return types