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 free parameters inside an array passed to an Operation yield correct gradients.
docstr_tok: ["Tests","that","free","parameters","inside","an","array","passed","to","an","Operation","yield","correct","gradients","."]
code: def test_cv_gradients_parameters_inside_array(
      self, gaussian_dev, tol
  ):
      "Tests that free parameters inside an array passed to an Operation yield correct gradients."
      import jax
  
      par = jax.numpy.array([0.4, 1.3])
  
      @qml.qnode(device=gaussian_dev, diff_method="finite-diff")
      def qf(x, y):
          qml.Displacement(0.5, 0, wires=[0])
          qml.Squeezing(x, 0, wires=[0])
          M = np.zeros((5, 5))
          M[1, 1] = y
          M[1, 2] = 1.0
          M[2, 1] = 1.0
          return qml.expval(qml.PolyXP(M, [0, 1]))
  
      grad_F = jax.grad(qf)(*par)
  
      @qml.qnode(
          device=gaussian_dev,
          diff_method="parameter-shift",
          force_order2=True,
      )
      def qf2(x, y):
          qml.Displacement(0.5, 0, wires=[0])
          qml.Squeezing(x, 0, wires=[0])
          M = np.zeros((5, 5))
          M[1, 1] = y
          M[1, 2] = 1.0
          M[2, 1] = 1.0
          return qml.expval(qml.PolyXP(M, [0, 1]))
  
      grad_A2 = jax.grad(qf2)(*par)
  
      # the different methods agree
      assert grad_A2 == pytest.approx(grad_F, abs=tol)
  
imports: import pytest
  import autograd
  import numpy
  import pennylane.numpy
  import pennylane
label_desc: Use image node_id 9 for calling the TestCVGradient obj's underlying member method code with example usage: obj.test_cv_gradients_parameters_inside_array(gaussian_dev, tol) and returns: qml, qml