def get_batches(self, batch_size, shuffle=True):
batches = []<EOL>for bkt_idx, bucket in enumerate(self._buckets):<EOL><INDENT>bucket_size = bucket.shape[<NUM_LIT:1>]<EOL>n_tokens = bucket_size * self._bucket_lengths[bkt_idx]<EOL>n_splits = min(max(n_tokens // batch_size, <NUM_LIT:1>), bucket_size)<EOL>range_func = np.random.permutation if shuffle else np.arange<EOL>for bkt_batch in np.array_split(range_func(bucket_size), n_splits):<EOL><INDENT>batches.append((bkt_idx, bkt_batch))<EOL><DEDENT><DEDENT>if shuffle:<EOL><INDENT>np.random.shuffle(batches)<EOL><DEDENT>for bkt_idx, bkt_batch in batches:<EOL><INDENT>word_inputs = self._buckets[bkt_idx][:, bkt_batch, <NUM_LIT:0>]  <EOL>tag_inputs = self._buckets[bkt_idx][:, bkt_batch, <NUM_LIT:1>]<EOL>arc_targets = self._buckets[bkt_idx][:, bkt_batch, <NUM_LIT:2>]<EOL>rel_targets = self._buckets[bkt_idx][:, bkt_batch, <NUM_LIT:3>]<EOL>yield word_inputs, tag_inputs, arc_targets, rel_targets<EOL><DEDENT>
Get batch iterator

        Parameters
        ----------
        batch_size : int
            size of one batch
        shuffle : bool
            whether to shuffle batches. Don't set to True when evaluating on dev or test set.
        Returns
        -------
        tuple
            word_inputs, tag_inputs, arc_targets, rel_targets