class_docstr: Non differentiability tests for the transform program keyword argument.
docstr: Test a transform program with two transforms where their order affects the output.
docstr_tok: ["Test","a","transform","program","with","two","transforms","where","their","order","affects","the","output","."]
code: def test_chained_preprocessing(self):
      """Test a transform program with two transforms where their order affects the output."""
  
      dev = qml.device("default.qubit.legacy", wires=2)
  
      def null_postprocessing(results):
          return results[0]
  
      def just_pauli_x_out(
          tape: qml.tape.QuantumTape,
      ) -> (Tuple[qml.tape.QuantumTape], Callable):
          return (
              qml.tape.QuantumScript(
                  [qml.PauliX(0)], tape.measurements
              ),
          ), null_postprocessing
  
      def repeat_operations(
          tape: qml.tape.QuantumTape,
      ) -> (Tuple[qml.tape.QuantumTape], Callable):
          new_tape = qml.tape.QuantumScript(
              tape.operations + copy.deepcopy(tape.operations),
              tape.measurements,
          )
          return (new_tape,), null_postprocessing
  
      just_pauli_x_container = qml.transforms.core.TransformContainer(
          just_pauli_x_out
      )
      repeat_operations_container = (
          qml.transforms.core.TransformContainer(repeat_operations)
      )
  
      prog = qml.transforms.core.TransformProgram(
          (just_pauli_x_container, repeat_operations_container)
      )
  
      tape1 = qml.tape.QuantumScript(
          [qml.RX(1.2, 0)], [qml.expval(qml.PauliZ(0))]
      )
  
      with dev.tracker:
          results = qml.execute((tape1,), dev, transform_program=prog)
  
      assert (
          dev.tracker.history["resources"][0].gate_types["PauliX"] == 2
      )
      assert qml.math.allclose(results, 1.0)
  
      prog_reverse = qml.transforms.core.TransformProgram(
          (repeat_operations_container, just_pauli_x_container)
      )
  
      with dev.tracker:
          results = qml.execute(
              (tape1,), dev, transform_program=prog_reverse
          )
  
      assert (
          dev.tracker.history["resources"][0].gate_types["PauliX"] == 1
      )
      assert qml.math.allclose(results, -1.0)
  
file_path: pennylane/tests/interfaces/test_transform_program_integration.py
imports: import copy
  from typing import Tuple, Callable
  from functools import partial
  import pytest
  import numpy
  import pennylane
label_desc: Use image node_id 5 for calling the TestTransformProgram obj's underlying member method code with example usage: obj.test_chained_preprocessing() and returns: results, qml,  null_postprocessing, new_tape,  null_postprocessing