code: def _smoothing_func(sigma):
      def smoothing(dense_field, spatial_rank):
          """
  
          :param dense_field: tensor, dense field to be smoothed
          :param spatial_rank: int, rank of input images
          :return: smoothed dense field
          """
          kernel = _get_smoothing_kernel(sigma, spatial_rank)
          kernel = tf.constant(kernel, dtype=dense_field.dtype)
          kernel = tf.expand_dims(kernel, axis=-1)
          kernel = tf.expand_dims(kernel, axis=-1)
          smoothed = [
              tf.nn.convolution(
                  tf.expand_dims(coord, axis=-1), kernel, "SAME"
              )
              for coord in tf.unstack(dense_field, axis=-1)
          ]
          return tf.concat(smoothed, axis=-1)
  
      return smoothing
  
imports: from __future__ import absolute_import, print_function
  import numpy
  import tensorflow
  from tensorflow.contrib.layers.python.layers import regularizers
  from niftynet.engine.application_initializer import GlorotUniform
  from niftynet.layer.convolution import ConvolutionalLayer
  from niftynet.layer.downsample_res_block import DownBlock
  from niftynet.layer.grid_warper import _create_affine_features
  from niftynet.layer.layer_util import infer_spatial_rank, check_spatial_dims
  from niftynet.layer.linear_resize import LinearResizeLayer
  from niftynet.layer.spatial_gradient import SpatialGradientLayer
  from niftynet.layer.upsample_res_block import UpBlock
  from niftynet.network.base_net import BaseNet
label_desc: Use image node_id 2 for calling a global function with example usage: _smoothing_func(sigma) and returns: smoothing, tf