# Ground truth error corresponding to a particular sampling event

In stim we can use the .compile_detector_sampler().sample() to sample a detection event. However, there might be different ground truth errors that lead to the same detection event. Is there a way to extract the actual ground truth error which led to the detection event?

I was thinking of using this to create a dataset for a low-level neural network decoder. The decoder would take a detection event (syndromes) as input and output the qubits which encountered an error.

The circuit sampling code doesn't have an option for this, but the detector error model sampling code does. stim.CompiledDemSampler.sample has a return_errors argument that you can set to True.
circuit = stim.Circuit(...)