You could squeeze the spatial dimension via:
pool = nn.AdaptiveMaxPool2d(output_size=1)

x = torch.randn(2, 3, 24, 24)
out =pool(x)
print(out.shape)
> torch.Size([2, 3, 1, 1])
out = out.squeeze(3).squeeze(2)
print(out.shape)
> torch.Size([2, 3])