class_docstr: Tests for the finite difference gradient transform
class_docstr_tok: ["Tests","for","the","finite","difference","gradient","transform"]
docstr: Tests correct output shape and evaluation for a tape
  with expval and var outputs
code: def test_var_expectation_values(
      self, approx_order, strategy, validate, tol
  ):
      """Tests correct output shape and evaluation for a tape
      with expval and var outputs"""
      dev = qml.device("default.qubit", wires=2)
      x = 0.543
      y = -0.654
  
      with qml.queuing.AnnotatedQueue() as q:
          qml.RX(x, wires=[0])
          qml.RY(y, wires=[1])
          qml.CNOT(wires=[0, 1])
          qml.expval(qml.PauliZ(0))
          qml.var(qml.PauliX(1))
  
      tape = qml.tape.QuantumScript.from_queue(q)
      tapes, fn = finite_diff(
          tape,
          approx_order=approx_order,
          strategy=strategy,
          validate_params=validate,
      )
      res = fn(dev.execute(tapes))
  
      assert isinstance(res, tuple)
      assert len(res) == 2
  
      assert isinstance(res[0], tuple)
      assert len(res[0]) == 2
      assert np.allclose(res[0], [-np.sin(x), 0], atol=tol, rtol=0)
      assert isinstance(res[0][0], numpy.ndarray)
      assert isinstance(res[0][1], numpy.ndarray)
  
      assert isinstance(res[1], tuple)
      assert len(res[1]) == 2
      assert np.allclose(
          res[1], [0, -2 * np.cos(y) * np.sin(y)], atol=tol, rtol=0
      )
      assert isinstance(res[1][0], numpy.ndarray)
      assert isinstance(res[1][1], numpy.ndarray)
  
imports: import numpy
  import pytest
  import pennylane
  from pennylane import numpy
  from pennylane.devices import DefaultQubitLegacy
  from pennylane.gradients import finite_diff, finite_diff_coeffs
  from pennylane.operation import AnyWires, Observable
label_desc: Use image node_id 7 for calling the TestFiniteDiffIntegration obj's underlying member method code with example usage: obj.test_var_expectation_values(approx_order, strategy, validate, tol) without return types