code: def init_affine_b(spatial_rank, initial_bias=0.0):
      """
  
      :param spatial_rank: int, rank of inputs (either 2D or 3D)
      :param initial_bias: float, initial bias
      :return: bias initialisation for the affine matrix
      """
      if spatial_rank == 2:
          identity = np.array(
              [[1.0, 0.0, 0.0], [0.0, 1.0, 0.0]]
          ).flatten()
      elif spatial_rank == 3:
          identity = np.array(
              [[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0]]
          ).flatten()
      else:
          tf.logging.fatal("Not supported spatial rank")
          raise NotImplementedError
      identity = identity.reshape([1, -1])
      identity = np.tile(identity, [1, 1])
      return tf.constant_initializer(identity + initial_bias)
  
file_path: NiftyNet/niftynet/network/interventional_affine_net.py
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.fully_connected import FullyConnectedLayer
  from niftynet.layer.grid_warper import AffineGridWarperLayer
  from niftynet.layer.layer_util import infer_spatial_rank
  from niftynet.layer.linear_resize import LinearResizeLayer
  from niftynet.network.base_net import BaseNet
label_desc: Use image node_id 2 for calling a global function with example usage: init_affine_b(spatial_rank, initial_bias) and returns: tf