code: def dfs_assemble_nx(
      graph, cur_mol, global_amap, fa_amap, cur_node_id, fa_node_id
  ):
      cur_node = graph.nodes_dict[cur_node_id]
      fa_node = (
          graph.nodes_dict[fa_node_id]
          if fa_node_id is not None
          else None
      )
  
      fa_nid = fa_node["nid"] if fa_node is not None else -1
      prev_nodes = [fa_node] if fa_node is not None else []
  
      children_id = [
          nei
          for nei in graph[cur_node_id]
          if graph.nodes_dict[nei]["nid"] != fa_nid
      ]
      children = [graph.nodes_dict[nei] for nei in children_id]
      neighbors = [
          nei for nei in children if nei["mol"].GetNumAtoms() > 1
      ]
      neighbors = sorted(
          neighbors, key=lambda x: x["mol"].GetNumAtoms(), reverse=True
      )
      singletons = [
          nei for nei in children if nei["mol"].GetNumAtoms() == 1
      ]
      neighbors = singletons + neighbors
  
      cur_amap = [
          (fa_nid, a2, a1)
          for nid, a1, a2 in fa_amap
          if nid == cur_node["nid"]
      ]
      cands = enum_assemble_nx(
          graph.nodes_dict[cur_node_id], neighbors, prev_nodes, cur_amap
      )
      if len(cands) == 0:
          return
  
      cand_smiles, _, cand_amap = zip(*cands)
      label_idx = cand_smiles.index(cur_node["label"])
      label_amap = cand_amap[label_idx]
  
      for nei_id, ctr_atom, nei_atom in label_amap:
          if nei_id == fa_nid:
              continue
          global_amap[nei_id][nei_atom] = global_amap[cur_node["nid"]][
              ctr_atom
          ]
  
      cur_mol = attach_mols_nx(
          cur_mol, children, [], global_amap
      )  # father is already attached
      for nei_node_id, nei_node in zip(children_id, children):
          if not nei_node["is_leaf"]:
              dfs_assemble_nx(
                  graph,
                  cur_mol,
                  global_amap,
                  label_amap,
                  nei_node_id,
                  cur_node_id,
              )
  
imports: from collections import defaultdict
  import rdkit.Chem
  from rdkit.Chem.EnumerateStereoisomers import EnumerateStereoisomers
  from scipy.sparse import csr_matrix
  from scipy.sparse.csgraph import minimum_spanning_tree
label_desc: Use image node_id 16 for calling a global function with example usage: dfs_assemble_nx(graph, cur_mol, global_amap, fa_amap, cur_node_id, fa_node_id) without return types