docs: def choicerank(
          digraph, traffic_in, traffic_out, weight=None,
          initial_params=None, alpha=1.0, max_iter=10000, tol=1e-8):
      """Compute the MAP estimate of a network choice model's parameters.
  
      This function computes the maximum-a-posteriori (MAP) estimate of model
      parameters given a network structure and node-level traffic data (see
      :ref:`data-network`), using the ChoiceRank algorithm [MG17]_, [KTVV15]_.
  
      The nodes are assumed to be labeled using consecutive integers starting
      from 0.
  
      Parameters
      ----------
      digraph : networkx.DiGraph
          Directed graph representing the network.
      traffic_in : array_like
          Number of arrivals at each node.
      traffic_out : array_like
          Number of departures at each node.
      weight : str, optional
          The edge attribute that holds the numerical value used for the edge
          weight. If None (default) then all edge weights are 1.
      initial_params : array_like, optional
          Parameters used to initialize the iterative procedure.
      alpha : float, optional
          Regularization parameter.
      max_iter : int, optional
          Maximum number of iterations allowed.
      tol : float, optional
          Maximum L1-norm of the difference between successive iterates to
          declare convergence.
  
      Returns
      -------
      params : numpy.ndarray
          The MAP estimate of model parameters.
  
      Raises
      ------
      ImportError
          If the NetworkX library cannot be imported.
      """
      import networkx as nx
      # Compute the (sparse) adjacency matrix.
      n_items = len(digraph)
      nodes = np.arange(n_items)
      adj = nx.to_scipy_sparse_matrix(digraph, nodelist=nodes, weight=weight)
      adj_t = adj.T.tocsr()
      # Process the data into a standard form.
      traffic_in = np.asarray(traffic_in)
      traffic_out = np.asarray(traffic_out)
      data = (adj, adj_t, traffic_in, traffic_out)
      return _mm(
              n_items, data, initial_params, alpha, max_iter, tol, _choicerank)