How to convert coordinate to image

I have n points as tensor(n, 2), the second dimension is x and y coordinate on an image, I want to convert them to tensor(n, W, H), the W and H are x and y coordinate on the image.
How can I do it with no for loop?


If you want to set a specific value for these coordinates into the image, this code should work:

img = torch.zeros(4, 5, 5)
x = torch.randint(0, 5, (4, 2))
img[torch.arange(img.size(0)), x[:, 0], x[:, 1]] = 1.