code: def BO2mol(mol, BO_matrix, atoms):
      """
      based on code written by Paolo Toscani
  
      From bond order, atoms, valence structure and total charge, generate an
      rdkit molecule.
  
      args:
          mol - rdkit molecule
          BO_matrix - bond order matrix of molecule
          atoms - list of integer atomic symbols
          atomic_valence_electrons -
          mol_charge - total charge of molecule
  
      optional:
          allow_charged_fragments - bool - allow charged fragments
  
      returns
          mol - updated rdkit molecule with bond connectivity
  
      """
  
      l = len(BO_matrix)
      l2 = len(atoms)
  
      if l != l2:
          raise RuntimeError(
              "sizes of adjMat ({0:d}) and Atoms {1:d} differ".format(
                  l, l2
              )
          )
  
      rwMol = Chem.RWMol(mol)
  
      bondTypeDict = {
          1: Chem.BondType.SINGLE,
          2: Chem.BondType.DOUBLE,
          3: Chem.BondType.TRIPLE,
      }
  
      for i in range(l):
          for j in range(i + 1, l):
              bo = int(round(BO_matrix[i, j]))
              if bo == 0:
                  continue
              bt = bondTypeDict.get(bo, Chem.BondType.SINGLE)
              rwMol.AddBond(i, j, bt)
  
      mol = rwMol.GetMol()
  
      return mol
  
imports: from rdkit import Chem
  import numpy
  import networkx
  import collections
  from collections import defaultdict
  import itertools
  import copy
  from scipy.spatial import distance_matrix
label_desc: Use image node_id 12 for calling a global function with example usage: BO2mol(mol, BO_matrix, atoms) and returns: mol