code: def test_multi_device_multi_optimiser_gradients(self):
      test_driver = get_initialised_driver(
          application="tests.toy_application.ToyApplicationMultOpti"
      )
      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)
              # query generator gradient sample to check
              dis_0, dis_1, dis_2, dis_3, dis_ave = sess.run(
                  [
                      graph.get_tensor_by_name(
                          "worker_0/ComputeGradientsD/gradients/AddN_5:0"
                      ),
                      graph.get_tensor_by_name(
                          "worker_1/ComputeGradientsD/gradients/AddN_5:0"
                      ),
                      graph.get_tensor_by_name(
                          "worker_2/ComputeGradientsD/gradients/AddN_5:0"
                      ),
                      graph.get_tensor_by_name(
                          "worker_3/ComputeGradientsD/gradients/AddN_5:0"
                      ),
                      graph.get_tensor_by_name(
                          "ApplyGradients/AveOverDevices:0"
                      ),
                  ]
              )
  
              # query discriminator gradient sample to check
              gen_0, gen_1, gen_2, gen_3, gen_ave = sess.run(
                  [
                      graph.get_tensor_by_name(
                          "worker_0/ComputeGradientsG/gradients/worker_0/tinynet/G/conv/conv_/conv/ExpandDims_1_grad/Reshape:0"
                      ),
                      graph.get_tensor_by_name(
                          "worker_1/ComputeGradientsG/gradients/worker_1/tinynet/G/conv/conv_/conv/ExpandDims_1_grad/Reshape:0"
                      ),
                      graph.get_tensor_by_name(
                          "worker_2/ComputeGradientsG/gradients/worker_2/tinynet/G/conv/conv_/conv/ExpandDims_1_grad/Reshape:0"
                      ),
                      graph.get_tensor_by_name(
                          "worker_3/ComputeGradientsG/gradients/worker_3/tinynet/G/conv/conv_/conv/ExpandDims_1_grad/Reshape:0"
                      ),
                      graph.get_tensor_by_name(
                          "ApplyGradients/AveOverDevices_14:0"
                      ),
                  ]
              )
              self.check_gradients(gen_0, gen_1, gen_2, gen_3, gen_ave)
              self.check_gradients(dis_0, dis_1, dis_2, dis_3, dis_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 5 for calling the ApplicationDriverTest obj's underlying member method code with example usage: obj.test_multi_device_multi_optimiser_gradients() without return types