code: def autocrop(inputs, cropping):
      """
      Crops the given input arrays.
  
      Cropping takes a sequence of inputs and crops them per-axis in order to
      ensure that their sizes are consistent so that they can be combined
      in an element-wise fashion. If cropping is enabled for a specific axis,
      the minimum size in that axis of all inputs is computed, and all
      inputs are cropped to that size.
  
      The per-axis cropping modes are:
  
      `None`: this axis is not cropped, inputs are unchanged in this axis
  
      `'lower'`: inputs are cropped choosing the lower portion in this axis
      (`a[:crop_size, ...]`)
  
      `'upper'`: inputs are cropped choosing the upper portion in this axis
      (`a[-crop_size:, ...]`)
  
      `'center'`: inputs are cropped choosing the central portion in this axis
      (``a[offset:offset+crop_size, ...]`` where
      ``offset = (a.shape[0]-crop_size)//2)``
  
      Parameters
      ----------
      inputs : list of Theano expressions
          The input arrays in the form of a list of Theano expressions
  
      cropping : list of cropping modes
          Cropping modes, one for each axis. If length of `cropping` is less
          than the number of axes in the inputs, it is padded with `None`.
          If `cropping` is None, `input` is returned as is.
  
      Returns
      -------
      list of Theano expressions
          each expression is the cropped version of the corresponding input
  
      Example
      -------
      For example, given three inputs:
  
      >>> import numpy
      >>> import theano
  
      >>> a = numpy.random.random((1, 2, 3, 4))
      >>> b = numpy.random.random((5, 4, 4, 2))
      >>> c = numpy.random.random((7, 1, 8, 9))
  
      Cropping mode for each axis:
  
      >>> cropping = [None, 'lower', 'center', 'upper']
  
      Crop (note that the input arrays are converted to Theano vars first,
      and that the results are converted back from Theano expressions to
      numpy arrays by calling `eval()`)
      >>> xa, xb, xc = autocrop([theano.shared(a), \
                                 theano.shared(b), \
                                 theano.shared(c)], cropping)
      >>> xa, xb, xc = xa.eval(), xb.eval(), xc.eval()
  
      They will be left as is in axis 0 and cropped in the other three,
      choosing the lower, center and upper portions:
  
      Axis 0: choose all, axis 1: lower 1 element,
      axis 2: central 3 (all) and axis 3: upper 2
      >>> (xa == a[:, :1, :3, -2:]).all()
      True
  
      Axis 0: choose all, axis 1: lower 1 element,
      axis 2: central 3 starting at 0 and axis 3: upper 2 (all)
      >>> (xb == b[:, :1, :3, -2:]).all()
      True
  
      Axis 0: all, axis 1: lower 1 element (all),
      axis 2: central 3 starting at 2 and axis 3: upper 2
      >>> (xc == c[:, :1, 2:5:, -2:]).all()
      True
      """
      if cropping is None:
          # No cropping in any dimension
          return inputs
      else:
          # Get the number of dimensions
          ndim = inputs[0].ndim
          # Check for consistent number of dimensions
          if not all(input.ndim == ndim for input in inputs):
              raise ValueError(
                  "Not all inputs are of the same "
                  "dimensionality. Got {0} inputs of "
                  "dimensionalities {1}.".format(
                      len(inputs), [input.ndim for input in inputs]
                  )
              )
          # Get the shape of each input, where each shape will be a Theano
          # expression
          shapes = [input.shape for input in inputs]
          # Convert the shapes to a matrix expression
          shapes_tensor = T.as_tensor_variable(shapes)
          # Min along axis 0 to get the minimum size in each dimension
          min_shape = T.min(shapes_tensor, axis=0)
  
          # Nested list of slices; each list in `slices` corresponds to
          # an input and contains a slice for each dimension
          slices_by_input = [[] for i in range(len(inputs))]
  
          # If there are more dimensions than cropping entries, pad
          # the cropping
          cropping = list(cropping)
          if ndim > len(cropping):
              cropping = list(cropping) + [None] * (
                  ndim - len(cropping)
              )
  
          # For each dimension
          for dim, cr in enumerate(cropping):
              if cr is None:
                  # Don't crop this dimension
                  slice_all = slice(None)
                  for slices in slices_by_input:
                      slices.append(slice_all)
              else:
                  # We crop all inputs in the dimension `dim` so that they
                  # are the minimum found in this dimension from all inputs
                  sz = min_shape[dim]
                  if cr == "lower":
                      # Choose the first `sz` elements
                      slc_lower = slice(None, sz)
                      for slices in slices_by_input:
                          slices.append(slc_lower)
                  elif cr == "upper":
                      # Choose the last `sz` elements
                      slc_upper = slice(-sz, None)
                      for slices in slices_by_input:
                          slices.append(slc_upper)
                  elif cr == "center":
                      # Choose `sz` elements from the center
                      for sh, slices in zip(shapes, slices_by_input):
                          offset = (sh[dim] - sz) // 2
                          slices.append(slice(offset, offset + sz))
                  else:
                      raise ValueError(
                          "Unknown crop mode '{0}'".format(cr)
                      )
  
          return [
              input[slices]
              for input, slices in zip(inputs, slices_by_input)
          ]
  
file_path: Lasagne/lasagne/layers/merge.py
imports: import theano.tensor
  from .base import MergeLayer
label_desc: Use image node_id 1 for calling a global function with example usage: autocrop(inputs, cropping) and returns: inputs, unknown