code: def _run_test(self, tempdir, initial_flag):
      n_data = 4
      n_epochs = 3
      outdir = os.path.join(tempdir, "testresult")
  
      # Prepare
      model = Model()
      classifier = links.Classifier(model)
      optimizer = chainer.optimizers.Adam()
      optimizer.setup(classifier)
  
      dataset = Dataset([i for i in range(n_data)])
      iterator = chainer.iterators.SerialIterator(
          dataset, 1, shuffle=False
      )
      updater = training.updaters.StandardUpdater(iterator, optimizer)
      trainer = training.Trainer(
          updater, (n_epochs, "epoch"), out=outdir
      )
  
      extension = c.DumpGraph("main/loss", filename="test.dot")
      trainer.extend(extension)
  
      # Run
      with chainer.using_config("keep_graph_on_report", initial_flag):
          trainer.run()
  
      # Check flag history
      self.assertEqual(
          model.flag_history,
          [True] + [initial_flag] * (n_data * n_epochs - 1),
      )
  
      # Check the dumped graph
      graph_path = os.path.join(outdir, "test.dot")
      with open(graph_path) as f:
          graph_dot = f.read()
  
      # Check that only the first iteration is dumped
      self.assertIn("Function1", graph_dot)
      self.assertNotIn("Function2", graph_dot)
  
      if c.is_graphviz_available():
          self.assertTrue(
              os.path.exists(os.path.join(outdir, "test.png"))
          )
  
imports: import os
  import shutil
  import tempfile
  import unittest
  import numpy
  import chainer
  from chainer import configuration
  from chainer import links
  from chainer import testing
  from chainer import training
  from chainer.training.extensions import computational_graph
label_desc: Use image node_id 1 for calling the TestGraphBuilderKeepGraphOnReport obj's underlying member method code with example usage: obj._run_test(tempdir, initial_flag) without return types