Better way to find max tensor element

This will at the very end give me the max element in 3D tensor.
Is there a better way?

values = torch.randn(32, 32, 32)
values, indices = values.max(0)
print(values, indices)
values, indices = values.max(0)
print(values, indices)
values, indices = values.max(0)
print(values, indices) #tensor(4.0173) tensor(31)

If you just skip the dim argument, you’ll get the max value:

a = values.max()

# if you need the index also
b = torch.argmax(values)
idx = np.unravel_index(b, values.shape)