class_docstr: Test tensor expectation values
class_docstr_tok: ["Test","tensor","expectation","values"]
docstr: Test that a tensor product involving an Hermitian matrix works correctly
docstr_tok: ["Test","that","a","tensor","product","involving","an","Hermitian","matrix","works","correctly"]
code: def test_hermitian(self, shots, theta, phi, varphi, tolerance):
      """Test that a tensor product involving an Hermitian matrix works correctly"""
      dev = qml.device("default.qubit", wires=3, shots=shots)
  
      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(a, b, c):
          ansatz(a, b, c)
          return expval(qml.PauliZ(0) @ qml.Hermitian(A, [1, 2]))
  
      res = circuit(theta, phi, varphi)
      expected = 0.5 * (
          -6 * np.cos(theta) * (np.cos(varphi) + 1)
          - 2
          * np.sin(varphi)
          * (np.cos(theta) + np.sin(phi) - 2 * np.cos(phi))
          + 3 * np.cos(varphi) * np.sin(phi)
          + np.sin(phi)
      )
  
      assert np.allclose(res, expected, **tolerance)
  
imports: import functools
  import pytest
  import numpy
  import pennylane
  from pennylane import expval, var, sample
label_desc: Use image node_id 8 for calling the TestTensorExpval obj's underlying member method code with example usage: obj.test_hermitian(shots, theta, phi, varphi, tolerance) and returns: expval