(embedding, ids)
return ret_t
embedding: shape(b_sz, tstp, emb_sz)
        ids : shape(b_sz, k)
embedding: shape(b_sz, tstp, emb_sz)
        ids : shape(b_sz, k)
embedding : shape ( b_sz tstp emb_sz ) ids : shape ( b_sz k )
def batch_embed_lookup(embedding, ids):
    '''
        embedding: shape(b_sz, tstp, emb_sz)
        ids : shape(b_sz, k)
    '''
    input_shape = tf.shape(embedding)
    time_steps = input_shape[0]
    def _create_ta(name, dtype):
        return tf.TensorArray(dtype=dtype,
                              size=time_steps,
                              tensor_array_name=name)
    input_ta = _create_ta('input_ta', embedding.dtype)
    fetch_ta = _create_ta('fetch_ta', ids.dtype)
    output_ta = _create_ta('output_ta', embedding.dtype)
    input_ta = input_ta.unstack(embedding)
    fetch_ta = fetch_ta.unstack(ids)

    def loop_body(time, output_ta):
        embed = input_ta.read(time) #shape(tstp, emb_sz) type of float32
        fetch_id = fetch_ta.read(time) #shape(tstp) type of int32
        out_emb = tf.nn.embedding_lookup(embed, fetch_id)
        output_ta = output_ta.write(time, out_emb)

        next_time = time+1
        return next_time, output_ta
    time = tf.constant(0)
    _, output_ta = tf.while_loop(cond=lambda time, *_: time < time_steps,
                  body=loop_body, loop_vars=(time, output_ta),
                  swap_memory=True)
    ret_t = output_ta.stack() #shape(b_sz, tstp, embd_sz)
    return ret_t
def batch_embed_lookup ( embedding , ids ) : input_shape = tf . shape ( embedding ) time_steps = input_shape [ 0 ] def _create_ta ( name , dtype ) : return tf . TensorArray ( dtype = dtype , size = time_steps , tensor_array_name = name ) input_ta = _create_ta ( 'input_ta' , embedding . dtype ) fetch_ta = _create_ta ( 'fetch_ta' , ids . dtype ) output_ta = _create_ta ( 'output_ta' , embedding . dtype ) input_ta = input_ta . unstack ( embedding ) fetch_ta = fetch_ta . unstack ( ids ) def loop_body ( time , output_ta ) : embed = input_ta . read ( time ) #shape(tstp, emb_sz) type of float32 fetch_id = fetch_ta . read ( time ) #shape(tstp) type of int32 out_emb = tf . nn . embedding_lookup ( embed , fetch_id ) output_ta = output_ta . write ( time , out_emb ) next_time = time + 1 return next_time , output_ta time = tf . constant ( 0 ) _ , output_ta = tf . while_loop ( cond = lambda time , * _ : time < time_steps , body = loop_body , loop_vars = ( time , output_ta ) , swap_memory = True ) ret_t = output_ta . stack ( ) #shape(b_sz, tstp, embd_sz) return ret_t