def bilinear(x, W, y, input_size, seq_len, batch_size, num_outputs=<NUM_LIT:1>, bias_x=False, bias_y=False):
if bias_x:<EOL><INDENT>x = nd.concat(x, nd.ones((<NUM_LIT:1>, seq_len, batch_size)), dim=<NUM_LIT:0>)<EOL><DEDENT>if bias_y:<EOL><INDENT>y = nd.concat(y, nd.ones((<NUM_LIT:1>, seq_len, batch_size)), dim=<NUM_LIT:0>)<EOL><DEDENT>nx, ny = input_size + bias_x, input_size + bias_y<EOL>lin = nd.dot(W, x)<EOL>if num_outputs > <NUM_LIT:1>:<EOL><INDENT>lin = reshape_fortran(lin, (ny, num_outputs * seq_len, batch_size))<EOL><DEDENT>y = y.transpose([<NUM_LIT:2>, <NUM_LIT:1>, <NUM_LIT:0>])  <EOL>lin = lin.transpose([<NUM_LIT:2>, <NUM_LIT:1>, <NUM_LIT:0>])<EOL>blin = nd.batch_dot(lin, y, transpose_b=True)<EOL>blin = blin.transpose([<NUM_LIT:2>, <NUM_LIT:1>, <NUM_LIT:0>])<EOL>if num_outputs > <NUM_LIT:1>:<EOL><INDENT>blin = reshape_fortran(blin, (seq_len, num_outputs, seq_len, batch_size))<EOL><DEDENT>return blin<EOL>
Do xWy

    Parameters
    ----------
    x : NDArray
        (input_size x seq_len) x batch_size
    W : NDArray
        (num_outputs x ny) x nx
    y : NDArray
        (input_size x seq_len) x batch_size
    input_size : int
        input dimension
    seq_len : int
        sequence length
    batch_size : int
        batch size
    num_outputs : int
        number of outputs
    bias_x : bool
        whether concat bias vector to input x
    bias_y : bool
        whether concat bias vector to input y

    Returns
    -------
    output : NDArray
        [seq_len_y x seq_len_x if output_size == 1 else seq_len_y x num_outputs x seq_len_x] x batch_size