code: def test_add_to_single_device(self):
      n_device = 1
      collector = OutputsCollector(n_devices=n_device)
      for idx in range(n_device):
          with tf.name_scope("worker_%d" % idx):
              image = tf.ones([2, 32, 32, 32, 1])
              foo = tf.zeros([2, 2])
              bar = tf.zeros([42])
              collector.add_to_collection(
                  name="image", var=image, average_over_devices=False
              )
              collector.add_to_collection(
                  name="foo", var=foo, average_over_devices=False
              )
              collector.add_to_collection(
                  name="bar",
                  var=bar,
                  collection=NETWORK_OUTPUT,
                  average_over_devices=False,
              )
      self.assertDictEqual(
          collector.variables(collection=CONSOLE),
          {"image": image, "foo": foo},
      )
      self.assertDictEqual(
          collector.variables(collection=NETWORK_OUTPUT), {"bar": bar}
      )
  
file_path: NiftyNet/tests/output_collector_test.py
imports: from __future__ import absolute_import, print_function
  import tensorflow
  from niftynet.engine.application_variables import NETWORK_OUTPUT, CONSOLE, TF_SUMMARIES
  from niftynet.engine.application_variables import OutputsCollector
  from tests.niftynet_testcase import NiftyNetTestCase
label_desc: Use image node_id 1 for calling the OutputCollectorTest obj's underlying member method code with example usage: obj.test_add_to_single_device() without return types