code: def pagerank(
      G,
      alpha=0.85,
      personalization=None,
      max_iter=100,
      tol=1.0e-6,
      nstart=None,
      weight="weight",
      dangling=None,
      *,
      dtype=None,
  ):
      """`dangling` parameter is not supported, but it is checked for validity."""
      G = _to_graph(G, weight, 1, np.float32)
      if (N := len(G)) == 0:
          return {}
      if dtype is not None:
          dtype = _get_float_dtype(dtype)
      elif weight in G.edge_values:
          dtype = _get_float_dtype(G.edge_values[weight].dtype)
      else:
          dtype = np.float32
      if nstart is not None:
          nstart = G._dict_to_nodearray(nstart, 0, dtype=dtype)
          if (total := nstart.sum()) == 0:
              raise ZeroDivisionError
          nstart /= total
      if personalization is not None:
          personalization = G._dict_to_nodearray(
              personalization, 0, dtype=dtype
          )
          if (total := personalization.sum()) == 0:
              raise ZeroDivisionError
          personalization /= total
      if dangling is not None:
          # Check if given dangling is valid even though we don't use it
          dangling = G._dict_to_nodearray(dangling, 0)  # Check validity
          if dangling.sum() == 0:
              raise ZeroDivisionError
          if (G._out_degrees_array() == 0).any():
              raise NotImplementedError(
                  "custom dangling weights is not supported"
              )
      if max_iter <= 0:
          raise nx.PowerIterationFailedConvergence(max_iter)
      kwargs = {
          "resource_handle": plc.ResourceHandle(),
          "graph": G._get_plc_graph(
              weight, 1, dtype, store_transposed=True
          ),
          "precomputed_vertex_out_weight_vertices": None,
          "precomputed_vertex_out_weight_sums": None,
          "initial_guess_vertices": None
          if nstart is None
          else cp.arange(N, dtype=index_dtype),
          "initial_guess_values": nstart,
          "alpha": alpha,
          "epsilon": N * tol,
          "max_iterations": max_iter,
          "do_expensive_check": False,
          "fail_on_nonconvergence": False,
      }
      if personalization is None:
          node_ids, values, is_converged = plc.pagerank(**kwargs)
      else:
          node_ids, values, is_converged = plc.personalized_pagerank(
              personalization_vertices=cp.arange(
                  N, dtype=index_dtype
              ),  # Why?
              personalization_values=personalization,
              **kwargs,
          )
      if not is_converged:
          raise nx.PowerIterationFailedConvergence(max_iter)
      return G._nodearrays_to_dict(node_ids, values)
  
file_path: cugraph/python/nx-cugraph/nx_cugraph/algorithms/link_analysis/pagerank_alg.py
imports: import cupy
  import networkx
  import numpy
  import pylibcugraph
  from nx_cugraph.convert import _to_graph
  from nx_cugraph.utils import _dtype_param, _get_float_dtype, index_dtype, networkx_algorithm
label_desc: Use image node_id 1 for calling a global function with example usage: pagerank(G, alpha, personalization, max_iter, tol, nstart, weight, dangling) and returns: G, dict