class_docstr: Test tensor expectation values
class_docstr_tok: ["Test","tensor","expectation","values"]
docstr: Test that a tensor product involving an Hermitian matrix and the identity works correctly
docstr_tok: ["Test","that","a","tensor","product","involving","an","Hermitian","matrix","and","the","identity","works","correctly"]
code: def test_hermitian_tensor_identity_expectation(
      self, shots, theta, phi, varphi, tolerance
  ):
      """Test that a tensor product involving an Hermitian matrix and the identity works correctly"""
      dev = qml.device("default.qubit", wires=2, shots=shots)
  
      A = np.array(
          [
              [1.02789352, 1.61296440 - 0.3498192j],
              [1.61296440 + 0.3498192j, 1.23920938 + 0j],
          ]
      )
  
      # pylint: disable=unused-argument
      @qml.qnode(dev)
      def circuit(a, b, c):
          qml.RY(a, wires=0)
          qml.RY(b, wires=1)
          qml.CNOT(wires=[0, 1])
          return expval(qml.Hermitian(A, 0) @ qml.Identity(1))
  
      res = circuit(theta, phi, varphi)
  
      a = A[0, 0]
      re_b = A[0, 1].real
      d = A[1, 1]
      expected = (
          (a - d) * np.cos(theta)
          + 2 * re_b * np.sin(theta) * np.sin(phi)
          + a
          + d
      ) / 2
  
      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 10 for calling the TestTensorExpval obj's underlying member method code with example usage: obj.test_hermitian_tensor_identity_expectation(shots, theta, phi, varphi, tolerance) and returns: expval