class_docstr: Test gradients for a single measurement
class_docstr_tok: ["Test","gradients","for","a","single","measurement"]
docstr: Test derivatives when using TF
docstr_tok: ["Test","derivatives","when","using","TF"]
code: def test_tf(self, diff_method, tol, interface):
      """Test derivatives when using TF"""
      import tensorflow as tf
  
      dev = qml.device("default.qubit", wires=2)
  
      @qml.batch_params
      @qml.qnode(dev, interface=interface, diff_method=diff_method)
      def circuit(x):
          qml.RX(x, wires=0)
          qml.RY(0.1, wires=1)
          qml.CNOT(wires=[0, 1])
          return qml.expval(qml.PauliZ(0) @ qml.PauliX(1))
  
      def cost(x):
          return tf.reduce_sum(circuit(x))
  
      batch_size = 3
      x = tf.Variable(tf.linspace(0.1, 0.5, batch_size))
  
      with tf.GradientTape() as tape:
          loss = cost(x)
  
      res = tape.gradient(loss, x)
      expected = -np.sin(0.1) * tf.sin(x)
      assert np.allclose(res, expected, atol=tol, rtol=0)
  
imports: import functools
  import pytest
  import pennylane
  from pennylane import numpy
label_desc: Use image node_id 5 for calling the TestDiffSingle obj's underlying member method code with example usage: obj.test_tf(diff_method, tol, interface) and returns: qml, tf