I think he wants a histogram on z-axis for each couple (x,y) of an (x,y,z) tensor. That can be useful, for ex, in a loss function that compares histograms, which is the greedy way to compare statistical properties between two tensors (I tried to do that once for art-style transfer).
Unfortunately, if torch.histc flats the tensor, I see no ways to avoid a loop over couples (x,y).