code: def _computing_bending_energy_3d(displacement):
      """
  
      :param displacement: 3D tensor, displacement field
      :return: bending energy
      """
      dTdx = ImgGrad(spatial_axis=0)(displacement)
      dTdy = ImgGrad(spatial_axis=1)(displacement)
      dTdz = ImgGrad(spatial_axis=2)(displacement)
  
      dTdxx = ImgGrad(spatial_axis=0)(dTdx)
      dTdyy = ImgGrad(spatial_axis=1)(dTdy)
      dTdzz = ImgGrad(spatial_axis=2)(dTdz)
  
      dTdxy = ImgGrad(spatial_axis=1)(dTdx)
      dTdyz = ImgGrad(spatial_axis=2)(dTdy)
      dTdxz = ImgGrad(spatial_axis=2)(dTdx)
  
      energy = tf.reduce_mean(
          [
              dTdxx * dTdxx,
              dTdyy * dTdyy,
              dTdzz * dTdzz,
              2 * dTdxy * dTdxy,
              2 * dTdxz * dTdxz,
              2 * dTdyz * dTdyz,
          ]
      )
      return energy
  
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 5 for calling a global function with example usage: _computing_bending_energy_3d(displacement) and returns: energy