All problems
Embedding Lookup
Problem
Look up embedding rows for a list of token indices. Return a list containing table[indices[k]] for each k, preserving order.
The signature is embedding_lookup(indices, table). Return copies of the rows, not aliases.
Hint
Index the table directly; repeated indices produce repeated rows.
Test cases
case 1
in: [[0,2],[[1,2],[3,4],[5,6]]]
expected: [[1,2],[5,6]]
case 2
in: [[1,1],[[9],[8]]]
expected: [[8],[8]]
case 3
in: [[0],[[0.5,-0.5]]]
expected: [[0.5,-0.5]]
case 4
in: [[],[[1]]]
expected: []
Starter codePython
def embedding_lookup(indices, table):
# Your code here
pass4 test cases · run your code against them in the editor