code: def impose_as(mask, offset=None):
      """generate a function, where some input tracks another input
  
      mask should be a set of tuples of positional index and tracked index,
      where the tuple should contain two different integers. The mask will be
      applied to the input, before the decorated function is called.
  
      The offset is applied to the second member of the tuple, and can accumulate.
  
      Examples:
          >>> @impose_as([(0,1),(3,1),(4,5),(5,6),(5,7)])
          ... def same(x):
          ...   return x
          ...
          >>> same([9,8,7,6,5,4,3,2,1])
          [9, 9, 7, 9, 5, 5, 5, 5, 1]
          >>> same([0,1,0,1])
          [0, 0, 0, 0]
          >>> same([-1,-2,-3,-4,-5,-6,-7])
          [-1, -1, -3, -1, -5, -5, -5]
  
          >>> @impose_as([(0,1),(3,1),(4,5),(5,6),(5,7)], 10)
          ... def doit(x):
          ...   return x
          ...
          >>> doit([9,8,7,6,5,4,3,2,1])
          [9, 19, 7, 9, 5, 15, 25, 25, 1]
          >>> doit([0,1,0,1])
          [0, 10, 0, 0]
          >>> doit([-1,-2,-3,-4,-5,-6])
          [-1, 9, -3, -1, -5, 5]
          >>> doit([-1,-2,-3,-4,-5,-6,-7])
          [-1, 9, -3, -1, -5, 5, 15]
      """
      import copy
  
      if offset is None:
          offset = 0
  
      def dec(f):
          def func(x, *args, **kwds):
              x = copy.copy(x)  # XXX: inefficient
              pairs = connected(mask)
              pairs = pairs.items()
              for i, j in pairs:
                  for k in j:
                      try:
                          x[k] = x[i]
                      except IndexError:
                          pass
              pairs = list(mask)  # XXX: inefficient
              while pairs:  # deal with the offset
                  indx, trac = zip(*pairs)
                  trac = set(trac)
                  for i in trac:
                      try:
                          x[i] += offset
                      except IndexError:
                          pass
                  indx = trac.intersection(indx)
                  pairs = [m for m in pairs if m[0] in indx]
              return f(x, *args, **kwds)
  
          func.__wrapped__ = f  # XXX: getattr(f, '__wrapped__', f) ?
          func.__doc__ = f.__doc__
          func.mask = mask
          return func
  
      return dec
  
imports: from mystic.math.measures import *
  from mystic.math import almostEqual
  from numpy import sum
  from numpy import asfarray, asarray, choose, zeros, ones, ndarray
  from numpy import shape, broadcast, empty, atleast_1d
  from numpy import round, abs
  from random import randrange, shuffle
  from numpy import array, intersect1d, inf, isnan, where, choose, clip
  from numpy.random import uniform, choice
  from numpy import maximum, minimum
  from numpy import round, abs
  from mystic.tools import synchronized, connected
  from mystic.math.discrete import product_measure
label_desc: Use image node_id 30 for calling a global function with example usage: impose_as(mask, offset) and returns: dec, func, f