code: def test_consistent_taper_ops(operation, op_gen):
      r"""Test that operations are tapered consistently when their generators are provided manually and when they are constructed internally"""
  
      symbols, geometry, charge = (
          ["He", "H"],
          np.array([[0.0, 0.0, 0.0], [0.0, 0.0, 1.4588684632]]),
          1,
      )
      mol = qml.qchem.Molecule(symbols, geometry, charge)
      hamiltonian = qml.qchem.diff_hamiltonian(mol)(geometry)
  
      generators = qml.symmetry_generators(hamiltonian)
      paulixops = qml.paulix_ops(generators, len(hamiltonian.wires))
      paulix_sector = optimal_sector(
          hamiltonian, generators, mol.n_electrons
      )
      wire_order = hamiltonian.wires
  
      taper_op1 = taper_operation(
          operation,
          generators,
          paulixops,
          paulix_sector,
          wire_order,
          op_gen=None,
      )
      taper_op2 = taper_operation(
          operation,
          generators,
          paulixops,
          paulix_sector,
          wire_order,
          op_gen=op_gen,
      )
      assert np.all(
          [
              qml.equal(op1.base, op2.base)
              for op1, op2 in zip(taper_op1, taper_op2)
          ]
      )
  
      with qml.queuing.AnnotatedQueue() as q_tape1:
          taper_operation(
              operation,
              generators,
              paulixops,
              paulix_sector,
              wire_order,
              op_gen=None,
          )
      with qml.queuing.AnnotatedQueue() as q_tape2:
          taper_operation(
              operation,
              generators,
              paulixops,
              paulix_sector,
              wire_order,
              op_gen=op_gen,
          )
      tape1 = qml.tape.QuantumScript.from_queue(q_tape1)
      tape2 = qml.tape.QuantumScript.from_queue(q_tape2)
      taper_circuit1 = [x for x in tape1.circuit if x.label() != "I"]
      taper_circuit2 = [x for x in tape2.circuit if x.label() != "I"]
  
      assert len(taper_op1) == len(taper_circuit1)
      assert len(taper_op2) == len(taper_circuit2)
      assert np.all(
          [
              qml.equal(op1.base, op2.base)
              for op1, op2 in zip(taper_circuit1, taper_op1)
          ]
      )
      assert np.all(
          [
              qml.equal(op1.base, op2.base)
              for op1, op2 in zip(taper_circuit2, taper_op2)
          ]
      )
  
      if taper_op1:
          observables = [
              hamiltonian,  # for energy
              sum(
                  qml.PauliZ(wire) for wire in hamiltonian.wires
              ),  # for local-cost 1
              # for local-cost 2
              sum(
                  qml.PauliZ(wire) @ qml.PauliZ(wire + 1)
                  for wire in hamiltonian.wires
              ),
          ]
          tapered_obs = [
              qml.taper(observale, generators, paulixops, paulix_sector)
              for observale in observables
          ]
  
          hf_state = np.where(
              np.arange(len(hamiltonian.wires)) < mol.n_electrons, 1, 0
          )
          hf_tapered = taper_hf(
              generators,
              paulixops,
              paulix_sector,
              mol.n_electrons,
              len(hamiltonian.wires),
          )
          o, l = np.array([1, 0]), np.array([0, 1])
          state = functools.reduce(
              np.kron, [l if s else o for s in hf_state]
          )
          state_tapered = functools.reduce(
              np.kron, [l if s else o for s in hf_tapered]
          )
          evolved_state = np.matmul(
              qml.matrix(operation, wire_order=range(len(hf_state))),
              state,
          )
          ob_tap_mat = functools.reduce(
              np.matmul,
              [
                  qml.matrix(op, wire_order=range(len(hf_tapered)))
                  for op in taper_op1
              ],
          )
          evolved_state_tapered = np.matmul(ob_tap_mat, state_tapered)
  
          for obs, tap_obs in zip(observables, tapered_obs):
              expec_val = (
                  scipy.sparse.coo_matrix(evolved_state)
                  @ scipy.sparse.coo_matrix(
                      qml.matrix(obs, wire_order=range(len(hf_state)))
                  )
                  @ scipy.sparse.coo_matrix(evolved_state).getH()
              ).toarray()
              expec_val_tapered = (
                  scipy.sparse.coo_matrix(evolved_state_tapered)
                  @ scipy.sparse.coo_matrix(
                      qml.matrix(
                          tap_obs, wire_order=range(len(hf_tapered))
                      )
                  )
                  @ scipy.sparse.coo_matrix(
                      evolved_state_tapered
                  ).getH()
              ).toarray()
              assert np.isclose(expec_val, expec_val_tapered)
  
imports: import functools
  import pytest
  import scipy
  import pennylane
  from pennylane import numpy
  from pennylane.pauli import pauli_sentence
  from pennylane.qchem.tapering import _kernel, _reduced_row_echelon, clifford, optimal_sector, taper_hf, taper_operation, _split_pauli_sentence, _taper_pauli_sentence
  from pennylane.operation import enable_new_opmath, disable_new_opmath
label_desc: Use image node_id 13 for calling a global function with example usage: test_consistent_taper_ops(operation, op_gen) without return types