class_docstr: Tests for parameter gradient methods
docstr: If the variance of the observable is first order, then
  parameter-shift is supported. If the observable is second order,
  however, only finite-differences is supported.
docstr_tok: ["If","the","variance","of","the","observable","is","first","order",",","then","parameter-shift","is","supported",".","If","the","observable","is","second","order",",","however",",","only","finite-differences","is","supported","."]
code: def test_variance(self):
      """If the variance of the observable is first order, then
      parameter-shift is supported. If the observable is second order,
      however, only finite-differences is supported."""
  
      with qml.queuing.AnnotatedQueue() as q:
          qml.Rotation(1.0, wires=[0])
          qml.var(qml.QuadP(0))  # first order
  
      tape = qml.tape.QuantumScript.from_queue(q)
      assert _grad_method_cv(tape, 0) == "A"
  
      with qml.queuing.AnnotatedQueue() as q:
          qml.Rotation(1.0, wires=[0])
          qml.var(qml.NumberOperator(0))  # second order
  
      tape = qml.tape.QuantumScript.from_queue(q)
      assert _grad_method_cv(tape, 0) == "F"
  
      with qml.queuing.AnnotatedQueue() as q:
          qml.Rotation(1.0, wires=[0])
          qml.Rotation(1.0, wires=[1])
          qml.Beamsplitter(0.5, 0.0, wires=[0, 1])
          qml.var(qml.NumberOperator(0))  # fourth order
          qml.expval(qml.NumberOperator(1))
  
      tape = qml.tape.QuantumScript.from_queue(q)
      assert _grad_method_cv(tape, 0) == "F"
      assert _grad_method_cv(tape, 1) == "F"
      assert _grad_method_cv(tape, 2) == "F"
      assert _grad_method_cv(tape, 3) == "F"
  
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 6 for calling the TestGradAnalysis obj's underlying member method code with example usage: obj.test_variance() without return types