# create dummy src and index for example
n = 5
h = 224
w = 224
src = torch.arange(1, 11).view(n, 2)
index = torch.arange(1,h * w + 1).view(h, w).remainder_(n)

# do indexing operation
output = src[index.view(-1).long(), :].view(h, w, 2)