class_docstr: Test that the TrotterProduct can be executed and differentiated
  through all interfaces.
class_docstr_tok: ["Test","that","the","TrotterProduct","can","be","executed","and","differentiated","through","all","interfaces","."]
docstr: Test that the gradient is computed correctly using tensorflow
docstr_tok: ["Test","that","the","gradient","is","computed","correctly","using","tensorflow"]
code: def test_tf_gradient(self, order, n):
      """Test that the gradient is computed correctly using tensorflow"""
      import tensorflow as tf
  
      time = tf.Variable(1.5, dtype=tf.complex128)
      coeffs = tf.Variable([1.23, -0.45], dtype=tf.complex128)
      terms = [qml.PauliX(0), qml.PauliZ(0)]
  
      dev = qml.device("default.qubit", wires=1)
  
      @qml.qnode(dev)
      def circ(time, coeffs):
          h = qml.sum(
              qml.s_prod(coeffs[0], terms[0]),
              qml.s_prod(coeffs[1], terms[1]),
          )
          qml.TrotterProduct(h, time, n=n, order=order)
          return qml.expval(qml.Hadamard(0))
  
      @qml.qnode(dev)
      def reference_circ(time, coeffs):
          with qml.QueuingManager.stop_recording():
              decomp = _generate_simple_decomp(
                  coeffs, terms, time, order, n
              )
  
          for op in decomp[::-1]:
              qml.apply(op)
  
          return qml.expval(qml.Hadamard(0))
  
      with tf.GradientTape() as tape:
          result = circ(time, coeffs)
  
      measured_time_grad, measured_coeff_grad = tape.gradient(
          result, (time, coeffs)
      )
  
      with tf.GradientTape() as tape:
          result = reference_circ(time, coeffs)
  
      reference_time_grad, reference_coeff_grad = tape.gradient(
          result, (time, coeffs)
      )
      assert allclose(measured_time_grad, reference_time_grad)
      assert allclose(measured_coeff_grad, reference_coeff_grad)
  
imports: import copy
  from functools import reduce
  import pytest
  import pennylane
  from pennylane import numpy
  from pennylane.math import allclose, get_interface
  from pennylane.templates.subroutines.trotter import _recursive_expression, _scalar
label_desc: Use image node_id 10 for calling the TestIntegration obj's underlying member method code with example usage: obj.test_tf_gradient(order, n) and returns: qml, qml