class_docstr: Tests for the custom_decomps argument for devices
class_docstr_tok: ["Tests","for","the","custom_decomps","argument","for","devices"]
docstr: Test that gradients are still correctly computed after a decomposition
  that performs transpilation.
docstr_tok: ["Test","that","gradients","are","still","correctly","computed","after","a","decomposition","that","performs","transpilation","."]
code: def test_one_custom_decomp_gradient(self, device_name):
      """Test that gradients are still correctly computed after a decomposition
      that performs transpilation."""
  
      def circuit(x):
          qml.Hadamard(wires=0)
          qml.Rot(x[0], x[1], x[2], wires=0)
          qml.Hadamard(wires=0)
          return qml.expval(qml.PauliZ(0))
  
      original_dev = qml.device(device_name, wires=3)
      decomp_dev = qml.device(
          device_name, wires=3, custom_decomps={"Rot": custom_rot}
      )
  
      original_qnode = qml.QNode(
          circuit, original_dev, expansion_strategy="device"
      )
      decomp_qnode = qml.QNode(
          circuit, decomp_dev, expansion_strategy="device"
      )
  
      x = qml.numpy.array([0.2, 0.3, 0.4], requires_grad=True)
  
      original_res = original_qnode(x)
      decomp_res = decomp_qnode(x)
      assert np.allclose(original_res, decomp_res)
  
      original_grad = qml.grad(original_qnode)(x)
      decomp_grad = qml.grad(decomp_qnode)(x)
      assert np.allclose(original_grad, decomp_grad)
  
      expected_ops = [
          "Hadamard",
          "RZ",
          "PauliX",
          "RY",
          "PauliX",
          "RZ",
          "Hadamard",
      ]
      assert all(
          op.name == name
          for op, name in zip(
              decomp_qnode.qtape.operations, expected_ops
          )
      )
  
imports: import pytest
  import numpy
  import pennylane
  from pennylane.wires import Wires
label_desc: Use image node_id 6 for calling the TestCreateCustomDecompExpandFn obj's underlying member method code with example usage: obj.test_one_custom_decomp_gradient(device_name) and returns: qml