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 torch.
docstr_tok: ["Test","purity","for","a","QNode","gradient","with","torch","."]
code: def test_IsingXX_qnode_purity_grad_torch(
      self, device, param, wires, is_partial, diff_method, interface
  ):
      """Test purity for a QNode gradient with torch."""
  
      import torch
  
      dev = qml.device(device, 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)
  
      expected_grad = (
          expected_purity_grad_ising_xx(param) if is_partial else 0
      )
  
      param = torch.tensor(
          param, dtype=torch.float64, requires_grad=True
      )
      purity = circuit(param)
      purity.backward()  # pylint: disable=no-member
      grad_purity = param.grad
  
      assert qml.math.allclose(
          grad_purity, expected_grad, rtol=1e-04, atol=1e-05
      )
  
imports: import pytest
  import numpy
  import pennylane
  from pennylane.measurements import PurityMP, 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_torch(device, param, wires, is_partial, diff_method, interface) and returns: qml