code: def _excitations(electrons, orbitals):
      r"""Generate all possible single and double excitations from a Hartree-Fock reference state.
  
      This function is a more performant version of ``qchem.excitations``, where the order of the
      generated excitations is consistent with PySCF.
  
      Single and double excitations can be generated by acting with the operators
      :math:`\hat T_1` and :math:`\hat T_2` on the Hartree-Fock reference state:
  
      .. math::
  
          && \hat{T}_1 = \sum_{p \in \mathrm{occ} \\ q \in \mathrm{unocc}}
          \hat{c}_q^\dagger \hat{c}_p \\
          && \hat{T}_2 = \sum_{p>q \in \mathrm{occ} \\ r>s \in
          \mathrm{unocc}} \hat{c}_r^\dagger \hat{c}_s^\dagger \hat{c}_p \hat{c}_q.
  
  
      In the equations above the indices :math:`p, q, r, s` run over the
      occupied (occ) and unoccupied (unocc) *spin* orbitals and :math:`\hat c` and
      :math:`\hat c^\dagger` are the electron annihilation and creation operators,
      respectively.
  
      Args:
          electrons (int): number of electrons
          orbitals (int): number of spin orbitals
  
      Returns:
          tuple(list, list): lists with the indices of the spin orbitals involved in the excitations
  
      **Example**
  
      >>> electrons = 2
      >>> orbitals = 4
      >>> _excitations(electrons, orbitals)
      ([[0, 2], [0, 3], [1, 2], [1, 3]], [[0, 1, 2, 3]])
      """
      singles_p, singles_q = [], []
      doubles_pq, doubles_rs = [], []
  
      for i in range(electrons):
          singles_p += [i]
          doubles_pq += [[k, i] for k in range(i)]
      for j in range(electrons, orbitals):
          singles_q += [j]
          doubles_rs += [[k, j] for k in range(electrons, j)]
  
      singles = [[p] + [q] for p in singles_p for q in singles_q]
      doubles = [pq + rs for pq in doubles_pq for rs in doubles_rs]
  
      return singles, doubles
  
imports: import warnings
  from itertools import product
  import numpy
  import pennylane
  from pennylane.operation import Tensor, active_new_opmath
  from pennylane.pauli import pauli_sentence
  from pennylane.wires import Wires
label_desc: Use image node_id 7 for calling a global function with example usage: _excitations(electrons, orbitals) and returns: singles,  doubles