def place_bonds_inner(self, state):
    """Place bonds corresponding to `state`.

    No validity checking is done, the calling function is responsible
    for that.

    Args:
      state: for each pair of atoms, the kind of bond to be placed.

    Returns:
      If successful, a BondTopology.
    """
    self._current_bonds_attached = np.copy(self._bonds_with_hydrogens_attached)

    result = dataset_pb2.BondTopology()
    result.CopyFrom(self._starting_bond_topology)  # only Hydrogens attached.
    result.score = self._initial_score

    # Make sure each atoms gets at least one bond
    atom_got_bond = np.zeros(self._heavy_atoms)

    for i, btype in enumerate(state):
      if btype != dataset_pb2.BondTopology.BOND_UNDEFINED:
        a1 = self._bonds[i][0]
        a2 = self._bonds[i][1]
        if not self._place_bond(a1, a2, btype):
          return None
        add_bond(a1, a2, btype, result)
        atom_got_bond[a1] = 1
        atom_got_bond[a2] = 1

      result.score = self._accumulate_score(result.score,
                                            self._scores[i][btype])
    if not np.all(atom_got_bond):
      return None

    return result