class_docstr: Test expectation values
class_docstr_tok: ["Test","expectation","values"]
docstr: Test that arbitrary multi-mode Hermitian expectation values are correct
code: def test_multi_mode_hermitian_expectation(self, device, tol):
      """Test that arbitrary multi-mode Hermitian expectation values are correct"""
      n_wires = 2
      dev = device(n_wires)
  
      if "Hermitian" not in dev.observables:
          pytest.skip(
              "Skipped because device does not support the Hermitian observable."
          )
  
      theta = 0.432
      phi = 0.123
      A_ = np.array(
          [
              [-6, 2 + 1j, -3, -5 + 2j],
              [2 - 1j, 0, 2 - 1j, -5 + 4j],
              [-3, 2 + 1j, 0, -4 + 3j],
              [-5 - 2j, -5 - 4j, -4 - 3j, -6],
          ]
      )
  
      @qml.qnode(dev)
      def circuit():
          qml.RY(theta, wires=[0])
          qml.RY(phi, wires=[1])
          qml.CNOT(wires=[0, 1])
          return qml.expval(qml.Hermitian(A_, wires=[0, 1]))
  
      res = circuit()
  
      # below is the analytic expectation value for this circuit with arbitrary
      # Hermitian observable A
      expected = 0.5 * (
          6 * np.cos(theta) * np.sin(phi)
          - np.sin(theta) * (8 * np.sin(phi) + 7 * np.cos(phi) + 3)
          - 2 * np.sin(phi)
          - 6 * np.cos(phi)
          - 6
      )
  
      assert np.allclose(res, expected, atol=tol(dev.shots))
  
imports: import pytest
  from flaky import flaky
  from scipy.sparse import csr_matrix
  import pennylane
  from pennylane import numpy
  from pennylane.measurements import ClassicalShadowMP, MeasurementTransform, SampleMeasurement, SampleMP, StateMeasurement, StateMP
label_desc: Use image node_id 8 for calling the TestExpval obj's underlying member method code with example usage: obj.test_multi_mode_hermitian_expectation(device, tol) and returns: qml