class_docstr: Tests for the custom_decomps argument for devices
class_docstr_tok: ["Tests","for","the","custom_decomps","argument","for","devices"]
docstr: Test that alternative expansion depths can be specified.
docstr_tok: ["Test","that","alternative","expansion","depths","can","be","specified","."]
code: def test_custom_decomp_different_depth(self, device_name):
      """Test that alternative expansion depths can be specified."""
  
      # BasicEntanglerLayers custom decomposition involves AngleEmbedding. If
      # expansion depth is 2, the AngleEmbedding will still be decomposed into
      # RX (since it's not a supported operation on the device), but the RX will
      # not be further decomposed even though the custom decomposition is specified.
      custom_decomps = {
          "BasicEntanglerLayers": custom_basic_entangler_layers,
          "RX": custom_rx,
      }
  
      decomp_dev_2 = qml.device(
          device_name,
          wires=2,
          custom_decomps=custom_decomps,
          decomp_depth=2,
      )
  
      decomp_dev_3 = qml.device(
          device_name,
          wires=2,
          custom_decomps=custom_decomps,
          decomp_depth=3,
      )
  
      def circuit():
          qml.BasicEntanglerLayers([[0.1, 0.2]], wires=[0, 1])
          return qml.expval(qml.PauliZ(0))
  
      circuit2 = qml.QNode(
          circuit, decomp_dev_2, expansion_strategy="device"
      )
      circuit3 = qml.QNode(
          circuit, decomp_dev_3, expansion_strategy="device"
      )
  
      _ = circuit2()
      _ = circuit3()
  
      decomp_ops = circuit2.tape.operations
  
      assert len(decomp_ops) == 3
  
      assert decomp_ops[0].name == "RX"
      assert np.isclose(decomp_ops[0].parameters[0], 0.1)
      assert decomp_ops[0].wires == Wires(0)
  
      assert decomp_ops[1].name == "RX"
      assert np.isclose(decomp_ops[1].parameters[0], 0.2)
      assert decomp_ops[1].wires == Wires(1)
  
      assert decomp_ops[2].name == "CNOT"
      assert decomp_ops[2].wires == Wires([0, 1])
  
      decomp_ops = circuit3.tape.operations
      assert len(decomp_ops) == 5
  
imports: import pytest
  import numpy
  import pennylane
  from pennylane.wires import Wires
label_desc: Use image node_id 10 for calling the TestCreateCustomDecompExpandFn obj's underlying member method code with example usage: obj.test_custom_decomp_different_depth(device_name) and returns: qml