class_docstr: Tests for VQE with interfaces.
class_docstr_tok: ["Tests","for","VQE","with","interfaces","."]
docstr: Tests for the TF interface
docstr_tok: ["Tests","for","the","TF","interface"]
code: def test_gradient_tf(self, tol):
      """Tests for the TF interface"""
      import tensorflow as tf
  
      dev = qml.device("default.qubit", wires=1)
  
      def ansatz(params, **kwargs):
          qml.RX(params[0], wires=0)
          qml.RY(params[1], wires=0)
  
      coeffs = [0.2, 0.5]
      observables = [qml.PauliX(0), qml.PauliY(0)]
  
      H = qml.Hamiltonian(coeffs, observables)
      a, b = 0.54, 0.123
      params = tf.Variable([a, b], dtype=tf.float64)
      cost = catch_warn_ExpvalCost(ansatz, H, dev, interface="tf")
  
      with tf.GradientTape() as tape:
          loss = cost(params)
          res = np.array(tape.gradient(loss, params))
  
      expected = [
          -coeffs[0] * np.sin(a) * np.sin(b) - coeffs[1] * np.cos(a),
          coeffs[0] * np.cos(a) * np.cos(b),
      ]
  
      assert np.allclose(res, expected, atol=tol, rtol=0)
  
imports: import copy
  import numpy
  import pytest
  import pennylane
  from pennylane import numpy
label_desc: Use image node_id 3 for calling the TestInterfaces obj's underlying member method code with example usage: obj.test_gradient_tf(tol) without return types