Mostly through soils, but also through the manufacturing process.
Here.
Recommend chocolate milk as calcium is a lead, cadmium antagonist.
https://x.com/BioavailableNd/status/1851973382708789281?t=dUzp1_h0OpoFCNbNXD8fYw&s=19
Discussion
Here are the safest.

And for cocoa powder.

I'm not a big Bryan Johnson fan, but his company's cocoa is well sourced and 3rd party tested. That's what we consume in my household.
https://www.amazon.com/Blueprint-Bryan-Johnson-Dairy-Powder/dp/B0CWMY8LZC/