class_docstr: Tests for the behavior of the `decompose` helper.
class_docstr_tok: ["Tests","for","the","behavior","of","the","`","decompose","`","helper","."]
docstr: Test that the decompose only expands mid-circuit instances of StatePrepBase if requested.
docstr_tok: ["Test","that","the","decompose","only","expands","mid-circuit","instances","of","StatePrepBase","if","requested","."]
code: def test_decompose_state_prep_skip_first(self, prep_op):
      """Test that the decompose only expands mid-circuit instances of StatePrepBase if requested."""
      ops = [
          prep_op,
          qml.Hadamard(wires=0),
          qml.StatePrep([0, 1], wires=1),
          qml.BasisState([1], wires=0),
          qml.RZ(0.123, wires=1),
          qml.AmplitudeEmbedding([0, 1, 0, 0], wires=[0, 1]),
      ]
      measurements = [qml.expval(qml.PauliZ(0)), qml.probs()]
      tape = QuantumScript(ops=ops, measurements=measurements)
  
      expanded_tapes, _ = decompose(
          tape, lambda obj: obj.has_matrix, skip_initial_state_prep=True
      )
      expanded_tape = expanded_tapes[0]
      expected = [
          prep_op,
          qml.Hadamard(0),
          qml.RY(3.14159265, wires=1),  # decomposition of StatePrep
          qml.PauliX(wires=0),  # decomposition of BasisState
          qml.RZ(0.123, wires=1),
          qml.RY(
              1.57079633, wires=[1]
          ),  # decomposition of AmplitudeEmbedding
          qml.CNOT(wires=[0, 1]),
          qml.RY(1.57079633, wires=[1]),
          qml.CNOT(wires=[0, 1]),
      ]
  
      assert expanded_tape.circuit == expected + measurements
  
imports: import pytest
  import pennylane
  from pennylane.operation import Operation
  from pennylane.tape import QuantumScript
  from pennylane import DeviceError
  from pennylane.devices.preprocess import no_sampling, validate_device_wires, validate_multiprocessing_workers, validate_adjoint_trainable_params, _operator_decomposition_gen, decompose, validate_observables, validate_measurements
label_desc: Use image node_id 4 for calling the TestDecomposeTransformations obj's underlying member method code with example usage: obj.test_decompose_state_prep_skip_first(prep_op) without return types