You can do the following:
import torch

batch_size = 2
num_channels = 3
height = 5
width = 5

a = torch.rand(batch_size, num_channels, height, width)
b = torch.rand(batch_size, num_channels, 2).mul(min(height, width)).long() # Make random valid indices

# Your solution
x = b[:,:,0]
x = x.view(batch_size,num_channels,1,1).expand(batch_size,num_channels,height,1)
y = b[:,:,1]
y = y.view(batch_size,num_channels,1,1)
result = a.gather(3, x).gather(2, y).squeeze()

# 1D solution
lin_indices = b.select(-1, 1) * width + b.select(-1, 0)
assert a.is_contiguous()
lin_a = a.view(batch_size, num_channels, height*width)
result2 = lin_a.gather(-1, lin_indices.unsqueeze(-1)).squeeze(-1)

print((result - result2).abs().max())