code: def vectorize(constraint, axis=1):
      """vectorize a 1D constraint function ``x' = c(x)`` for 2D input and output
  
      Args:
          constraint (function): a function ``c``, where ``x' = c(x)`` with ``x``
            and ``x'`` lists of the same length
          axis (int, default=1): index of the axis of ``x`` to apply constraints;
            must be either 0 or 1
  
      Returns:
          a function ``k``, where ``x' = k(x)`` with ``x`` and ``x'`` 2D arrays
            of the same shape
  
      Notes:
          - Produces a ``transform`` function that is of the form required by
            ``sklearn.preprocessing.FunctionTransformer(func=transform)``, and
            takes a ``numpy`` array of shape ``(samples, features)`` as input.
  
      Examples:
          >>> from mystic.constraints import (impose_bounds, integers,
          ...                                 with_mean, and_)
          >>> cons = and_(impose_bounds([(0,5),(7,10)])(lambda x:x),
          ...             integers()(lambda x:x), with_mean(6.0)(lambda x:x))
          >>> import numpy as np
          >>> data = np.random.randn(6,4)
          >>> c = vectorize(cons, axis=0)
          >>> c(data)
          array([[ 3,  9,  3, 10],
                 [ 7,  8,  7,  4],
                 [ 9,  3,  7,  7],
                 [ 7,  3,  8,  7],
                 [ 3,  5,  4,  4],
                 [ 7,  8,  7,  4]])
          >>> _.mean(axis=0)
          array([6., 6., 6., 6.])
          >>> c = vectorize(cons, axis=1)
          >>> c(data)
          array([[ 3,  3,  9,  9],
                 [ 8,  3,  4,  9],
                 [ 5, 10,  4,  5],
                 [ 7,  8,  7,  2],
                 [ 2,  4,  8, 10],
                 [ 7, 10,  5,  2]])
          >>> _.mean(axis=1)
          array([6., 6., 6., 6., 6., 6.])
          >>> k = FunctionTransformer(func=c)
          >>> k.fit(data).transform(data).mean(axis=1)
          array([6., 6., 6., 6., 6., 6.])
      """
      if not axis in (0, 1):
          msg = "axis = %s, must be either 0 or 1" % axis
          raise ValueError(msg)
      _doc = """mystic kernel transform `x' = k(x)` with x a 2D numpy array.
  
          """
      if axis:
  
          def transform(x, *args, **kwds):
              import numpy as np
  
              c = lambda x, *args, **kwds: np.array(
                  [constraint(xi, *args, **kwds) for xi in x]
              )
              return c(x, *args, **kwds)
  
      else:
  
          def transform(x, *args, **kwds):
              import numpy as np
  
              c = lambda x, *args, **kwds: np.array(
                  [constraint(xi, *args, **kwds) for xi in x.T]
              ).T
              return c(x, *args, **kwds)
  
      doc = constraint.__doc__
      transform.__doc__ = _doc + doc if doc else _doc
      return transform
  
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 1 for calling a global function with example usage: vectorize(constraint, axis) and returns: transform, c, c