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 prob and expval outputs
docstr_tok: ["Tests","correct","output","shape","and","evaluation","for","a","tape","with","prob","and","expval","outputs"]
code: def test_prob_expectation_values(
      self, approx_order, strategy, validate
  ):
      """Tests correct output shape and evaluation for a tape
      with prob and expval outputs"""
      dev = qml.device(
          "default.qubit", wires=2, shots=many_shots_shot_vector
      )
      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.probs(wires=[0, 1])
  
      tape = qml.tape.QuantumScript.from_queue(
          q, shots=many_shots_shot_vector
      )
      tapes, fn = finite_diff(
          tape,
          approx_order=approx_order,
          strategy=strategy,
          validate_params=validate,
          h=h_val,
      )
      all_res = fn(dev.execute(tapes))
  
      assert isinstance(all_res, tuple)
      assert len(all_res) == len(many_shots_shot_vector)
  
      for res in all_res:
          assert isinstance(res, tuple)
          assert len(res) == 2
  
          assert isinstance(res[0], tuple)
          assert len(res[0]) == 2
          assert np.allclose(res[0][0], -np.sin(x), atol=0.1, rtol=0)
          assert isinstance(res[0][0], numpy.ndarray)
          assert np.allclose(res[0][1], 0, atol=0.1, rtol=0)
          assert isinstance(res[0][1], numpy.ndarray)
  
          assert isinstance(res[1], tuple)
          assert len(res[1]) == 2
          assert np.allclose(
              res[1][0],
              [
                  -(np.cos(y / 2) ** 2 * np.sin(x)) / 2,
                  -(np.sin(x) * np.sin(y / 2) ** 2) / 2,
                  (np.sin(x) * np.sin(y / 2) ** 2) / 2,
                  (np.cos(y / 2) ** 2 * np.sin(x)) / 2,
              ],
              atol=0.07,
              rtol=0,
          )
          assert isinstance(res[1][0], numpy.ndarray)
          assert np.allclose(
              res[1][1],
              [
                  -(np.cos(x / 2) ** 2 * np.sin(y)) / 2,
                  (np.cos(x / 2) ** 2 * np.sin(y)) / 2,
                  (np.sin(x / 2) ** 2 * np.sin(y)) / 2,
                  -(np.sin(x / 2) ** 2 * np.sin(y)) / 2,
              ],
              atol=0.08,
              rtol=0,
          )
          assert isinstance(res[1][1], numpy.ndarray)
  
imports: import numpy
  import pytest
  from pennylane import numpy
  import pennylane
  from pennylane.gradients import finite_diff
  from pennylane.devices import DefaultQubitLegacy
  from pennylane.measurements import Shots
  from pennylane.operation import Observable, AnyWires
label_desc: Use image node_id 8 for calling the TestFiniteDiffIntegration obj's underlying member method code with example usage: obj.test_prob_expectation_values(approx_order, strategy, validate) without return types