I'm notorious for putting in too many commas, so maybe don't trust me. I tend to just put them in whenever I pause when reading.  Just so I can stop stressing about it, I'll change it to: "Each sample in a dataset can...", where there is no punctuation ambiguity.