code: def test_particle_number(orbitals, coeffs_ref, ops_ref):
      r"""Tests the correctness of the :math:`\hat{S}_z` observable built by the
      function `'spin_z'`.
      """
      n = qchem.particle_number(orbitals)
      n_ref = qml.Hamiltonian(coeffs_ref, ops_ref)
      assert n.compare(n_ref)
  
      enable_new_opmath()
      n_pl_op = qchem.particle_number(orbitals)
      disable_new_opmath()
  
      wire_order = n_ref.wires
      assert not isinstance(n_pl_op, qml.Hamiltonian)
      assert np.allclose(
          qml.matrix(n_pl_op, wire_order=wire_order),
          qml.matrix(n_ref, wire_order=wire_order),
      )
  
imports: import pytest
  import pennylane
  from pennylane import Identity, PauliZ
  from pennylane import numpy
  from pennylane import qchem
  from pennylane.operation import enable_new_opmath, disable_new_opmath
label_desc: Use image node_id 1 for calling a global function with example usage: test_particle_number(orbitals, coeffs_ref, ops_ref) without return types