from tensorflow.python import debug as tf_debug


  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:
