def iterator(self,
                 mode='sequential',
                 batch_size=None,
                 num_batches=None,
                 rng_seed=0):

        if(batch_size is not None):
            if(batch_size > self.n_samples):
                raise ValueError("batch_size is larger than number of samples")

        if(mode == 'sequential'):
            if batch_size is None:
                if num_batches is not None:
                    batch_size = int(self.n_samples / num_batches)
                else:
                    raise ValueError("need one of batch_size, num_batches"
                                     "for sequential batch iteration")
            elif batch_size is not None:
                if num_batches is not None:
                    max_num_batches = int(np.ceil(self.n_samples / batch_size))
                    if num_batches > max_num_batches:
                        raise ValueError("dataset of %d examples can only "
                                         "provide %d batches with batch_size "
                                         "%d, but %d batches were requested" %
                                         (self.n_samples, max_num_batches,
                                          batch_size, num_batches))
                else:
                    num_batches = int(self.n_samples / batch_size)

            self.iter = DatasetIteratorSequential(self.X, self.y, batch_size,
                                                  num_batches, self.n_samples)

        elif(mode == 'random_uniform'):
            if batch_size is None:
                raise ValueError("batch_size cannot be None for random "
                                 "uniform iteration")
            elif num_batches is None:
                raise ValueError("num_batches cannot be None for random "
                                 "uniform iteration")
            self.iter = DatasetIteratorRandomUniform(self.X, self.y,
                                                     batch_size, num_batches,
                                                     self.n_samples, rng_seed)

        elif(mode == 'random_uniform_no_rep'):
            if batch_size is None:
                if num_batches is not None:
                    # Floor Function chosen to ensure that uneven segment
                    # (i.e. "runt") is ignored
                    batch_size = int(np.floor(np.float32(self.n_samples) /
                                              num_batches))
                else:
                    raise ValueError("need one of batch_size, num_batches"
                                     "for sequential batch iteration")
            elif batch_size is not None:
                if num_batches is not None:
                    max_num_batches = int(np.ceil(self.n_samples / batch_size))
                    if max_num_batches > num_batches:
                        raise ValueError("dataset of %d examples can only "
                                         "provide %d batches with batch_size "
                                         " %d, but %d batches were requested" %
                                         (self.n_samples, max_num_batches,
                                          batch_size, num_batches))
                else:
                    # Floor Function chosen to ensure that uneven segment
                    # (i.e. "runt") is ignored
                    num_batches = int(np.floor(np.float32(self.n_samples) /
                                               batch_size))

            self.iter = DatasetIteratorRandomUniformNoRep(self.X, self.y,
                                                          batch_size,
                                                          num_batches,
                                                          self.n_samples,
                                                          rng_seed)

        else:
            raise ValueError("please specify the iterator mode as either "
                             "('sequential', 'random_uniform', "
                             " 'random_uniform_no_rep')")

        return self.iter
dataset/ETHPy150Open ifp-uiuc/anna/anna/datasets/supervised_dataset.py/SupervisedDataset.iterator/swapped operands of `>`