Create Shadow Mask for Current Camera

So I am currently trying to teach an AI to detect shadows and am trying to create a mask which represents the shadows on the viewable window for the data. In theory, the rendered output uses the depth buffer from the light source to determine where the shadows should be placed on the scene via transformation of the depth buffer w.r.t the light source to the camera. I’ve only done one week of computer graphics so sorry if I’m completely misunderstanding something. Anyone know how I might achieve this?