class_docstr: Tests for the sample return type.
class_docstr_tok: ["Tests","for","the","sample","return","type","."]
docstr: Tests if the samples returned by sample have
  the correct values
code: def test_sample_values(self, device, tol):
      """Tests if the samples 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."
          )
  
      @qml.qnode(dev)
      def circuit():
          qml.RX(1.5708, wires=[0])
          return qml.sample(qml.PauliZ(wires=0))
  
      res = circuit()
  
      # res should only contain 1 and -1
      assert np.allclose(res**2, 1, 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 1 for calling the TestSample obj's underlying member method code with example usage: obj.test_sample_values(device, tol) and returns: qml