Compute the distance between each point of the labels and the prediction

Hi everyone,
I have a problem that is I think quite complicated to solve computationally speaking. I compute the segmentation from a label image, and I’d like to calculate the distance between the label’s image and each point of my prediction. Is there an efficient already implemented method in Pytorch to do that?
The brute force method would be to go through all the labels pixels and keep the minimum distance with the given pixel of the prediction, for each pixel of the prediction. I do not know if I made myself clear enough. If not, don’t hesitate to ask for more details.
Thank you very much!