You may wanna try something like broadcast
TRY:
cosine_embedding_loss(x1.view(10,1,3), x2)
# x1 would broadcast to (10,5,3) as x2

BTW, it  seems something is rong with your format.
use 10x 3 instead of 10*3