Replace torch.gather by other operator

Hello all, I have one script code, where x1 and x2 size of 1x68x8x8

tmp_batch, tmp_channel, tmp_height, tmp_width = x1.size()
 x1 = x1.view(tmp_batch*tmp_channel, -1)        
 max_ids = torch.argmax(x1, 1)            
 max_ids = max_ids.view(-1, 1)
            
 x2 = x2.view(tmp_batch*tmp_channel, -1)
 outputs_x_select = torch.gather(x2, 1, max_ids) # size of 68 x 1

As the above code, I have a trouble with torch.gather when I used old onnx. Hence, I would like to find an alternative solution that replace the toch.gather by other operators but gives same output with above code. Could you please give me some suggestion?