I cannot test the code but it looks alright.
You only have to make sure that the input sequences match the embedding. For example, if you convert the sentence “i go to work every day” into the input sequence [4, 24, 8, 120, 53, 78, 0, 0, 0, 0] with 0 representing padding, so that 4 represents “I”, 24 represents “go” and so on…then that must match in the embedding matrix, i.e., the forth word vector is the one for “i”. See this other post 82 discussing that issue.