Solved by Eta_C in post #2 
              
              
                maximum 
index = torch.topk(tensor.reshape(2, -1), 2, dim=1)[1][..., None]
a, b = index // 3， index % 3
res = torch.cat([a, b], dim=2)
print(res)

for minimum, use tensor =  -tensor