code: def attach_mols(ctr_mol, neighbors, prev_nodes, nei_amap):
      prev_nids = [node.nid for node in prev_nodes]
      for nei_node in prev_nodes + neighbors:
          nei_id, nei_mol = nei_node.nid, nei_node.mol
          amap = nei_amap[nei_id]
          for atom in nei_mol.GetAtoms():
              if atom.GetIdx() not in amap:
                  new_atom = copy_atom(atom)
                  amap[atom.GetIdx()] = ctr_mol.AddAtom(new_atom)
  
          if nei_mol.GetNumBonds() == 0:
              nei_atom = nei_mol.GetAtomWithIdx(0)
              ctr_atom = ctr_mol.GetAtomWithIdx(amap[0])
              ctr_atom.SetAtomMapNum(nei_atom.GetAtomMapNum())
          else:
              for bond in nei_mol.GetBonds():
                  a1 = amap[bond.GetBeginAtom().GetIdx()]
                  a2 = amap[bond.GetEndAtom().GetIdx()]
                  if ctr_mol.GetBondBetweenAtoms(a1, a2) is None:
                      ctr_mol.AddBond(a1, a2, bond.GetBondType())
                  elif nei_id in prev_nids:  # father node overrides
                      ctr_mol.RemoveBond(a1, a2)
                      ctr_mol.AddBond(a1, a2, bond.GetBondType())
      return ctr_mol
  
imports: import rdkit
  import rdkit.Chem
  from scipy.sparse import csr_matrix
  from scipy.sparse.csgraph import minimum_spanning_tree
  from collections import defaultdict
  from rdkit.Chem.EnumerateStereoisomers import EnumerateStereoisomers, StereoEnumerationOptions
  from .vocab import Vocab
label_desc: Use image node_id 12 for calling a global function with example usage: attach_mols(ctr_mol, neighbors, prev_nodes, nei_amap) and returns: ctr_mol