class_docstr: Tests for the custom_decomps argument for devices
class_docstr_tok: ["Tests","for","the","custom_decomps","argument","for","devices"]
docstr: Test that decomposing a controlled version of a gate uses the custom decomposition
  for the base gate.
docstr_tok: ["Test","that","decomposing","a","controlled","version","of","a","gate","uses","the","custom","decomposition","for","the","base","gate","."]
code: def test_custom_decomp_with_control(self, device_name):
      """Test that decomposing a controlled version of a gate uses the custom decomposition
      for the base gate."""
  
      class CustomOp(qml.operation.Operation):
          num_wires = 1
  
          @staticmethod
          def compute_decomposition(wires):
              return [qml.S(wires)]
  
      original_decomp = CustomOp(0).decomposition()
  
      custom_decomps = {
          CustomOp: lambda wires: [qml.T(wires), qml.T(wires)]
      }
      decomp_dev = qml.device(
          device_name, wires=2, custom_decomps=custom_decomps
      )
  
      @qml.qnode(decomp_dev, expansion_strategy="device")
      def circuit():
          qml.ctrl(CustomOp, control=1)(0)
          return qml.expval(qml.PauliZ(0))
  
      circuit.construct(tuple(), {})
      decomp_ops = circuit.tape.operations
  
      assert len(decomp_ops) == 2
  
      for op in decomp_ops:
          assert isinstance(op, qml.ops.op_math.Controlled)
          assert qml.equal(op.base, qml.T(0))
  
      # check that new instances of the operator are not affected by the modifications made to get the decomposition
      assert [
          op1 == op2
          for op1, op2 in zip(
              CustomOp(0).decomposition(), original_decomp
          )
      ]
  
imports: import pytest
  import numpy
  import pennylane
  from pennylane.wires import Wires
label_desc: Use image node_id 12 for calling the TestCreateCustomDecompExpandFn obj's underlying member method code with example usage: obj.test_custom_decomp_with_control(device_name) and returns: qml, list