def seq_minibatches2(inputs, targets, batch_size, num_steps):
if len(inputs) != len(targets):<EOL><INDENT>raise AssertionError("<STR_LIT>")<EOL><DEDENT>data_len = len(inputs)<EOL>batch_len = data_len // batch_size<EOL>data = np.zeros((batch_size, batch_len) + inputs.shape[<NUM_LIT:1>:], dtype=inputs.dtype)<EOL>data2 = np.zeros([batch_size, batch_len])<EOL>for i in range(batch_size):<EOL><INDENT>data[i] = inputs[batch_len * i:batch_len * (i + <NUM_LIT:1>)]<EOL>data2[i] = targets[batch_len * i:batch_len * (i + <NUM_LIT:1>)]<EOL><DEDENT>epoch_size = (batch_len - <NUM_LIT:1>) // num_steps<EOL>if epoch_size == <NUM_LIT:0>:<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>for i in range(epoch_size):<EOL><INDENT>x = data[:, i * num_steps:(i + <NUM_LIT:1>) * num_steps]<EOL>x2 = data2[:, i * num_steps:(i + <NUM_LIT:1>) * num_steps]<EOL>yield (x, x2)<EOL><DEDENT>
Generate a generator that iterates on two list of words. Yields (Returns) the source contexts and
    the target context by the given batch_size and num_steps (sequence_length).
    In TensorFlow's tutorial, this generates the `batch_size` pointers into the raw PTB data, and allows minibatch iteration along these pointers.

    Parameters
    ----------
    inputs : list of data
        The context in list format; note that context usually be represented by splitting by space, and then convert to unique word IDs.
    targets : list of data
        The context in list format; note that context usually be represented by splitting by space, and then convert to unique word IDs.
    batch_size : int
        The batch size.
    num_steps : int
        The number of unrolls. i.e. sequence length

    Yields
    ------
    Pairs of the batched data, each a matrix of shape [batch_size, num_steps].

    Raises
    ------
    ValueError : if batch_size or num_steps are too high.

    Examples
    --------
    >>> X = [i for i in range(20)]
    >>> Y = [i for i in range(20,40)]
    >>> for batch in tl.iterate.seq_minibatches2(X, Y, batch_size=2, num_steps=3):
    ...     x, y = batch
    ...     print(x, y)

    [[  0.   1.   2.]
    [ 10.  11.  12.]]
    [[ 20.  21.  22.]
    [ 30.  31.  32.]]

    [[  3.   4.   5.]
    [ 13.  14.  15.]]
    [[ 23.  24.  25.]
    [ 33.  34.  35.]]

    [[  6.   7.   8.]
    [ 16.  17.  18.]]
    [[ 26.  27.  28.]
    [ 36.  37.  38.]]

    Notes
    -----
    - Hint, if the input data are images, you can modify the source code `data = np.zeros([batch_size, batch_len)` to `data = np.zeros([batch_size, batch_len, inputs.shape[1], inputs.shape[2], inputs.shape[3]])`.