def project(hidden_states, proj_layer, key_value_states, past_key_value):
        """projects hidden states correctly to key/query states"""
        if key_value_states is None:
            # self-attn
            hidden_states = shape(proj_layer(hidden_states))
        else:
            if past_key_value is None:
                hidden_states = shape(proj_layer(key_value_states))
            else:
                hidden_states = past_key_value.transpose(0, 1)[
                    :, : key_value_states.shape[1], :, :
                ]
        return hidden_states
projects hidden states correctly to key/query states
intel_extension_for_pytorch/transformers/models/reference/modules/attentions.py