class_docstr: Tests for the custom_decomps argument for devices
class_docstr_tok: ["Tests","for","the","custom_decomps","argument","for","devices"]
docstr: Test that specifying two custom decompositions that have interdependence
  works as expected.
docstr_tok: ["Test","that","specifying","two","custom","decompositions","that","have","interdependence","works","as","expected","."]
code: def test_nested_custom_decomp(self, device_name):
      """Test that specifying two custom decompositions that have interdependence
      works as expected."""
  
      custom_decomps = {
          "Hadamard": custom_hadamard,
          qml.CNOT: custom_cnot,
      }
      decomp_dev = qml.device(
          device_name, wires=2, custom_decomps=custom_decomps
      )
  
      @qml.qnode(decomp_dev, expansion_strategy="device")
      def circuit():
          qml.Hadamard(wires=0)
          qml.CNOT(wires=[0, 1])
          return qml.expval(qml.PauliZ(0))
  
      _ = circuit()
      decomp_ops = circuit.tape.operations
  
      assert len(decomp_ops) == 7
  
      # Check the RZ gates are in the correct place
      for idx in [0, 2, 5]:
          assert decomp_ops[idx].name == "RZ"
          assert np.isclose(decomp_ops[idx].parameters[0], np.pi)
  
      assert decomp_ops[0].wires == Wires(0)
      assert decomp_ops[2].wires == Wires(1)
      assert decomp_ops[5].wires == Wires(1)
  
      # Check RY are in the correct place
      for idx in [1, 3, 6]:
          assert decomp_ops[idx].name == "RY"
          assert np.isclose(decomp_ops[idx].parameters[0], np.pi / 2)
  
      assert decomp_ops[1].wires == Wires(0)
      assert decomp_ops[3].wires == Wires(1)
      assert decomp_ops[6].wires == Wires(1)
  
      assert decomp_ops[4].name == "CZ"
  
imports: import pytest
  import numpy
  import pennylane
  from pennylane.wires import Wires
label_desc: Use image node_id 7 for calling the TestCreateCustomDecompExpandFn obj's underlying member method code with example usage: obj.test_nested_custom_decomp(device_name) and returns: qml