Hello Alexander,
I can confirm this and took the liberty to file QNNPACK mean with keepdim doesn't work · Issue #58668 · pytorch/pytorch · GitHub 1 . Thank you so much for reporting this with very precise repro information! This makes things much easier.
For reference: This illustrates the problem:
torch.backends.quantized.engine = 'qnnpack'
print(torch.backends.quantized.engine, torch.quantize_per_tensor(torch.randn(5, 5, 5, 5), scale=0.2, zero_point=0, dtype=torch.quint8).mean((2,3), keepdim=True).shape)
torch.backends.quantized.engine = 'fbgemm'
print(torch.backends.quantized.engine, torch.quantize_per_tensor(torch.randn(5, 5, 5, 5), scale=0.2, zero_point=0, dtype=torch.quint8).mean((2,3), keepdim=True).shape)

Best regards
Thomas