How should I use the transformer in pytorch when input is features?

I have an input of BxKx768 which is my embedded features.
Is there a way to give them to a transformer and get the output of size BxM where M can be any number?