class_docstr: Test for the MetadataCaptureHook
class_docstr_tok: ["Test","for","the","MetadataCaptureHook"]
code: def test_capture(self):
      global_step = tf.contrib.framework.get_or_create_global_step()
      # Some test computation
      some_weights = tf.get_variable("weigths", [2, 128])
      computation = tf.nn.softmax(some_weights)
  
      hook = hooks.MetadataCaptureHook(
          params={"step": 5},
          model_dir=self.model_dir,
          run_config=tf.contrib.learn.RunConfig(),
      )
      hook.begin()
  
      with self.test_session() as sess:
          sess.run(tf.global_variables_initializer())
          # pylint: disable=W0212
          mon_sess = monitored_session._HookedSession(sess, [hook])
          # Should not trigger for step 0
          sess.run(tf.assign(global_step, 0))
          mon_sess.run(computation)
          self.assertEqual(gfile.ListDirectory(self.model_dir), [])
          # Should trigger *after* step 5
          sess.run(tf.assign(global_step, 5))
          mon_sess.run(computation)
          self.assertEqual(gfile.ListDirectory(self.model_dir), [])
          mon_sess.run(computation)
          self.assertEqual(
              set(gfile.ListDirectory(self.model_dir)),
              set(["run_meta", "tfprof_log", "timeline.json"]),
          )
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  from __future__ import unicode_literals
  import os
  import tempfile
  import shutil
  import time
  import tensorflow
  from tensorflow.python.training import monitored_session
  from tensorflow import gfile
  from seq2seq import graph_utils
  from seq2seq.training import hooks
label_desc: Use image node_id 3 for calling the TestMetadataCaptureHook obj's underlying member method code with example usage: obj.test_capture() without return types