class_docstr: Tests for the quantum gradients of various gates
  with variance measurements
docstr: Test gradient of the photon variance of a displaced thermal state
docstr_tok: ["Test","gradient","of","the","photon","variance","of","a","displaced","thermal","state"]
code: def test_displaced_thermal_mean_photon_variance(self, tol):
      """Test gradient of the photon variance of a displaced thermal state"""
      dev = qml.device("default.gaussian", wires=1)
  
      n = 0.12
      a = 0.105
  
      with qml.queuing.AnnotatedQueue() as q:
          qml.ThermalState(n, wires=0)
          qml.Displacement(a, 0, wires=0)
          qml.var(qml.TensorN(wires=[0]))
  
      tape = qml.tape.QuantumScript.from_queue(q)
      tape.trainable_params = {0, 1}
      tapes, fn = param_shift_cv(tape, dev)
      grad = fn(dev.batch_execute(tapes))
      expected = np.array([2 * a**2 + 2 * n + 1, 2 * a * (2 * n + 1)])
      assert np.allclose(grad, expected, atol=tol, rtol=0)
  
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 8 for calling the TestVarianceQuantumGradients obj's underlying member method code with example usage: obj.test_displaced_thermal_mean_photon_variance(tol) without return types