code: def alignment(layer, decay_ratio=2):
      """Encourage neighboring images to be similar.
  
      When visualizing the interpolation between two objectives, it's often
      desirable to encourage analogous objects to be drawn in the same position,
      to make them more comparable.
  
      This term penalizes L2 distance between neighboring images, as evaluated at
      layer.
  
      In general, we find this most effective if used with a parameterization that
      shares across the batch. (In fact, that works quite well by itself, so this
      function may just be obsolete.)
  
      Args:
        layer: layer to penalize at.
        decay_ratio: how much to decay penalty as images move apart in batch.
  
      Returns:
        Objective.
      """
  
      def inner(T):
          batch_n = T(layer).get_shape().as_list()[0]
          arr = T(layer)
          accum = 0
          for d in [1, 2, 3, 4]:
              for i in range(batch_n - d):
                  a, b = i, i + d
                  arr1, arr2 = arr[a], arr[b]
                  accum += tf.reduce_mean(
                      (arr1 - arr2) ** 2
                  ) / decay_ratio ** float(d)
          return -accum
  
      return inner
  
imports: from __future__ import absolute_import, division, print_function
  from decorator import decorator
  import numpy
  import tensorflow
  from lucid.optvis.objectives_util import _dot, _dot_cossim, _extract_act_pos, _make_arg_str, _T_force_NHWC, _T_handle_batch
label_desc: Use image node_id 17 for calling a global function with example usage: alignment(layer, decay_ratio) and returns: inner, unknown