class_docstr: Unit tests for the batch_transform class
class_docstr_tok: ["Unit","tests","for","the","batch_transform","class"]
docstr: Test that kwargs are respected in the expansion.
docstr_tok: ["Test","that","kwargs","are","respected","in","the","expansion","."]
code: def test_expand_qnode_with_kwarg(self, mocker, perform_expansion):
      """Test that kwargs are respected in the expansion."""
  
      class MyTransform:
          """Dummy class to allow spying to work"""
  
          # pylint: disable=unused-argument
  
          def my_transform(self, tape, **kwargs):
              tape1 = tape.copy()
              tape2 = tape.copy()
              return [tape1, tape2], None
  
      spy_transform = mocker.spy(MyTransform, "my_transform")
      transform_fn = qml.batch_transform(
          MyTransform().my_transform,
          expand_fn=self.expand_logic_with_kwarg,
      )
  
      spy_expand = mocker.spy(transform_fn, "expand_fn")
      dev = qml.device("default.qubit", wires=2)
  
      @functools.partial(
          transform_fn, perform_expansion=perform_expansion
      )
      @qml.qnode(dev)
      def qnode(x):
          # pylint: disable=unused-argument
          qml.PhaseShift(0.5, wires=0)
          return qml.expval(qml.PauliX(0))
  
      qnode(0.2)
  
      spy_transform.assert_called()
      spy_expand.assert_called()  # The expand_fn of transform_fn always is called
      input_tape = spy_transform.call_args[0][1]
  
      if perform_expansion:
          assert len(input_tape.operations) == 2
          assert input_tape.operations[0].name == "RZ"
          assert input_tape.operations[0].parameters == [0.5]
          assert input_tape.operations[1].name == "GlobalPhase"
          assert input_tape.operations[1].parameters == [-0.25]
      else:
          assert len(input_tape.operations) == 1
          assert input_tape.operations[0].name == "PhaseShift"
          assert input_tape.operations[0].parameters == [0.5]
  
imports: import functools
  import pytest
  import pennylane
  from pennylane import numpy
label_desc: Use image node_id 12 for calling the TestBatchTransform obj's underlying member method code with example usage: obj.test_expand_qnode_with_kwarg(mocker, perform_expansion) and returns: qml, list,  None