function attention_scores(query, keys):
   return [dot(query, key) / sqrt(key_dimension) for key in keys]


 function attention(query, keys, values):
   scores = attention_scores(query, keys)
   weights = softmax(scores)   # how much to attend to each posit
 ion
   return sum(w * v for w, v in zip(weights, values))
