import tensorflow as tf

    def train(self, iterations, validation_interval=100, output_dir=None,
              save_interval=None, checkpoint_path=None, keep_checkpoints=1):
        assert 'training' in self.datasets, 'Training dataset is required.'
        if output_dir is not None:
            train_writer = tf.summary.FileWriter(output_dir)
        if not hasattr(self, 'saver'):
            with tf.device('/cpu:0'):
                self.saver = tf.train.Saver(save_relative_paths=True,
                                            max_to_keep=keep_checkpoints)
        if not self.graph.finalized:
            self.graph.finalize()

