code: def test_modularity_clustering_nx(graph_file, partitions):
      # Read in the graph and get a cugraph object
      dataset_path = graph_file.get_path()
      csv_data = utils.read_csv_for_nx(
          dataset_path, read_weights_in_sp=True
      )
  
      nxG = nx.from_pandas_edgelist(
          csv_data,
          source="0",
          target="1",
          edge_attr="weight",
          create_using=nx.Graph(),
      )
      assert nx.is_directed(nxG) is False
      assert nx.is_weighted(nxG) is True
  
      cuG, isNx = ensure_cugraph_obj_for_nx(nxG)
      assert cugraph.is_directed(cuG) is False
      assert cugraph.is_weighted(cuG) is True
  
      # Get the modularity score for partitioning versus random assignment
      cu_score = cugraph_call(cuG, partitions)
      rand_score = random_call(cuG, partitions)
  
      # Assert that the partitioning has better modularity than the random
      # assignment
      assert cu_score > rand_score
  
file_path: cugraph/python/cugraph/cugraph/tests/community/test_modularity.py
imports: import gc
  import random
  import pytest
  import networkx
  import cudf
  import cugraph
  from cugraph.testing import utils, DEFAULT_DATASETS
  from cugraph.utilities import ensure_cugraph_obj_for_nx
label_desc: Use image node_id 4 for calling a global function with example usage: test_modularity_clustering_nx(graph_file, partitions) without return types