code: def create_hooks(use_tfdbg=False,
                   use_dbgprofile=False,
                   dbgprofile_kwargs=None,
                   use_validation_monitor=False,
                   validation_monitor_kwargs=None,
                   use_early_stopping=False,
                   early_stopping_kwargs=None):
    
    train_hooks = []
    eval_hooks = []
  
    if use_tfdbg:
      hook = debug.LocalCLIDebugHook()
      train_hooks.append(hook)
      eval_hooks.append(hook)
  
    if use_dbgprofile:
      # Recorded traces can be visualized with chrome://tracing/
      # The memory/tensor lifetime is also profiled
      tf.logging.info("Using ProfilerHook")
      defaults = dict(save_steps=10, show_dataflow=True, show_memory=True)
      defaults.update(dbgprofile_kwargs)
      train_hooks.append(tf.train.ProfilerHook(**defaults))
  
    if use_validation_monitor:
      tf.logging.info("Using ValidationMonitor")
      train_hooks.append(
          tf.contrib.learn.monitors.ValidationMonitor(
              hooks=eval_hooks, **validation_monitor_kwargs))
  
    if use_early_stopping:
      tf.logging.info("Using EarlyStoppingHook")
      hook = metrics_hook.EarlyStoppingHook(**early_stopping_kwargs)
      # Adding to both training and eval so that eval aborts as well
      train_hooks.append(hook)
      eval_hooks.append(hook)
  
    return train_hooks, eval_hooks
docs: Create train and eval hooks for Experiment.