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","."]
docstr: computes a relative transformation
  mapping <-1..1, -1..1, -1..1> to <-1..1, -1..1, -1..1> (in 3D)
  or <-1..1, -1..1> to <-1..1, -1..1> (in 2D).
  
  :param batch_size: number of different random transformations
  :param spatial_rank: number of spatial dimensions
  :return:
docstr_tok: ["computes","a","relative","transformation","mapping","<","-1","..","1",",","-1","..","1",",","-1","..","1",">","to","<","-1","..","1",",","-1","..","1",",","-1","..","1",">","(","in","3D",")","or","<","-1","..","1",",","-1","..","1",">","to","<","-1","..","1",",","-1","..","1",">","(","in","2D",")",".",":","param","batch_size",":","number","of","different","random","transformations",":","param","spatial_rank",":","number","of","spatial","dimensions",":","return",":"]
code: def _random_transform(self, batch_size, spatial_rank):
      """
      computes a relative transformation
      mapping <-1..1, -1..1, -1..1> to <-1..1, -1..1, -1..1> (in 3D)
      or <-1..1, -1..1> to <-1..1, -1..1> (in 2D).
  
      :param batch_size: number of different random transformations
      :param spatial_rank: number of spatial dimensions
      :return:
      """
      output_corners = get_relative_corners(spatial_rank)
      output_corners = tf.tile([output_corners], [batch_size, 1, 1])
  
      # make randomised output corners
      random_size = [batch_size, 2**spatial_rank, spatial_rank]
      random_scale = tf.random_uniform(
          random_size, 1.0 - self.scale, 1.0
      )
      source_corners = output_corners * random_scale
  
      # make homogeneous corners
      batch_ones = tf.ones_like(output_corners[..., 0:1])
      source_corners = tf.concat([source_corners, batch_ones], -1)
      output_corners = tf.concat([output_corners, batch_ones], -1)
  
      ls_transform = tf.matrix_solve_ls(output_corners, source_corners)
      return tf.transpose(ls_transform, [0, 2, 1])
  
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 2 for calling the AffineAugmentationLayer obj's underlying member method code with example usage: obj._random_transform(batch_size, spatial_rank) and returns: tf