class_docstr: This layer applies a small random (per-iteration) affine
  transformation to an image. The distribution of transformations
  generally results in scaling the image up, with minimal sampling
  outside the original image.
class_docstr_tok: ["This","layer","applies","a","small","random","(","per-iteration",")","affine","transformation","to","an","image",".","The","distribution","of","transformations","generally","results","in","scaling","the","image","up",",","with","minimal","sampling","outside","the","original","image","."]
code: def layer_op(self, input_tensor):
      input_shape = input_tensor.shape.as_list()
      batch_size = input_shape[0]
      spatial_shape = input_shape[1:-1]
      spatial_rank = infer_spatial_rank(input_tensor)
  
      if self._transform is None:
          relative_transform = self._random_transform(
              batch_size, spatial_rank
          )
          self._transform = relative_transform
      else:
          relative_transform = self._transform
  
      grid_warper = AffineGridWarperLayer(spatial_shape, spatial_shape)
      resampler = ResamplerLayer(
          interpolation=self.interpolation, boundary=self.boundary
      )
      warp_parameters = tf.reshape(
          relative_transform[:, :spatial_rank, :], [batch_size, -1]
      )
      grid = grid_warper(warp_parameters)
      resampled = resampler(input_tensor, grid)
      return resampled
  
file_path: NiftyNet/niftynet/layer/affine_augmentation.py
imports: from __future__ import absolute_import, print_function
  import tensorflow
  from niftynet.layer.base_layer import Layer
  from niftynet.layer.grid_warper import AffineGridWarperLayer
  from niftynet.layer.layer_util import infer_spatial_rank
  from niftynet.layer.resampler import ResamplerLayer
label_desc: Use image node_id 3 for calling the AffineAugmentationLayer obj's underlying member method code with example usage: obj.layer_op(input_tensor) and returns: resampled