code: def _maximum_spanning_tree_subgraph(G):
      mst_subgraph = Graph()
      if G.is_directed():
          raise ValueError("input graph must be undirected")
  
      if not G.adjlist:
          G.view_adj_list()
  
      if G.adjlist.weights is not None:
          G.adjlist.weights = G.adjlist.weights.mul(-1)
  
      mst_df = minimum_spanning_tree_wrapper.minimum_spanning_tree(G)
  
      # revert to original weights
      if G.adjlist.weights is not None:
          G.adjlist.weights = G.adjlist.weights.mul(-1)
          mst_df["weight"] = mst_df["weight"].mul(-1)
  
      if G.renumbered:
          mst_df = G.unrenumber(mst_df, "src")
          mst_df = G.unrenumber(mst_df, "dst")
  
      mst_subgraph.from_cudf_edgelist(
          mst_df, source="src", destination="dst", edge_attr="weight"
      )
      return mst_subgraph
  
imports: from cugraph.tree import minimum_spanning_tree_wrapper
  from cugraph.structure.graph_classes import Graph
  from cugraph.utilities import ensure_cugraph_obj_for_nx, cugraph_to_nx
label_desc: Use image node_id 2 for calling a global function with example usage: _maximum_spanning_tree_subgraph(G) and returns: mst_subgraph