The internal _polygon 1 method used in skimage seems to iterate the passed coordinates and appends the indices which are inside the polygon, so you could try to adapt this code in PyTorch and reuse it.