class_docstr: Test for the dispatching logic of the parameter shift method
docstr: Test the case where expectation values are independent of some parameters. For those
  parameters, the gradient should be evaluated to zero without executing the device.
docstr_tok: ["Test","the","case","where","expectation","values","are","independent","of","some","parameters",".","For","those","parameters",",","the","gradient","should","be","evaluated","to","zero","without","executing","the","device","."]
code: def test_independent_parameters_analytic(self):
      """Test the case where expectation values are independent of some parameters. For those
      parameters, the gradient should be evaluated to zero without executing the device.
      """
      dev = qml.device("default.gaussian", wires=2)
  
      with qml.queuing.AnnotatedQueue() as q:
          qml.Displacement(1.0, 0.0, wires=[1])
          qml.Displacement(1.0, 0.0, wires=[0])
          qml.expval(qml.QuadX(0))
  
      tape = qml.tape.QuantumScript.from_queue(q)
      tape.trainable_params = {0, 2}
      tapes, fn = qml.gradients.param_shift_cv(tape, dev)
  
      # We should only be executing the device to differentiate 1 parameter
      # (first order, so 2 executions)
      assert len(tapes) == 2
  
      res = fn(dev.batch_execute(tapes))
      assert np.allclose(res, [0, 2])
  
      tape.trainable_params = {0, 2}
      tapes, fn = qml.gradients.param_shift_cv(
          tape, dev, force_order2=True
      )
  
      # We should only be executing the device to differentiate 1 parameter
      # (second order, so 0 executions)
      assert len(tapes) == 0
  
      res = fn(dev.batch_execute(tapes))
      assert np.allclose(res, [0, 2])
  
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 12 for calling the TestParameterShiftLogic obj's underlying member method code with example usage: obj.test_independent_parameters_analytic() without return types