class_docstr: Tests for variance of tensor observables
class_docstr_tok: ["Tests","for","variance","of","tensor","observables"]
docstr: Test that a tensor product involving qml.Hermitian works correctly
docstr_tok: ["Test","that","a","tensor","product","involving","qml.Hermitian","works","correctly"]
code: def test_tensor_hermitian(self, shots, theta, phi, varphi, tolerance):
      """Test that a tensor product involving qml.Hermitian 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 var(qml.PauliZ(0) @ qml.Hermitian(A, [1, 2]))
  
      res = circuit(theta, phi, varphi)
      expected = (
          1057
          - np.cos(2 * phi)
          + 12 * (27 + np.cos(2 * phi)) * np.cos(varphi)
          - 2
          * np.cos(2 * varphi)
          * np.sin(phi)
          * (16 * np.cos(phi) + 21 * np.sin(phi))
          + 16 * np.sin(2 * phi)
          - 8
          * (-17 + np.cos(2 * phi) + 2 * np.sin(2 * phi))
          * np.sin(varphi)
          - 8
          * np.cos(2 * theta)
          * (3 + 3 * np.cos(varphi) + np.sin(varphi)) ** 2
          - 24
          * np.cos(phi)
          * (np.cos(phi) + 2 * np.sin(phi))
          * np.sin(2 * varphi)
          - 8
          * np.cos(theta)
          * (
              4
              * np.cos(phi)
              * (
                  4
                  + 8 * np.cos(varphi)
                  + np.cos(2 * varphi)
                  - (1 + 6 * np.cos(varphi)) * np.sin(varphi)
              )
              + np.sin(phi)
              * (
                  15
                  + 8 * np.cos(varphi)
                  - 11 * np.cos(2 * varphi)
                  + 42 * np.sin(varphi)
                  + 3 * np.sin(2 * varphi)
              )
          )
      ) / 16
  
      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 4 for calling the TestTensorVar obj's underlying member method code with example usage: obj.test_tensor_hermitian(shots, theta, phi, varphi, tolerance) and returns: var