code: def generalized_singles(wires, delta_sz):
      r"""Return generalized single excitation terms
  
      .. math::
          \hat{T_1} = \sum_{pq} t_{p}^{q} \hat{c}^{\dagger}_{q} \hat{c}_{p}
  
      """
      sz = np.array(
          [0.5 if (i % 2 == 0) else -0.5 for i in range(len(wires))]
      )  # alpha-beta electrons
      gen_singles_wires = []
      for r in range(len(wires)):
          for p in range(len(wires)):
              if sz[p] - sz[r] == delta_sz and p != r:
                  if r < p:
                      gen_singles_wires.append(wires[r : p + 1])
                  else:
                      gen_singles_wires.append(wires[p : r + 1][::-1])
      return gen_singles_wires
  
file_path: pennylane/pennylane/templates/subroutines/kupccgsd.py
imports: import numpy
  import pennylane
  from pennylane.operation import Operation, AnyWires
label_desc: Use image node_id 1 for calling a global function with example usage: generalized_singles(wires, delta_sz) and returns: gen_singles_wires