class_docstr: Tests for the quantum gradients of various gates
  with expectation value output
docstr: Test the numerical gradient of the squeeze gate with
  with number state expectation is correct
docstr_tok: ["Test","the","numerical","gradient","of","the","squeeze","gate","with","with","number","state","expectation","is","correct"]
code: def test_squeezed_number_state_gradient(self, mocker, tol):
      """Test the numerical gradient of the squeeze gate with
      with number state expectation is correct"""
      dev = qml.device("default.gaussian", wires=2, hbar=hbar)
  
      r = 0.23354
  
      with qml.queuing.AnnotatedQueue() as q:
          qml.Squeezing(r, 0.0, wires=[0])
          # the fock state projector is a 'non-Gaussian' observable
          qml.expval(
              qml.FockStateProjector(np.array([2, 0]), wires=[0, 1])
          )
  
      tape = qml.tape.QuantumScript.from_queue(q)
      tape.trainable_params = {0}
  
      spy = mocker.spy(
          qml.gradients.parameter_shift_cv, "second_order_param_shift"
      )
      spy2 = mocker.spy(
          qml.gradients.parameter_shift_cv, "_find_gradient_methods_cv"
      )
  
      tapes, fn = param_shift_cv(tape, dev)
      grad = fn(dev.batch_execute(tapes))
  
      spy.assert_not_called()
      assert spy2.spy_return == {0: "F"}
  
      # (d/dr) |<2|S(r)>|^2 = 0.5 tanh(r)^3 (2 csch(r)^2 - 1) sech(r)
      expected = (
          0.5
          * np.tanh(r) ** 3
          * (2 / (np.sinh(r) ** 2) - 1)
          / np.cosh(r)
      )
      assert np.allclose(grad, expected, atol=tol, rtol=0)
  
imports: import unittest.mock
  import pytest
  import pennylane
  from pennylane import numpy
  from pennylane.gradients import param_shift_cv
  from pennylane.gradients.gradient_transform import choose_trainable_params
  from pennylane.gradients.parameter_shift_cv import _grad_method_cv, _find_gradient_methods_cv, _transform_observable
label_desc: Use image node_id 5 for calling the TestExpectationQuantumGradients obj's underlying member method code with example usage: obj.test_squeezed_number_state_gradient(mocker, tol) without return types