class_docstr: A hook to capture metadata for a single step.
  Useful for performance debugging. It performs a full trace and saves
  run_metadata and Chrome timeline information to a file.
  
  Args:
    step: The step number to trace. The hook is only enable for this step.
code: def after_run(self, _run_context, run_values):
      if not self.is_chief or self._done:
          return
  
      step_done = run_values.results
      if self._active:
          tf.logging.info("Captured full trace at step %s", step_done)
          # Create output directory
          gfile.MakeDirs(self._output_dir)
  
          # Save run metadata
          trace_path = os.path.join(self._output_dir, "run_meta")
          with gfile.GFile(trace_path, "wb") as trace_file:
              trace_file.write(
                  run_values.run_metadata.SerializeToString()
              )
              tf.logging.info("Saved run_metadata to %s", trace_path)
  
          # Save timeline
          timeline_path = os.path.join(
              self._output_dir, "timeline.json"
          )
          with gfile.GFile(timeline_path, "w") as timeline_file:
              tl_info = timeline.Timeline(
                  run_values.run_metadata.step_stats
              )
              tl_chrome = tl_info.generate_chrome_trace_format(
                  show_memory=True
              )
              timeline_file.write(tl_chrome)
              tf.logging.info("Saved timeline to %s", timeline_path)
  
          # Save tfprof op log
          tf.contrib.tfprof.tfprof_logger.write_op_log(
              graph=tf.get_default_graph(),
              log_dir=self._output_dir,
              run_meta=run_values.run_metadata,
          )
          tf.logging.info("Saved op log to %s", self._output_dir)
          self._active = False
          self._done = True
  
      self._active = step_done >= self.params["step"]
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  from __future__ import unicode_literals
  import abc
  import os
  import numpy
  import six
  import yaml
  import tensorflow
  from tensorflow.python.training.basic_session_run_hooks import SecondOrStepTimer
  from tensorflow.python.training import session_manager
  from tensorflow.python.client import timeline
  from tensorflow import gfile
  from seq2seq.configurable import Configurable, abstractstaticmethod
  from seq2seq import graph_utils, global_vars
label_desc: Use image node_id 5 for calling the MetadataCaptureHook obj's underlying member method code with example usage: obj.after_run(_run_context, run_values) without return types