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 gradients of circuits of gaussian gates match
  between the finite difference and analytic methods.
docstr_tok: ["Tests","that","the","gradients","of","circuits","of","gaussian","gates","match","between","the","finite","difference","and","analytic","methods","."]
code: def test_cv_gradients_gaussian_circuit(
      self, make_gate, O, gaussian_dev, tol
  ):
      """Tests that the gradients of circuits of gaussian gates match
      between the finite difference and analytic methods."""
  
      tol = 1e-5
      par = anp.array(0.4, requires_grad=True)
  
      def circuit(x):
          qml.Displacement(0.5, 0, wires=0)
          make_gate(x)
          qml.Beamsplitter(1.3, -2.3, wires=[0, 1])
          qml.Displacement(-0.5, 0.1, wires=0)
          qml.Squeezing(0.5, -1.5, wires=0)
          qml.Rotation(-1.1, wires=0)
          return qml.expval(O(wires=0))
  
      q = qml.QNode(circuit, gaussian_dev)
  
      grad_F = qml.gradients.finite_diff(q)(par)
      grad_A2 = qml.gradients.param_shift_cv(
          q, dev=gaussian_dev, force_order2=True
      )(par)
      if O.ev_order == 1:
          grad_A = qml.gradients.param_shift_cv(q, dev=gaussian_dev)(
              par
          )
          # the different methods agree
          assert qml.math.shape(grad_A) == qml.math.shape(grad_F) == ()
          assert np.allclose(grad_A, grad_F, atol=tol)
  
      # the different methods agree
      assert qml.math.shape(grad_A2) == qml.math.shape(grad_F) == ()
      assert np.allclose(grad_A2, grad_F, atol=tol)
  
imports: import pytest
  import autograd
  import numpy
  import pennylane.numpy
  import pennylane
label_desc: Use image node_id 6 for calling the TestCVGradient obj's underlying member method code with example usage: obj.test_cv_gradients_gaussian_circuit(make_gate, O, gaussian_dev, tol) and returns: qml