class_docstr: Test for the dispatching logic of the parameter shift method
docstr: Test that if the force_order2 keyword argument is provided, the
  second order parameter shift rule is forced for an observable with
  2-dimensional parameters
docstr_tok: ["Test","that","if","the","force_order2","keyword","argument","is","provided",",","the","second","order","parameter","shift","rule","is","forced","for","an","observable","with","2-dimensional","parameters"]
code: def test_force_order2_dim_2(self, mocker, monkeypatch):
      """Test that if the force_order2 keyword argument is provided, the
      second order parameter shift rule is forced for an observable with
      2-dimensional parameters"""
      spy = mocker.spy(
          qml.gradients.parameter_shift_cv, "second_order_param_shift"
      )
  
      def _mock_transform_observable(
          obs, Z, device_wires
      ):  # pylint: disable=unused-argument
          """A mock version of the _transform_observable internal function
          such that an operator ``transformed_obs`` of two-dimensions is
          returned. This function is created such that when definining ``A =
          transformed_obs.parameters[0]`` the condition ``len(A.nonzero()[0])
          == 1 and A.ndim == 2 and A[0, 0] != 0`` is ``True``."""
          iden = qml.Identity(0)
          iden.data = (np.array([[1, 0], [0, 0]]),)
          return iden
  
      monkeypatch.setattr(
          qml.gradients.parameter_shift_cv,
          "_transform_observable",
          _mock_transform_observable,
      )
  
      dev = qml.device("default.gaussian", wires=1)
  
      with qml.queuing.AnnotatedQueue() as q:
          qml.Displacement(1.0, 0.0, wires=[0])
          qml.Rotation(2.0, wires=[0])
          qml.expval(qml.QuadX(0))
  
      tape = qml.tape.QuantumScript.from_queue(q)
      tape.trainable_params = {0, 1, 2}
  
      qml.gradients.param_shift_cv(tape, dev, force_order2=False)
      spy.assert_not_called()
  
      qml.gradients.param_shift_cv(tape, dev, force_order2=True)
      spy.assert_called()
  
imports: import unittest.mock
  import pytest
  import pennylane
  from pennylane import numpy
  from pennylane.gradients import param_shift_cv
  from pennylane.gradients.gradient_transform import choose_trainable_params
  from pennylane.gradients.parameter_shift_cv import _grad_method_cv, _find_gradient_methods_cv, _transform_observable
label_desc: Use image node_id 9 for calling the TestParameterShiftLogic obj's underlying member method code with example usage: obj.test_force_order2_dim_2(mocker, monkeypatch) and returns: iden