for an input image of size, 3x28x28
inp = torch.randn(1, 3, 28, 28)
x = nn.MultiheadAttention(28, 2)
x(inp[0], torch.randn(28, 28), torch.randn(28, 28))[0].shape

gives
torch.Size([3, 28, 28])

while
x(inp[0], torch.randn(28, 28), torch.randn(28, 28))[1].shape

gives
torch.Size([28, 3, 1])

what is the correct way of using MultiHeadAttention for images?
does this multiheadattention work something liike paying attention only on a part of image?