<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def get_iterator(self, dataset, training=False):
 """Get an iterator that allows to loop over the batches of the given data. If ``self.iterator_train__batch_size`` and/or ``self.iterator_test__batch_size`` are not set, use ``self.batch_size`` instead. Parameters dataset : torch Dataset (default=skorch.dataset.Dataset) Usually, ``self.dataset``, initialized with the corresponding data, is passed to ``get_iterator``. training : bool (default=False) Whether to use ``iterator_train`` or ``iterator_test``. Returns ------- iterator An instantiated iterator that allows to loop over the mini-batches. """

        if training:
            kwargs = self._get_params_for('iterator_train')
            iterator = self.iterator_train
        else:
            kwargs = self._get_params_for('iterator_valid')
            iterator = self.iterator_valid

        if 'batch_size' not in kwargs:
            kwargs['batch_size'] = self.batch_size

        if kwargs['batch_size'] == -1:
            kwargs['batch_size'] = len(dataset)

        return iterator(dataset, **kwargs)