code: def layer_op(self, inputs, deformation, **kwargs):
      nof_dims = infer_spatial_rank(inputs)
      nof_output_dims = infer_spatial_rank(deformation)
  
      batch_size = inputs.shape.as_list()[0]
      if deformation.shape.as_list()[0] != batch_size:
          deformation = tf.tile(
              deformation, [batch_size] + [1] * (nof_output_dims + 1)
          )
  
      output_spatial_dims = deformation.shape.as_list()[1:-1]
      input_dims = [d if d else -1 for d in inputs.shape.as_list()]
      if len(output_spatial_dims) != nof_dims:
          resample_def = deformation
          while len(resample_def.shape) < len(inputs.shape):
              resample_def = tf.expand_dims(
                  resample_def, axis=len(resample_def.shape) - 2
              )
      else:
          resample_def = deformation
      assert infer_spatial_rank(resample_def) == nof_dims
  
      resampled = get_niftyreg_module().niftyreg_image_resampling(
          _transpose(inputs),
          _transpose(resample_def),
          interpolation=self._interpolation,
          boundary=__BOUNDARY_CODES__[self._boundary],
      )
  
      return tf.reshape(
          _transpose(resampled),
          [batch_size] + output_spatial_dims + [input_dims[-1]],
      )
  
file_path: NiftyNet/niftynet/contrib/niftyreg_image_resampling/niftyreg_image_resampling.py
imports: from __future__ import print_function, division
  import tensorflow
  from tensorflow.python.framework import ops
  from niftynet.layer.base_layer import Layer
  from niftynet.layer.layer_util import infer_spatial_rank
  from niftyreg_module_loader import get_niftyreg_module
label_desc: Use image node_id 2 for calling the NiftyregImageResamplingLayer obj's underlying member method code with example usage: obj.layer_op(inputs, deformation) and returns: tf