torch.argmax will return the index of the first max. value when duplicates are seen as described in the docs.
nn.MaxPool2d will return the max. value, so the index doesn’t matter unless you use return_indices in which case also the first index should be returned:
x = torch.ones(1, 1, 2, 2)
pool = nn.MaxPool2d(2, return_indices=True)
out = pool(x)
print(out)
# (tensor([[[[1.]]]]), tensor([[[[0]]]]))