class_docstr: Tests for purity transform
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_state(x):
          qml.IsingXX(x, wires=[0, 1])
          return qml.state()
  
      expected_grad = (
          expected_purity_grad_ising_xx(param) if is_partial else 0
      )
  
      param = torch.tensor(
          param, dtype=torch.float64, requires_grad=True
      )
      purity = qml.qinfo.purity(circuit_state, wires=wires)(param)
      purity.backward()
      grad_purity = param.grad
  
      assert qml.math.allclose(grad_purity, expected_grad)
  
imports: import pytest
  import pennylane
  from pennylane import numpy
label_desc: Use image node_id 13 for calling the TestPurity 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