from tensorflow.python import debug as tf_debug

  hooks = []

  if FLAGS.use_hvd:
    hooks.append(hvd.BroadcastGlobalVariablesHook(0))

    if hvd.rank() == -1: #if debug, set 0
      CLIDebugHook = tf_debug.LocalCLIDebugHook(ui_type='readline')
      CLIDebugHook.add_tensor_filter("has_inf_or_nan", tf_debug.has_inf_or_nan)
      hooks.append(CLIDebugHook)

    if FLAGS.profile and hvd.rank() == 0:
      ProfilerHook = tf.train.ProfilerHook(save_steps=FLAGS.hooking_frequence, output_dir=FLAGS.output_dir, show_dataflow=True, show_memory=True)
