class_docstr: Unit tests for the _batch_transform helper function.
class_docstr_tok: ["Unit","tests","for","the","_batch_transform","helper","function","."]
docstr: Test that preprocess returns the correct tapes when splitting and expanding
  is needed.
docstr_tok: ["Test","that","preprocess","returns","the","correct","tapes","when","splitting","and","expanding","is","needed","."]
code: def test_split_and_expand_performed(self):
      """Test that preprocess returns the correct tapes when splitting and expanding
      is needed."""
  
      class NoMatOp(qml.operation.Operation):
          """Dummy operation for expanding circuit."""
  
          # pylint: disable=missing-function-docstring
          num_wires = 1
  
          # pylint: disable=arguments-renamed, invalid-overridden-method
          @property
          def has_matrix(self):
              return False
  
          def decomposition(self):
              return [qml.PauliX(self.wires), qml.PauliY(self.wires)]
  
      ops = [
          qml.Hadamard(0),
          NoMatOp(1),
          qml.RX([np.pi, np.pi / 2], wires=1),
      ]
      # Need to specify grouping type to transform tape
      measurements = [
          qml.expval(qml.PauliX(0)),
          qml.expval(qml.PauliZ(1)),
      ]
      tapes = [
          qml.tape.QuantumScript(
              ops=ops, measurements=[measurements[0]]
          ),
          qml.tape.QuantumScript(
              ops=ops, measurements=[measurements[1]]
          ),
      ]
  
      dev = DefaultQubit()
      config = qml.devices.ExecutionConfig(gradient_method="adjoint")
  
      program, new_config = dev.preprocess(config)
      res_tapes, batch_fn = program(tapes)
      expected_ops = [
          [
              qml.Hadamard(0),
              qml.PauliX(1),
              qml.PauliY(1),
              qml.RX(np.pi, wires=1),
          ],
          [
              qml.Hadamard(0),
              qml.PauliX(1),
              qml.PauliY(1),
              qml.RX(np.pi / 2, wires=1),
          ],
      ]
  
      assert len(res_tapes) == 4
      for i, t in enumerate(res_tapes):
          for op, expected_op in zip(t.operations, expected_ops[i % 2]):
              assert qml.equal(op, expected_op)
          assert len(t.measurements) == 1
          if i < 2:
              assert qml.equal(t.measurements[0], measurements[0])
          else:
              assert qml.equal(t.measurements[0], measurements[1])
  
      input = ([[1, 2]], [[3, 4]], [[5, 6]], [[7, 8]])
      assert np.array_equal(
          batch_fn(input),
          np.array([[[1, 2], [3, 4]], [[5, 6], [7, 8]]]),
      )
  
      assert new_config.grad_on_execution
      assert new_config.use_device_gradient
  
file_path: pennylane/tests/interfaces/default_qubit_2_integration/test_execute_default_qubit_2.py
imports: import pytest
  import pennylane
  from pennylane import numpy
  from pennylane.workflow.execution import _preprocess_expand_fn
  from pennylane.devices import DefaultQubit
label_desc: Use image node_id 2 for calling the TestBatchTransformHelper obj's underlying member method code with example usage: obj.test_split_and_expand_performed() and returns: False, list