<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def sg_lookup(tensor, opt):
 r"""Looks up the `tensor`, which is the embedding matrix. Args: tensor: A tensor ( automatically given by chain ) opt: emb: A 2-D `Tensor`. An embedding matrix. name: If provided, replace current tensor's name. Returns: A `Tensor`. """

    assert opt.emb is not None, 'emb is mandatory.'
    return tf.nn.embedding_lookup(opt.emb, tensor, name=opt.name)