class_docstr: Test that the measure_with_samples function works as expected
class_docstr_tok: ["Test","that","the","measure_with_samples","function","works","as","expected"]
docstr: Test that a sample measurement works as expected
docstr_tok: ["Test","that","a","sample","measurement","works","as","expected"]
code: def test_sample_measure(self):
      """Test that a sample measurement works as expected"""
      state = qml.math.array(two_qubit_state)
      shots = qml.measurements.Shots(100)
      mp = qml.sample(wires=range(2))
  
      result = measure_with_samples([mp], state, shots=shots)[0]
  
      assert result.shape == (shots.total_shots, 2)
      assert result.dtype == np.int64
      assert all(
          qml.math.allequal(s, [0, 1]) or qml.math.allequal(s, [1, 0])
          for s in result
      )
  
imports: from random import shuffle
  import pytest
  import numpy
  import pennylane
  from pennylane.devices.qubit import simulate
  from pennylane.devices.qubit.simulate import _FlexShots
  from pennylane.devices.qubit import sample_state, measure_with_samples
  from pennylane.devices.qubit.sampling import _sample_state_jax
  from pennylane.measurements import Shots
label_desc: Use image node_id 1 for calling the TestMeasureSamples obj's underlying member method code with example usage: obj.test_sample_measure() without return types