It is ok, don’t be shy about it, if you could provide some shape hints like this:
keys = self.linear_keys(input)  # shape: (N, T, key_size)
query = self.linear_query(input)  # shape: (N, T, key_size)
values = self.linear_values(input)  # shape: (N, T, value_size)

It will make your code much easier to read and check. .