import tensorflow as tf

    # Final Evaluation if training is finished.
    if current_step >= hparams.num_epochs * train_steps_per_epoch:
      eval_results = image_classifier.evaluate(
          input_fn=imagenet_eval.input_fn, steps=eval_steps, hooks=eval_hooks)
      tf.logging.info('Evaluation results: %s' % eval_results)
    while current_step < hparams.num_epochs * train_steps_per_epoch:
      image_classifier.train(
          input_fn=imagenet_train.input_fn, steps=train_steps_per_eval)
      current_step += train_steps_per_eval
      tf.logging.info('Starting evaluation at step=%d.' % current_step)
      eval_results = image_classifier.evaluate(
          input_fn=imagenet_eval.input_fn, steps=eval_steps, hooks=eval_hooks)
      tf.logging.info('Evaluation results: %s' % eval_results)
  elif mode == 'predict':
    for checkpoint in _get_next_checkpoint():
      tf.logging.info('Starting prediction ...')
      time_hook = model_lib.SessionTimingHook()
      eval_hooks.append(time_hook)
      result_iter = image_classifier.predict(
          input_fn=imagenet_eval.input_fn,
          hooks=eval_hooks,
          checkpoint_path=checkpoint,
          yield_single_examples=False)
      results = list(itertools.islice(result_iter, eval_steps))
      tf.logging.info('Inference speed = {} images per second.'.format(
          time_hook.compute_speed(len(results) * eval_batch_size)))
  elif mode == 'train':
    current_step = _load_global_step_from_checkpoint_dir(model_dir)
    total_step = int(hparams.num_epochs * train_steps_per_epoch)
    if current_step < total_step:
