class_docstr: Tests for the variance return type
class_docstr_tok: ["Tests","for","the","variance","return","type"]
docstr: Tests if the samples returned by sample have
  the correct values
code: def test_var(self, device, tol):
      """Tests if the samples returned by sample have
      the correct values
      """
      n_wires = 2
      dev = device(n_wires)
  
      phi = 0.543
      theta = 0.6543
  
      @qml.qnode(dev)
      def circuit():
          qml.RX(phi, wires=[0])
          qml.RY(theta, wires=[0])
          return qml.var(qml.PauliZ(wires=0))
  
      res = circuit()
  
      expected = 0.25 * (
          3
          - np.cos(2 * theta)
          - 2 * np.cos(theta) ** 2 * np.cos(2 * phi)
      )
      assert np.allclose(res, expected, atol=tol(dev.shots))
  
imports: import pytest
  from flaky import flaky
  from scipy.sparse import csr_matrix
  import pennylane
  from pennylane import numpy
  from pennylane.measurements import ClassicalShadowMP, MeasurementTransform, SampleMeasurement, SampleMP, StateMeasurement, StateMP
label_desc: Use image node_id 1 for calling the TestVar obj's underlying member method code with example usage: obj.test_var(device, tol) and returns: qml