class_docstr: Grid warper interface class.
  
  An object implementing the `GridWarper` interface
  generates a reference grid of feature points at construction time,
  and warps it via a parametric transformation model,
  specified at run time by an input parameter Tensor.
  Grid warpers must then implement a `create_features` function
  used to generate the reference grid to be warped
  in the forward pass (according to a determined warping model).
docstr: Constructs a GridWarper module and
  initializes the source grid params.
  
  `source_shape` and `output_shape` defines the size of the source
  and output signal domains.
  
  For example,
  for an image of size `width=W` and `height=H`,
  `{source,output}_shape=[H, W]`;
  for a volume of size `width=W`, `height=H`
  and `depth=D`, `{source,output}_shape=[H, W, D]`.
  
  Args:
    source_shape: Iterable of integers determining
      the size of the source signal domain.
    output_shape: Iterable of integers determining
      the size of the destination resampled signal domain.
    coeff_shape: Shape of coefficients parameterizing the grid warp.
      For example, a 2D affine transformation will be defined by the [6]
      parameters populating the corresponding 2x3 affine matrix.
    name: Name of Module.
    **kwargs: Extra kwargs to be forwarded to
      the `create_features` function,
      instantiating the source grid parameters.
  
  Raises:
    Error: If `len(output_shape) > len(source_shape)`.
    TypeError: If `output_shape` and `source_shape`
      are not both iterable.
docstr_tok: ["Constructs","a","GridWarper","module","and","initializes","the","source","grid","params",".","`","source_shape","`","and","`","output_shape","`","defines","the","size","of","the","source","and","output","signal","domains",".","For","example",",","for","an","image","of","size","`","width=W","`","and","`","height=H","`",",","`","{","source",",","output","}","_shape=","[","H",",","W","]","`",";","for","a","volume","of","size","`","width=W","`",",","`","height=H","`","and","`","depth=D","`",",","`","{","source",",","output","}","_shape=","[","H",",","W",",","D","]","`",".","Args",":","source_shape",":","Iterable","of","integers","determining","the","size","of","the","source","signal","domain",".","output_shape",":","Iterable","of","integers","determining","the","size","of","the","destination","resampled","signal","domain",".","coeff_shape",":","Shape","of","coefficients","parameterizing","the","grid","warp",".","For","example",",","a","2D","affine","transformation","will","be","defined","by","the","[","6","]","parameters","populating","the","corresponding","2x3","affine","matrix",".","name",":","Name","of","Module",".","*","*","kwargs",":","Extra","kwargs","to","be","forwarded","to","the","`","create_features","`","function",",","instantiating","the","source","grid","parameters",".","Raises",":","Error",":","If","`","len","(","output_shape",")",">","len","(","source_shape",")","`",".","TypeError",":","If","`","output_shape","`","and","`","source_shape","`","are","not","both","iterable","."]
code: def __init__(
      self, source_shape, output_shape, coeff_shape, name, **kwargs
  ):
      """
      Constructs a GridWarper module and
      initializes the source grid params.
  
      `source_shape` and `output_shape` defines the size of the source
      and output signal domains.
  
      For example,
      for an image of size `width=W` and `height=H`,
      `{source,output}_shape=[H, W]`;
      for a volume of size `width=W`, `height=H`
      and `depth=D`, `{source,output}_shape=[H, W, D]`.
  
      Args:
        source_shape: Iterable of integers determining
          the size of the source signal domain.
        output_shape: Iterable of integers determining
          the size of the destination resampled signal domain.
        coeff_shape: Shape of coefficients parameterizing the grid warp.
          For example, a 2D affine transformation will be defined by the [6]
          parameters populating the corresponding 2x3 affine matrix.
        name: Name of Module.
        **kwargs: Extra kwargs to be forwarded to
          the `create_features` function,
          instantiating the source grid parameters.
  
      Raises:
        Error: If `len(output_shape) > len(source_shape)`.
        TypeError: If `output_shape` and `source_shape`
          are not both iterable.
      """
      super(GridWarperLayer, self).__init__(name=name)
  
      self._source_shape = tuple(source_shape)
      self._output_shape = tuple(output_shape)
      if len(self._output_shape) > len(self._source_shape):
          tf.logging.fatal(
              "Output domain dimensionality (%s) must be equal or "
              "smaller than source domain dimensionality (%s)",
              len(self._output_shape),
              len(self._source_shape),
          )
          raise ValueError
  
      self._coeff_shape = coeff_shape
      self._psi = self._create_features(**kwargs)
  
imports: from __future__ import absolute_import, division, print_function
  from itertools import chain
  import numpy
  import tensorflow
  from niftynet.layer.base_layer import Layer, LayerFromCallable, Invertible
label_desc: Use image node_id 1 to create a new GridWarperLayer object from inherited base classes: Layer with example: obj = GridWarperLayer(source_shape, output_shape, coeff_shape, name)