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.

print(img)