class_docstr: Test tensor expectation values
class_docstr_tok: ["Test","tensor","expectation","values"]
docstr: Test that a tensor product involving two Hermitian matrices works correctly
docstr_tok: ["Test","that","a","tensor","product","involving","two","Hermitian","matrices","works","correctly"]
code: def test_hermitian_tensor_hermitian(
      self, shots, theta, phi, varphi, tolerance
  ):
      """Test that a tensor product involving two Hermitian matrices works correctly"""
      dev = qml.device("default.qubit", wires=3, shots=shots)
  
      A1 = np.array([[1, 2], [2, 4]])
  
      A2 = 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.Hermitian(A1, 0) @ qml.Hermitian(A2, [1, 2])
          )
  
      res = circuit(theta, phi, varphi)
      expected = 0.25 * (
          -30
          + 4 * np.cos(phi) * np.sin(theta)
          + 3
          * np.cos(varphi)
          * (-10 + 4 * np.cos(phi) * np.sin(theta) - 3 * np.sin(phi))
          - 3 * np.sin(phi)
          - 2
          * (
              5
              + np.cos(phi) * (6 + 4 * np.sin(theta))
              + (-3 + 8 * np.sin(theta)) * np.sin(phi)
          )
          * np.sin(varphi)
          + np.cos(theta)
          * (
              18
              + 5 * np.sin(phi)
              + 3 * np.cos(varphi) * (6 + 5 * np.sin(phi))
              + 2
              * (3 + 10 * np.cos(phi) - 5 * np.sin(phi))
              * np.sin(varphi)
          )
      )
  
      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 9 for calling the TestTensorExpval obj's underlying member method code with example usage: obj.test_hermitian_tensor_hermitian(shots, theta, phi, varphi, tolerance) and returns: expval