class_docstr: Test the purity meausrement with qnodes and devices.
class_docstr_tok: ["Test","the","purity","meausrement","with","qnodes","and","devices","."]
docstr: Test purity for a QNode gradient with tf.
docstr_tok: ["Test","purity","for","a","QNode","gradient","with","tf","."]
code: def test_IsingXX_qnode_purity_grad_tf(
      self, param, wires, is_partial, diff_method, interface
  ):
      """Test purity for a QNode gradient with tf."""
  
      import tensorflow as tf
  
      dev = qml.device("default.qubit.legacy", wires=2)
  
      @qml.qnode(dev, interface=interface, diff_method=diff_method)
      def circuit(x):
          qml.IsingXX(x, wires=[0, 1])
          return qml.purity(wires=wires)
  
      grad_expected_purity = (
          expected_purity_grad_ising_xx(param) if is_partial else 0
      )
  
      param = tf.Variable(param)
      with tf.GradientTape() as tape:
          purity = circuit(param)
  
      grad_purity = tape.gradient(purity, param)
  
      assert qml.math.allclose(
          grad_purity, grad_expected_purity, rtol=1e-04, atol=1e-05
      )
  
file_path: pennylane/tests/measurements/legacy/test_purity_measurement_legacy.py
imports: import pytest
  import numpy
  import pennylane
  from pennylane.measurements import Shots
label_desc: Use image node_id 10 for calling the TestPurityIntegration obj's underlying member method code with example usage: obj.test_IsingXX_qnode_purity_grad_tf(param, wires, is_partial, diff_method, interface) and returns: qml