class_docstr: Tests of the automatic gradient method for CV circuits.
class_docstr_tok: ["Tests","of","the","automatic","gradient","method","for","CV","circuits","."]
docstr: Tests that the automatic gradient of a squeezed state with number state expectation is correct.
docstr_tok: ["Tests","that","the","automatic","gradient","of","a","squeezed","state","with","number","state","expectation","is","correct","."]
code: def test_number_state_gradient(self, r, grad_fn_S_Fock, tol):
      "Tests that the automatic gradient of a squeezed state with number state expectation is correct."
  
      # (d/dr) |<2|S(r)>|^2 = 0.5 tanh(r)^3 (2 csch(r)^2 - 1) sech(r)
      autograd_val = grad_fn_S_Fock(r)
      manualgrad_val = (
          0.5
          * np.tanh(r) ** 3
          * (2 / (np.sinh(r) ** 2) - 1)
          / np.cosh(r)
      )
      assert autograd_val == pytest.approx(manualgrad_val, abs=tol)
  
imports: import pytest
  import autograd
  import numpy
  import pennylane.numpy
  import pennylane
label_desc: Use image node_id 5 for calling the TestCVGradient obj's underlying member method code with example usage: obj.test_number_state_gradient(r, grad_fn_S_Fock, tol) without return types