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,
  ):
      """Create train and eval hooks for Experiment."""
      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(
              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
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import collections
  import contextlib
  import json
  import os
  import random
  import numpy
  from tensor2tensor.utils import contrib
  from tensor2tensor.utils import decoding
  from tensor2tensor.utils import devices
  from tensor2tensor.utils import hparams_lib
  from tensor2tensor.utils import metrics_hook
  from tensor2tensor.utils import mlperf_log
  from tensor2tensor.utils import registry
  from tensor2tensor.utils import t2t_model
  import tensorflow.compat.v1
  from tensorflow.compat.v1 import estimator
  from tensorflow.core.protobuf import rewriter_config_pb2
  from tensorflow.python import debug
label_desc: Use image node_id 7 for calling a global function with example usage: create_hooks(use_tfdbg, use_dbgprofile, dbgprofile_kwargs, use_validation_monitor, validation_monitor_kwargs, use_early_stopping, early_stopping_kwargs) and returns: train_hooks,  eval_hooks