In other words, during rendering, many fragments happens in one pixel, ...

In principle: Each render (geometry/depth) pass writes its color into a texture, and a final pass blends the textures into the final image. Because each rendering targets a specific texture and is to be set-up accordingly, the correspondences are a-priorily known, and the texture will receive color for a specific depth layer only.

... but one remains to be the final color due to depth test.

If just one color would remain due to depth test in the end, then depth peeling would not be needed at all.

obvioursly, render times and times again to get a more "deeper" image and finaly see if there are any shading pixel is one way.

The very first render pass finds all the geometry that is at most in front. It is comparable to a standard rendering pass, because the fragments with the nearest depth win. The second render pass finds all geometry that is behind geometry found by the first pass. And so on. As soon as a pass has not found geometry, any following pass will also find nothing. So we have a progressive refinement with each pass, and already the first pass gives you results. It usually makes no sense to look for very deep layers. Dependent on the use case, it may already be enough to make 3 or 4 passes.

BTW: If your question is based on a specific implementation detail, then please tell us about.

So we have a progressive refinement with each pass, and already the first pass gives you results. It usually makes no sense to look for very deep layers

I don't konw this meaning.

My question is that, I want a number of depth images to represents a scene. However, I don't know how much the layer number is. I hope to find a specific pass that tell me how many fragment N (also can be known as layers because 1 layer issues one fragment) in each pixel of final image (u,v). Thus by rendering Nmax number of scene, we can get Nmax depth images to briefly represent this scece.

It means that although a scene may have 20 depth layers, it is seldom meaningful to actually render them all. E.g. if each layer has a transparency of 75%, then the 10-th layer has an effect of 5.6% only, and the 20-th layer has an effect of 0.3%. However, if you want to render a deep image (i.e. without especially considering transparency), then ignore this argument.

My question is that, I want a number of depth images to represents a scene. However, I don't know how much the layer number is. ...

The perhaps fastest approach would be to render the geometry without writing color or depth. Then in the fragment shader increment a counter for each fragment for which the shader is invoked (gl_FragCoord.xy). The stencil buffer can probably be used for this, or perhaps an offscreen integer render target (details need to be investigated). Doing so requires a single pass.

The above approach can be extended if only transparent layers in front of opaque geometry should be counted. Then render the opaque geometry as usual, and perform the above counting with the depth buffer left from opaque geometry.