def minibatches(inputs=None, targets=None, batch_size=None, allow_dynamic_batch_size=False, shuffle=False):
if len(inputs) != len(targets):<EOL><INDENT>raise AssertionError("<STR_LIT>")<EOL><DEDENT>if shuffle:<EOL><INDENT>indices = np.arange(len(inputs))<EOL>np.random.shuffle(indices)<EOL><DEDENT>for start_idx in range(<NUM_LIT:0>, len(inputs), batch_size):<EOL><INDENT>end_idx = start_idx + batch_size<EOL>if end_idx > len(inputs):<EOL><INDENT>if allow_dynamic_batch_size:<EOL><INDENT>end_idx = len(inputs)<EOL><DEDENT>else:<EOL><INDENT>break<EOL><DEDENT><DEDENT>if shuffle:<EOL><INDENT>excerpt = indices[start_idx:end_idx]<EOL><DEDENT>else:<EOL><INDENT>excerpt = slice(start_idx, end_idx)<EOL><DEDENT>if (isinstance(inputs, list) or isinstance(targets, list)) and (shuffle ==True):<EOL><INDENT>yield [inputs[i] for i in excerpt], [targets[i] for i in excerpt]<EOL><DEDENT>else:<EOL><INDENT>yield inputs[excerpt], targets[excerpt]<EOL><DEDENT><DEDENT>
Generate a generator that input a group of example in numpy.array and
    their labels, return the examples and labels by the given batch size.

    Parameters
    ----------
    inputs : numpy.array
        The input features, every row is a example.
    targets : numpy.array
        The labels of inputs, every row is a example.
    batch_size : int
        The batch size.
    allow_dynamic_batch_size: boolean
        Allow the use of the last data batch in case the number of examples is not a multiple of batch_size, this may result in unexpected behaviour if other functions expect a fixed-sized batch-size.
    shuffle : boolean
        Indicating whether to use a shuffling queue, shuffle the dataset before return.

    Examples
    --------
    >>> X = np.asarray([['a','a'], ['b','b'], ['c','c'], ['d','d'], ['e','e'], ['f','f']])
    >>> y = np.asarray([0,1,2,3,4,5])
    >>> for batch in tl.iterate.minibatches(inputs=X, targets=y, batch_size=2, shuffle=False):
    >>>     print(batch)
    (array([['a', 'a'], ['b', 'b']], dtype='<U1'), array([0, 1]))
    (array([['c', 'c'], ['d', 'd']], dtype='<U1'), array([2, 3]))
    (array([['e', 'e'], ['f', 'f']], dtype='<U1'), array([4, 5]))

    Notes
    -----
    If you have two inputs and one label and want to shuffle them together, e.g. X1 (1000, 100), X2 (1000, 80) and Y (1000, 1), you can stack them together (`np.hstack((X1, X2))`)
    into (1000, 180) and feed to ``inputs``. After getting a batch, you can split it back into X1 and X2.