class_docstr: Tests for the quantum gradients of various gates
  with expectation value output
docstr: An integration test for CV gates that support analytic differentiation
  if succeeding the gate to be differentiated, but cannot be differentiated
  themselves (for example, they may be Gaussian but accept no parameters,
  or may accept a numerical array parameter.).
  
  This ensures that, assuming their _heisenberg_rep is defined, the quantum
  gradient analytic method can still be used, and returns the correct result.
  
  Currently, the only such operation is qml.InterferometerUnitary. In the future,
  we may consider adding a qml.GaussianTransfom operator.
docstr_tok: ["An","integration","test","for","CV","gates","that","support","analytic","differentiation","if","succeeding","the","gate","to","be","differentiated",",","but","can","not","be","differentiated","themselves","(","for","example",",","they","may","be","Gaussian","but","accept","no","parameters",",","or","may","accept","a","numerical","array","parameter.",")",".","This","ensures","that",",","assuming","their","_heisenberg_rep","is","defined",",","the","quantum","gradient","analytic","method","can","still","be","used",",","and","returns","the","correct","result",".","Currently",",","the","only","such","operation","is","qml.InterferometerUnitary",".","In","the","future",",","we","may","consider","adding","a","qml.GaussianTransfom","operator","."]
code: def test_interferometer_unitary(self, mocker, t, tol):
      """An integration test for CV gates that support analytic differentiation
      if succeeding the gate to be differentiated, but cannot be differentiated
      themselves (for example, they may be Gaussian but accept no parameters,
      or may accept a numerical array parameter.).
  
      This ensures that, assuming their _heisenberg_rep is defined, the quantum
      gradient analytic method can still be used, and returns the correct result.
  
      Currently, the only such operation is qml.InterferometerUnitary. In the future,
      we may consider adding a qml.GaussianTransfom operator.
      """
  
      if t == 1:
          pytest.xfail(
              "There is a bug in the second order CV parameter-shift rule; "
              "phase arguments return the incorrect derivative."
          )
  
          # Note: this bug currently affects PL core as well:
          #
          # dev = qml.device("default.gaussian", wires=2)
          #
          # U = np.array([[ 0.51310276+0.81702166j,  0.13649626+0.22487759j],
          #         [ 0.26300233+0.00556194j, -0.96414101-0.03508489j]])
          #
          # @qml.qnode(dev)
          # def circuit(r, phi):
          #     qml.Displacement(r, phi, wires=0)
          #     qml.InterferometerUnitary(U, wires=[0, 1])
          #     return qml.expval(qml.QuadX(0))
          #
          # r = 0.543
          # phi = 0.
          #
          # >>> print(circuit.jacobian([r, phi], options={"force_order2":False}))
          # [[ 1.02620552 0.14823494]]
          # >>> print(circuit.jacobian([r, phi], options={"force_order2":True}))
          # [[ 1.02620552 -0.88728552]]
  
      U = np.array(
          [
              [0.51310276 + 0.81702166j, 0.13649626 + 0.22487759j],
              [0.26300233 + 0.00556194j, -0.96414101 - 0.03508489j],
          ],
          requires_grad=False,
      )
  
      with qml.queuing.AnnotatedQueue() as q:
          qml.Displacement(0.543, 0, wires=0)
          qml.InterferometerUnitary(U, wires=[0, 1])
          qml.expval(qml.QuadX(0))
  
      tape = qml.tape.QuantumScript.from_queue(q)
      tape.trainable_params = {t}
  
      dev = qml.device("default.gaussian", wires=2)
  
      spy = mocker.spy(
          qml.gradients.parameter_shift_cv, "_find_gradient_methods_cv"
      )
  
      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 spy.spy_return[0] == "A"
  
      # the different methods agree
      assert np.allclose(grad_A, grad_F, atol=tol, rtol=0)
      assert np.allclose(grad_A2, grad_F, atol=tol, rtol=0)
  
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 9 for calling the TestExpectationQuantumGradients obj's underlying member method code with example usage: obj.test_interferometer_unitary(mocker, t, tol) without return types