docstr: Performs channel-wise merging of input tensors
  :param roots: tensors to be merged
  :return: fused tensor
docstr_tok: ["Performs","channel-wise","merging","of","input","tensors",":","param","roots",":","tensors","to","be","merged",":","return",":","fused","tensor"]
code: def layer_op(self, roots):
      """
      Performs channel-wise merging of input tensors
      :param roots: tensors to be merged
      :return: fused tensor
      """
      if self.func == "MAXOUT":
          return tf.reduce_max(tf.stack(roots, axis=-1), axis=-1)
      elif self.func == "AVERAGE":
          return tf.reduce_mean(tf.stack(roots, axis=-1), axis=-1)
      elif self.func == "WEIGHTED_AVERAGE":
          input_tensor = tf.stack(roots, axis=-1)
          rank = input_tensor.shape.ndims
          perm = [i for i in range(rank)]
          perm[-2], perm[-1] = perm[-1], perm[-2]
  
          output_tensor = input_tensor
          output_tensor = tf.transpose(output_tensor, perm=perm)
          output_tensor = tf.unstack(output_tensor, axis=-1)
          roots_merged = []
          for f in range(len(output_tensor)):
              conv_layer = ConvLayer(
                  n_output_chns=1, kernel_size=1, stride=1
              )
              roots_merged_f = conv_layer(output_tensor[f])
              roots_merged.append(roots_merged_f)
          return tf.concat(roots_merged, axis=-1)
  
imports: from __future__ import absolute_import, print_function
  import tensorflow
  from niftynet.layer.base_layer import TrainableLayer
  from niftynet.layer.convolution import ConvLayer
  from niftynet.layer.convolution import ConvolutionalLayer
  from niftynet.layer.dilatedcontext import DilatedTensor
  from niftynet.layer.downsample import DownSampleLayer
  from niftynet.layer.upsample import UpSampleLayer
  from niftynet.network.base_net import BaseNet
  from niftynet.network.highres3dnet import HighResBlock
label_desc: Use image node_id 2 for calling the MergeLayer obj's underlying member method code with example usage: obj.layer_op(roots) and returns: tf, tf, tf