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 gates with multiple free parameters yield correct gradients.
docstr_tok: ["Tests","that","gates","with","multiple","free","parameters","yield","correct","gradients","."]
code: def test_cv_gradients_multiple_gate_parameters(
      self, gaussian_dev, tol
  ):
      "Tests that gates with multiple free parameters yield correct gradients."
      par = anp.array([0.4, -0.3, -0.7, 0.2], requires_grad=True)
  
      def qf(r0, phi0, r1, phi1):
          qml.Squeezing(r0, phi0, wires=[0])
          qml.Squeezing(r1, phi1, wires=[0])
          return qml.expval(qml.NumberOperator(0))
  
      q = qml.QNode(qf, gaussian_dev)
      q(*par)
      grad_F = qml.gradients.finite_diff(q)(*par)
      grad_A = qml.gradients.param_shift_cv(q, dev=gaussian_dev)(*par)
      grad_A2 = qml.gradients.param_shift_cv(
          q, dev=gaussian_dev, force_order2=True
      )(*par)
  
      # the different methods agree
      assert qml.math.allclose(grad_A, grad_F, atol=tol, rtol=0)
      assert qml.math.allclose(grad_A2, grad_F, atol=tol, rtol=0)
  
      # check against the known analytic formula
      r0, phi0, r1, phi1 = par
      dn = np.zeros([4])
      dn[0] = np.cosh(2 * r1) * np.sinh(2 * r0) + np.cos(
          phi0 - phi1
      ) * np.cosh(2 * r0) * np.sinh(2 * r1)
      dn[1] = (
          -0.5 * np.sin(phi0 - phi1) * np.sinh(2 * r0) * np.sinh(2 * r1)
      )
      dn[2] = np.cos(phi0 - phi1) * np.cosh(2 * r1) * np.sinh(
          2 * r0
      ) + np.cosh(2 * r0) * np.sinh(2 * r1)
      dn[3] = (
          0.5 * np.sin(phi0 - phi1) * np.sinh(2 * r0) * np.sinh(2 * r1)
      )
  
      assert all(
          qml.math.isclose(dn[i], grad_F[i], atol=tol, rtol=0)
          for i in range(4)
      )
  
imports: import pytest
  import autograd
  import numpy
  import pennylane.numpy
  import pennylane
label_desc: Use image node_id 7 for calling the TestCVGradient obj's underlying member method code with example usage: obj.test_cv_gradients_multiple_gate_parameters(gaussian_dev, tol) and returns: qml