message: Add test case for record_summaries_every_n_global_steps
  This test case illustrates how to use
  record_summaries_every_n_global_steps and tf.all_summaries()
  in graph mode. There are no tests using
  record_summaries_every_n_global_steps. All existing graph
  based tests don't use tf.all_summaries() creating the impression
  that summary ops will somehow always run, which is not the case.
diff: @@ -29,6 +29,7 @@ from tensorflow.python.framework import dtypes
  from tensorflow.python.framework import ops
  from tensorflow.python.ops import array_ops
  from tensorflow.python.ops import control_flow_ops
  +from tensorflow.python.ops import state_ops
  from tensorflow.python.platform import test
  from tensorflow.python.training import training_util
  @@ -53,6 +54,37 @@ class DbTest(summary_test_util.SummaryDbTest):
  six.assertCountEqual(self, [name],
  get_all(self.db, 'SELECT node_name FROM Nodes'))
  + def testScalarSummary(self):
  + """Test record_summaries_every_n_global_steps and all_summaries()."""
  + with ops.Graph().as_default(), self.test_session() as sess:
  + global_step = training_util.get_or_create_global_step()
  + global_step.initializer.run()
  + with ops.device('/cpu:0'):
  + step_increment = state_ops.assign_add(global_step, 1)
  + sess.run(step_increment) # Increment global step from 0 to 1
  +
  + logdir = tempfile.mkdtemp()
  + with summary_ops.create_file_writer(logdir, max_queue=0,
  + name='t2').as_default():
  + with summary_ops.record_summaries_every_n_global_steps(2):
  + summary_ops.initialize()
  + summary_op = summary_ops.scalar('my_scalar', 2.0)
  +
  + # Neither of these should produce a summary because
  + # global_step is 1 and "1 % 2 != 0"
  + sess.run(summary_ops.all_summary_ops())
  + sess.run(summary_op)
  + events = summary_test_util.events_from_logdir(logdir)
  + self.assertEqual(len(events), 1)
  +
  + # Increment global step from 1 to 2 and check that the summary
  + # is now written
  + sess.run(step_increment)
  + sess.run(summary_ops.all_summary_ops())
  + events = summary_test_util.events_from_logdir(logdir)
  + self.assertEqual(len(events), 2)
  + self.assertEqual(events[1].summary.value[0].tag, 'cond/my_scalar')
  +
  def testSummaryGraphModeCond(self):
  with ops.Graph().as_default(), self.test_session():
  training_util.get_or_create_global_step()
  