4d matrix multiplcation using einsum

I have two tensor, a and b, with 4 dimensions each of the same size and I want to write the following operation using einsum:

output = torch.matmul(a, b.transpose(-2,-1))

This is what I have so far:

output = torch.einsum("ijkl,jmnl->imkn", [q,k])

But this is not correct, how do I write 4d tensor multiplication using einsum?

Solved, this seems to be give the correct results:

torch.einsum("ijkl,ijml->ijkm", [q,k])