code: def test_multi_device_gradients(self):
      test_driver = get_initialised_driver()
      graph = test_driver.create_graph(
          test_driver.app, test_driver.num_gpus, True
      )
      with self.cached_session(graph=graph) as sess:
          SESS_STARTED.send(test_driver.app, iter_msg=None)
          for i in range(2):
              sess.run(test_driver.app.gradient_op)
              g_0, g_1, g_2, g_3, g_ave = sess.run(
                  [
                      graph.get_tensor_by_name(
                          "worker_0/ComputeGradients/gradients/AddN_5:0"
                      ),
                      graph.get_tensor_by_name(
                          "worker_1/ComputeGradients/gradients/AddN_5:0"
                      ),
                      graph.get_tensor_by_name(
                          "worker_2/ComputeGradients/gradients/AddN_5:0"
                      ),
                      graph.get_tensor_by_name(
                          "worker_3/ComputeGradients/gradients/AddN_5:0"
                      ),
                      graph.get_tensor_by_name(
                          "ApplyGradients/AveOverDevices:0"
                      ),
                  ]
              )
              self.check_gradients(g_0, g_1, g_2, g_3, g_ave)
          SESS_FINISHED.send(test_driver.app, itermsg=None)
          test_driver.app.stop()
  
imports: from __future__ import absolute_import, print_function
  import os
  import uuid
  import numpy
  import tensorflow
  from niftynet.engine.application_driver import ApplicationDriver
  from niftynet.engine.application_variables import global_vars_init_or_restore
  from niftynet.engine.handler_model import ModelRestorer
  from niftynet.io.misc_io import set_logger
  from niftynet.utilities.util_common import ParserNamespace
  from niftynet.engine.signal import SESS_FINISHED, SESS_STARTED
  from tests.niftynet_testcase import NiftyNetTestCase
label_desc: Use image node_id 4 for calling the ApplicationDriverTest obj's underlying member method code with example usage: obj.test_multi_device_gradients() without return types