class_docstr: Tests for the sample return type.
class_docstr_tok: ["Tests","for","the","sample","return","type","."]
docstr: Tests if the samples of a Hermitian observable returned by sample have
  the correct values
code: def test_sample_values_hermitian(self, device, tol):
      """Tests if the samples of a Hermitian observable returned by sample have
      the correct values
      """
      n_wires = 1
      dev = device(n_wires)
  
      if dev.shots is None:
          pytest.skip(
              "Device is in analytic mode, cannot test sampling."
          )
  
      if "Hermitian" not in dev.observables:
          pytest.skip(
              "Skipped because device does not support the Hermitian observable."
          )
  
      A_ = np.array([[1, 2j], [-2j, 0]])
      theta = 0.543
  
      @qml.qnode(dev)
      def circuit():
          qml.RX(theta, wires=[0])
          return qml.sample(qml.Hermitian(A_, wires=0))
  
      res = circuit().flatten()
  
      # res should only contain the eigenvalues of
      # the hermitian matrix
      eigvals = np.linalg.eigvalsh(A_)
      assert np.allclose(
          sorted(list(set(res.tolist()))),
          sorted(eigvals),
          atol=tol(dev.shots),
      )
      # the analytic mean is 2*sin(theta)+0.5*cos(theta)+0.5
      assert np.allclose(
          np.mean(res),
          2 * np.sin(theta) + 0.5 * np.cos(theta) + 0.5,
          atol=tol(False),
      )
      # the analytic variance is 0.25*(sin(theta)-4*cos(theta))^2
      assert np.allclose(
          np.var(res),
          0.25 * (np.sin(theta) - 4 * np.cos(theta)) ** 2,
          atol=tol(False),
      )
  
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 2 for calling the TestSample obj's underlying member method code with example usage: obj.test_sample_values_hermitian(device, tol) and returns: qml