apparently the weight parameter of F.embedding has to be a 2d tensor, otherwise it fails to backprop.
w = torch.rand(10000, 10, 256, requires_grad=True)
o = torch.rand(256, 10000, requires_grad=True)

x = torch.tensor([0, 1, 2])
y = F.embedding(x, w)
logits = y.mean(dim=1) @ o
loss = F.cross_entropy(logits, x)
loss.backward()
# RuntimeError: shape '[3, 256]' is invalid for input of size 7680