code: def impose_weight(npts, noweight):
      """generate a function, that constrains measure weights
  
      npts is a tuple of the product_measure dimensionality
  
      noweight is a dict of collapses, or a tuple of dicts of collapses.
      a noweight collapse is a dict of {measure: {indices}), where the
      indices are where the measure will be constrained to have zero weight
  
      Examples:
          >>> wts = {0: {1}, 1: {1, 2}}
          >>> npts = (3,3)
          >>>
          >>> @impose_weight(npts, wts)
          ... def doit(x):
          ...   return x
          ...
          >>> doit([.5, 0., .5, 2., 4., 6., .25, .5, .25, 6., 4., 2.])
          [0.5, 0.0, 0.5, 2.0, 4.0, 6.0, 1.0, 0.0, 0.0, 4.0, 2.0, 0.0]
          >>> doit([1./3, 1./3, 1./3, 1., 2., 3., 1./3, 1./3, 1./3, 1., 2., 3.])
          [0.5, 0.0, 0.5, 1.0, 2.0, 3.0, 1.0, 0.0, 0.0, 2.0, 3.0, 4.0]
      """
      return impose_measure(npts, {}, noweight)
  
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 34 for calling a global function with example usage: impose_weight(npts, noweight) and returns: impose_measure