H = image.shape[1]
W = image.shape[2]
# a is some const integer
x = torch.arange(0, H)
y = torch.arange(0, W)
image_scale = image[:, x * a % H, :][:, :, y * a % W]
I’m wondering whether or not the code of the last line could be merged into the single one. Also, is there a more effective method to implement this logic?