Looking through the code, we have the following:

And this means that on one diagonal of the matrix simwe get the result of multiplying each column.
You can try if you want to use a simple matrix:

, - ( ) .
norms, , , gram matrix sqrt .
, :

, norms result.
, , , :

, :

, , :

, , :

, :
return sim / norms / norms.T
EDIT:
, , , , DOT PRODUCT .
, A * B, A.T * B