code: def connect_data_and_network(
      self, outputs_collector=None, gradients_collector=None
  ):
      self.patience = self.action_param.patience
      print(vars(self.action_param))
      self.optimiser = dict()
      with tf.name_scope("OptimiserGen"):
          optimiser_class = OptimiserFactory.create(
              name=self.action_param.optimiser
          )
          self.optimiser["gen"] = optimiser_class.get_instance(
              learning_rate=self.action_param.lr
          )
  
      # 2nd optimiser could be initialized different
      with tf.name_scope("OptimiserDis"):
          optimiser_class = OptimiserFactory.create(
              name=self.action_param.optimiser
          )
          self.optimiser["dis"] = optimiser_class.get_instance(
              learning_rate=self.action_param.lr
          )
  
      fake_features, fake_logits, real_logits = self.feed_forward()
  
      d_loss, g_loss = self.compute_loss(fake_logits, real_logits)
  
      grads = dict()
      with tf.name_scope("ComputeGradientsD"):
          d_vars = tf.get_collection(
              tf.GraphKeys.TRAINABLE_VARIABLES,
              scope=self.net.d_net.layer_scope().name,
          )
          grads["dis"] = self.optimiser["dis"].compute_gradients(
              d_loss, var_list=d_vars
          )
      with tf.name_scope("ComputeGradientsG"):
          g_vars = tf.get_collection(
              tf.GraphKeys.TRAINABLE_VARIABLES,
              scope=self.net.g_net.layer_scope().name,
          )
          grads["gen"] = self.optimiser["gen"].compute_gradients(
              g_loss, var_list=g_vars
          )
  
      gradients_collector.add_to_collection(grads)
  
      self.collect_results(
          d_loss, fake_features, g_loss, outputs_collector
      )
  
imports: from __future__ import absolute_import, print_function
  import tensorflow
  from niftynet.application.base_application import BaseApplication
  from niftynet.engine.application_factory import ApplicationNetFactory
  from niftynet.engine.application_factory import OptimiserFactory
  from niftynet.engine.application_variables import CONSOLE
  from niftynet.engine.application_variables import TF_SUMMARIES
  from niftynet.engine.sampler_random_vector_v2 import RandomVectorSampler
  from niftynet.layer.convolution import ConvolutionalLayer
  from niftynet.layer.fully_connected import FullyConnectedLayer
  from niftynet.network.base_net import BaseNet
label_desc: Use image node_id 2 for calling the ToyApplicationMultOpti obj's underlying member method code with example usage: obj.connect_data_and_network(outputs_collector, gradients_collector) without return types