def attention_without_cache(q, k, v):
    # 每次都需要重新计算所有位置的K和V
    scores = torch.matmul(q, k.transpose(-2, -1))
    attention_weights = torch.softmax(scores, dim=-1)
    output = torch.matmul(attention_weights, v)
    return output
