class_docstr: Tests for the quantum gradients of various gates
  with variance measurements
docstr: Tests that the gradients of circuits of selected gaussian gates match between the
  finite difference and analytic methods.
docstr_tok: ["Tests","that","the","gradients","of","circuits","of","selected","gaussian","gates","match","between","the","finite","difference","and","analytic","methods","."]
code: def test_gradients_gaussian_circuit(self, mocker, op, obs, tol):
      """Tests that the gradients of circuits of selected gaussian gates match between the
      finite difference and analytic methods."""
      tol = 1e-2
  
      with qml.queuing.AnnotatedQueue() as q:
          qml.Displacement(0.5, 0, wires=0)
          qml.apply(op)
          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)
          qml.var(obs(wires=0))
  
      tape = qml.tape.QuantumScript.from_queue(q)
      dev = qml.device("default.gaussian", wires=2)
  
      tape.trainable_params = set(range(2, 2 + op.num_params))
  
      spy = mocker.spy(
          qml.gradients.parameter_shift_cv, "_find_gradient_methods_cv"
      )
  
      # jacobians must match
      tapes, fn = qml.gradients.finite_diff(tape)
      grad_F = fn(dev.batch_execute(tapes))
  
      tapes, fn = param_shift_cv(tape, dev)
      grad_A = fn(dev.batch_execute(tapes))
  
      tapes, fn = param_shift_cv(tape, dev, force_order2=True)
      grad_A2 = fn(dev.batch_execute(tapes))
  
      assert np.allclose(grad_A2, grad_F, atol=tol, rtol=0)
      assert np.allclose(grad_A, grad_F, atol=tol, rtol=0)
  
      if obs != qml.NumberOperator:
          assert all(m == "A" for m in spy.spy_return.values())
  
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 6 for calling the TestVarianceQuantumGradients obj's underlying member method code with example usage: obj.test_gradients_gaussian_circuit(mocker, op, obs, tol) without return types