class_docstr: Spatial transformer layer
  
  The layer applies an affine transformation on the input. The affine
  transformation is parameterized with six learned parameters [1]_.
  The output is interpolated with a bilinear transformation.
  
  Parameters
  ----------
  incoming : a :class:`Layer` instance or a tuple
      The layer feeding into this layer, or the expected input shape. The
      output of this layer should be a 4D tensor, with shape
      ``(batch_size, num_input_channels, input_rows, input_columns)``.
  
  localization_network : a :class:`Layer` instance
      The network that calculates the parameters of the affine
      transformation. See the example for how to initialize to the identity
      transform.
  
  downsample_factor : float or iterable of float
      A float or a 2-element tuple specifying the downsample factor for the
      output image (in both spatial dimensions). A value of 1 will keep the
      original size of the input. Values larger than 1 will downsample the
      input. Values below 1 will upsample the input.
  border_mode : 'nearest', 'mirror', or 'wrap'
      Determines how border conditions are handled during interpolation.  If
      'nearest', points outside the grid are clipped to the boundary. If
      'mirror', points are mirrored across the boundary. If 'wrap', points
      wrap around to the other side of the grid.  See
      http://stackoverflow.com/q/22669252/22670830#22670830 for details.
  
  References
  ----------
  .. [1]  Max Jaderberg, Karen Simonyan, Andrew Zisserman,
          Koray Kavukcuoglu (2015):
          Spatial Transformer Networks. NIPS 2015,
          http://papers.nips.cc/paper/5854-spatial-transformer-networks.pdf
  
  Examples
  --------
  Here we set up the layer to initially do the identity transform, similarly
  to [1]_. Note that you will want to use a localization with linear output.
  If the output from the localization networks is [t1, t2, t3, t4, t5, t6]
  then t1 and t5 determines zoom, t2 and t4 determines skewness, and t3 and
  t6 move the center position.
  
  >>> import numpy as np
  >>> import lasagne
  >>> b = np.zeros((2, 3), dtype='float32')
  >>> b[0, 0] = 1
  >>> b[1, 1] = 1
  >>> b = b.flatten()  # identity transform
  >>> W = lasagne.init.Constant(0.0)
  >>> l_in = lasagne.layers.InputLayer((None, 3, 28, 28))
  >>> l_loc = lasagne.layers.DenseLayer(l_in, num_units=6, W=W, b=b,
  ... nonlinearity=None)
  >>> l_trans = lasagne.layers.TransformerLayer(l_in, l_loc)
code: def __init__(
      self,
      incoming,
      localization_network,
      downsample_factor=1,
      border_mode="nearest",
      **kwargs,
  ):
      super(TransformerLayer, self).__init__(
          [incoming, localization_network], **kwargs
      )
      self.downsample_factor = as_tuple(downsample_factor, 2)
      self.border_mode = border_mode
  
      input_shp, loc_shp = self.input_shapes
  
      if loc_shp[-1] != 6 or len(loc_shp) != 2:
          raise ValueError(
              "The localization network must have "
              "output shape: (batch_size, 6)"
          )
      if len(input_shp) != 4:
          raise ValueError(
              "The input network must have a 4-dimensional "
              "output shape: (batch_size, num_input_channels, "
              "input_rows, input_columns)"
          )
  
imports: import theano
  import theano.tensor
  import numpy
  from ..None import init
  from ..None import nonlinearities
  from ..utils import as_tuple, floatX, int_types
  from ..random import get_rng
  from .base import Layer, MergeLayer
  from theano.sandbox.rng_mrg import MRG_RandomStreams
label_desc: Use image node_id 1 to create a new TransformerLayer object from inherited base classes: MergeLayer with example: obj = TransformerLayer(incoming, localization_network, downsample_factor, border_mode)