class_docstr: Affine Grid Warper class.
  
  The affine grid warper generates a reference grid of n-dimensional points
  and warps it via an affine transformation model determined by an input
  parameter Tensor. Some of the transformation parameters can be fixed at
  construction time via an `AffineWarpConstraints` object.
docstr: Constructs an AffineGridWarper.
  
  `source_shape` and `output_shape` are used to define shape of source
  and output signal domains, as opposed to the shape of the respective
  Tensors.
  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 shape of source
      signal domain.
    output_shape: Iterable of integers determining shape of destination
      resampled signal domain.
    constraints: Either a double list of shape `[N, N+1]`
      defining constraints
      on the entries of a matrix defining an affine transformation in N
      dimensions, or an `AffineWarpConstraints` object.
      If the double list is passed, a numeric value bakes
      in a constraint on the corresponding
      entry in the transformation matrix, whereas `None` implies that the
      corresponding entry will be specified at run time.
    name: Name of module.
  
  Raises:
    Error: If constraints fully define the affine transformation; or if
      input grid shape and constraints have different dimensionality.
    TypeError: If output_shape and source_shape are not both iterable.
docstr_tok: ["Constructs","an","AffineGridWarper",".","`","source_shape","`","and","`","output_shape","`","are","used","to","define","shape","of","source","and","output","signal","domains",",","as","opposed","to","the","shape","of","the","respective","Tensors",".","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","shape","of","source","signal","domain",".","output_shape",":","Iterable","of","integers","determining","shape","of","destination","resampled","signal","domain",".","constraints",":","Either","a","double","list","of","shape","`","[","N",",","N+1","]","`","defining","constraints","on","the","entries","of","a","matrix","defining","an","affine","transformation","in","N","dimensions",",","or","an","`","AffineWarpConstraints","`","object",".","If","the","double","list","is","passed",",","a","numeric","value","bakes","in","a","constraint","on","the","corresponding","entry","in","the","transformation","matrix",",","whereas","`","None","`","implies","that","the","corresponding","entry","will","be","specified","at","run","time",".","name",":","Name","of","module",".","Raises",":","Error",":","If","constraints","fully","define","the","affine","transformation",";","or","if","input","grid","shape","and","constraints","have","different","dimensionality",".","TypeError",":","If","output_shape","and","source_shape","are","not","both","iterable","."]
code: def __init__(
      self,
      source_shape,
      output_shape,
      constraints=None,
      name="affine_grid_warper",
  ):
      """Constructs an AffineGridWarper.
  
      `source_shape` and `output_shape` are used to define shape of source
      and output signal domains, as opposed to the shape of the respective
      Tensors.
      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 shape of source
          signal domain.
        output_shape: Iterable of integers determining shape of destination
          resampled signal domain.
        constraints: Either a double list of shape `[N, N+1]`
          defining constraints
          on the entries of a matrix defining an affine transformation in N
          dimensions, or an `AffineWarpConstraints` object.
          If the double list is passed, a numeric value bakes
          in a constraint on the corresponding
          entry in the transformation matrix, whereas `None` implies that the
          corresponding entry will be specified at run time.
        name: Name of module.
  
      Raises:
        Error: If constraints fully define the affine transformation; or if
          input grid shape and constraints have different dimensionality.
        TypeError: If output_shape and source_shape are not both iterable.
      """
      self._source_shape = tuple(source_shape)
      self._output_shape = tuple(output_shape)
      num_dim = len(source_shape)
      if isinstance(constraints, AffineWarpConstraints):
          self._constraints = constraints
      elif constraints is None:
          self._constraints = AffineWarpConstraints.no_constraints(
              num_dim
          )
      else:
          self._constraints = AffineWarpConstraints(
              constraints=constraints
          )
  
      if self._constraints.num_free_params == 0:
          tf.logging.fatal("Transformation is fully constrained.")
          raise ValueError
  
      if self._constraints.num_dim != num_dim:
          tf.logging.fatal(
              "Incompatible set of constraints provided: "
              "input grid shape and constraints have different "
              "dimensionality."
          )
          raise ValueError
  
      GridWarperLayer.__init__(
          self,
          source_shape=source_shape,
          output_shape=output_shape,
          coeff_shape=[6],
          name=name,
          constraints=self._constraints,
      )
  
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 AffineGridWarperLayer object from inherited base classes: GridWarperLayer, Invertible with example: obj = AffineGridWarperLayer(source_shape, output_shape, constraints, name)