code: def umap_graph_to_weighted_edges(
      umap_graph, engine, is_legacy, cfg=config
  ):
      logger.debug("Calculating weighted adjacency (edge) DataFrame")
      coo = umap_graph.tocoo()
      src, dst, weight_col = cfg.SRC, cfg.DST, cfg.WEIGHT
      if (engine == "umap_learn") or is_legacy:
          _weighted_edges_df = pd.DataFrame(
              {src: coo.row, dst: coo.col, weight_col: coo.data}
          )
      elif (engine == "cuml") and not is_legacy:
          _weighted_edges_df = pd.DataFrame(
              {
                  src: coo.get().row,
                  dst: coo.get().col,
                  weight_col: coo.get().data,
              }
          )
      return _weighted_edges_df
  
imports: import copy
  from time import time
  from typing import TYPE_CHECKING, Any, Dict, Optional, Tuple, Union
  from inspect import getmodule
  import pandas
  from .None import constants
  from .constants import CUML, UMAP_LEARN
  from .feature_utils import FeatureMixin, Literal, XSymbolic, YSymbolic, prune_weighted_edges_df_and_relabel_nodes, resolve_feature_engine
  from .PlotterBase import Plottable, WeakValueDictionary
  from .util import check_set_memoize
  import logging
label_desc: Use image node_id 10 for calling a global function with example usage: umap_graph_to_weighted_edges(umap_graph, engine, is_legacy, cfg) and returns: _weighted_edges_df