code: def connect_data_and_network(
      self, outputs_collector=None, gradients_collector=None
  ):
      if self.is_training:
          # using the original training pipeline
          RegressionApplication.connect_data_and_network(
              self, outputs_collector, gradients_collector
          )
      else:
          init_aggregator = self.SUPPORTED_SAMPLING[
              self.net_param.window_sampling
          ][2]
          init_aggregator()
  
          # modifying the original pipeline so that
          # the error maps are computed instead of the regression output
          with tf.name_scope("validation"):
              data_dict = self.get_sampler()[0][-1].pop_batch_op()
          image = tf.cast(data_dict["image"], tf.float32)
          net_out = self.net(image, is_training=self.is_training)
  
          if self.regression_param.error_map:
              # writing error maps to folder without prefix
              error_map_folder = os.path.join(
                  os.path.dirname(self.action_param.save_seg_dir),
                  "error_maps",
              )
              self.output_decoder.output_path = error_map_folder
              self.output_decoder.prefix = ""
  
              # computes absolute error
              target = tf.cast(data_dict["output"], tf.float32)
              net_out = tf.squared_difference(target, net_out)
  
          # window output and locations for aggregating volume results
          outputs_collector.add_to_collection(
              var=net_out,
              name="window",
              average_over_devices=False,
              collection=NETWORK_OUTPUT,
          )
          outputs_collector.add_to_collection(
              var=data_dict["image_location"],
              name="location",
              average_over_devices=False,
              collection=NETWORK_OUTPUT,
          )
  
file_path: NiftyNet/niftynet/contrib/regression_weighted_sampler/isample_regression.py
imports: import os
  import tensorflow
  from niftynet.application.regression_application import RegressionApplication, SUPPORTED_INPUT
  from niftynet.engine.sampler_uniform_v2 import UniformSampler
  from niftynet.engine.sampler_weighted_v2 import WeightedSampler
  from niftynet.engine.application_variables import NETWORK_OUTPUT
  from niftynet.io.image_reader import ImageReader
  from niftynet.layer.histogram_normalisation import HistogramNormalisationLayer
  from niftynet.layer.mean_variance_normalisation import MeanVarNormalisationLayer
  from niftynet.layer.pad import PadLayer
label_desc: Use image node_id 2 for calling the ISampleRegression obj's underlying member method code with example usage: obj.connect_data_and_network(outputs_collector, gradients_collector) without return types