Typically, one uses masks. Either directly or to index with a boolean mask, which gives you an arbitray selection of pixels in a flattened tensor, e.g. for a circle, you can use
mask = (torch.linspace(-1, 1)[None]**2+torch.linspace(-1, 1)[:, None]**2)<0.5**2
Best regards
Thomas