class_docstr: Test that the TensorFlow execute function can be differentiated
class_docstr_tok: ["Test","that","the","TensorFlow","execute","function","can","be","differentiated"]
docstr: Test hessian calculation of a vector valued QNode
docstr_tok: ["Test","hessian","calculation","of","a","vector","valued","QNode"]
code: def test_hessian_vector_valued(self, tol, interface):
      """Test hessian calculation of a vector valued QNode"""
      dev = qml.device("default.qubit.tf", wires=1)
      params = tf.Variable([0.543, -0.654], dtype=tf.float64)
  
      with tf.GradientTape() as t2:
          with tf.GradientTape(persistent=True) as t1:
              with qml.queuing.AnnotatedQueue() as q:
                  qml.RY(params[0], wires=0)
                  qml.RX(params[1], wires=0)
                  qml.probs(wires=0)
  
              tape = qml.tape.QuantumScript.from_queue(q)
              res = execute(
                  [tape],
                  dev,
                  gradient_fn=param_shift,
                  interface=interface,
                  max_diff=2,
              )[0]
              res = tf.stack(res)
  
          g = t1.jacobian(res, params, experimental_use_pfor=False)
  
      hess = t2.jacobian(g, params)
  
      a, b = params * 1.0
  
      expected_res = [
          0.5 + 0.5 * tf.cos(a) * tf.cos(b),
          0.5 - 0.5 * tf.cos(a) * tf.cos(b),
      ]
      assert np.allclose(res, expected_res, atol=tol, rtol=0)
  
      expected_g = [
          [-0.5 * tf.sin(a) * tf.cos(b), -0.5 * tf.cos(a) * tf.sin(b)],
          [0.5 * tf.sin(a) * tf.cos(b), 0.5 * tf.cos(a) * tf.sin(b)],
      ]
      assert np.allclose(g, expected_g, atol=tol, rtol=0)
  
      expected_hess = [
          [
              [
                  -0.5 * tf.cos(a) * tf.cos(b),
                  0.5 * tf.sin(a) * tf.sin(b),
              ],
              [
                  0.5 * tf.sin(a) * tf.sin(b),
                  -0.5 * tf.cos(a) * tf.cos(b),
              ],
          ],
          [
              [
                  0.5 * tf.cos(a) * tf.cos(b),
                  -0.5 * tf.sin(a) * tf.sin(b),
              ],
              [
                  -0.5 * tf.sin(a) * tf.sin(b),
                  0.5 * tf.cos(a) * tf.cos(b),
              ],
          ],
      ]
  
      np.testing.assert_allclose(
          hess, expected_hess, atol=tol, rtol=0, verbose=True
      )
  
imports: import numpy
  import pytest
  import pennylane
  from pennylane.gradients import finite_diff, param_shift
  from pennylane import execute
label_desc: Use image node_id 2 for calling the TestHigherOrderDerivatives obj's underlying member method code with example usage: obj.test_hessian_vector_valued(tol, interface) without return types