code: def test_taper_obs(symbols, geometry, charge, op_arithmetic):
      r"""Test that the expectation values of tapered observables with respect to the
      tapered Hartree-Fock state (:math:`\langle HF|obs|HF \rangle`) are consistent.
      """
      if op_arithmetic:
          enable_new_opmath()
      mol = qml.qchem.Molecule(symbols, geometry, charge)
      hamiltonian = qml.qchem.diff_hamiltonian(mol)(geometry)
      hf_state = np.where(
          np.arange(len(hamiltonian.wires)) < mol.n_electrons, 1, 0
      )
      generators = qml.symmetry_generators(hamiltonian)
      paulixops = qml.paulix_ops(generators, len(hamiltonian.wires))
      paulix_sector = optimal_sector(
          hamiltonian, generators, mol.n_electrons
      )
      hf_state_tapered = taper_hf(
          generators,
          paulixops,
          paulix_sector,
          mol.n_electrons,
          len(hamiltonian.wires),
      )
  
      # calculate the HF energy <\psi_{HF}| H |\psi_{HF}> for tapered and untapered Hamiltonian
      o = np.array([1, 0])
      l = 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_state_tapered]
      )
  
      observables = [
          hamiltonian,
          qml.qchem.particle_number(len(hamiltonian.wires)),
          qml.qchem.spin2(mol.n_electrons, len(hamiltonian.wires)),
          qml.qchem.spinz(len(hamiltonian.wires)),
      ]
      for observable in observables:
          if op_arithmetic:
              enable_new_opmath()
  
          obs_ps = qml.pauli.pauli_sentence(observable)
          tapered_obs = qml.taper(
              observable, generators, paulixops, paulix_sector
          )
          tapered_ps = _taper_pauli_sentence(
              obs_ps, generators, paulixops, paulix_sector
          )
  
          obs_val = (
              scipy.sparse.coo_matrix(state)
              @ observable.sparse_matrix(
                  wire_order=range(len(observable.wires))
              )
              @ scipy.sparse.coo_matrix(state).T
          ).toarray()
          obs_val_tapered = (
              scipy.sparse.coo_matrix(state_tapered)
              @ tapered_obs.sparse_matrix(
                  wire_order=range(len(tapered_obs.wires))
              )
              @ scipy.sparse.coo_matrix(state_tapered).T
          ).toarray()
  
          if op_arithmetic:
              disable_new_opmath()
  
          assert np.isclose(obs_val, obs_val_tapered)
          assert qml.equal(tapered_obs, tapered_ps)
  
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 10 for calling a global function with example usage: test_taper_obs(symbols, geometry, charge, op_arithmetic) without return types