class_docstr: Session hook that watches for shutdown events.
  
  If a shutdown is indicated, `saver.save(checkpoint_prefix)` is executed, and a
  SystemShutdown exception is raised to terminate the main session.  If `saver`
  is None the `SAVERS` collection will be read to find a saver.
  
  `on_shutdown_hooks` is an optional list of functions that should be called
  after checkpointing.  The function is called with (`run_context`,
  `all_workers`, `lame_workers`).
  
  If `heartbeat_group` is not specified, it will default to all CPU workers
  in the system.
class_docstr_tok: ["Session","hook","that","watches","for","shutdown","events",".","If","a","shutdown","is","indicated",",","`","saver.save","(","checkpoint_prefix",")","`","is","executed",",","and","a","SystemShutdown","exception","is","raised","to","terminate","the","main","session",".","If","`","saver","`","is","None","the","`","SAVERS","`","collection","will","be","read","to","find","a","saver",".","`","on_shutdown_hooks","`","is","an","optional","list","of","functions","that","should","be","called","after","checkpointing",".","The","function","is","called","with","(","`","run_context","`",",","`","all_workers","`",",","`","lame_workers","`",")",".","If","`","heartbeat_group","`","is","not","specified",",","it","will","default","to","all","CPU","workers","in","the","system","."]
code: def after_run(self, run_context, run_values):
      del run_values
      if not self._heartbeat_supported:
          return
  
      lame_workers = self._workers.lame_workers()
  
      if lame_workers:
          logging.info(
              "ShutdownHook: lame workers found: %s", lame_workers
          )
  
          if self.saver():
              logging.info(
                  "ShutdownHook: saving checkpoint to %s",
                  self._checkpoint_prefix,
              )
              self.saver().save(
                  run_context.session,
                  self._checkpoint_prefix,
                  global_step=training_util.get_global_step(),
                  write_state=True,
              )
          else:
              logging.info("ShutdownHook: no Saver defined.")
  
          for fn in self._on_shutdown_hooks:
              fn(run_context, self._workers, lame_workers)
  
imports: import threading
  import time
  from google.protobuf import text_format
  from tensorflow.core.protobuf import config_pb2
  from tensorflow.core.util import event_pb2
  from tensorflow.python.client import session
  from tensorflow.python.framework import dtypes
  from tensorflow.python.framework import errors
  from tensorflow.python.framework import ops
  from tensorflow.python.ops import array_ops
  from tensorflow.python.platform import tf_logging
  from tensorflow.python.tpu.ops import tpu_ops
  from tensorflow.python.training import session_run_hook
  from tensorflow.python.training import training_util
label_desc: Use image node_id 4 for calling the GracefulShutdownHook obj's underlying member method code with example usage: obj.after_run(run_context, run_values) without return types