code: def additive(penalty=lambda x: 0.0, args=None, kwds=None):
      """penalize a function with another function: y = f(x) to y' = f(x) + p(x)
  
      This is useful, for example, in penalizing a cost function where the constraints
      are violated; thus, the satisfying the constraints will be preferred at every
      cost function evaluation.
  
      Examples:
          >>> def squared(x):
          ...   return x**2
          ...
          >>> # equivalent to: (x+1) + (x**2)
          >>> @additive(squared)
          ... def constrain(x):
          ...   return x+1
          ...
          >>> from numpy import array
          >>> x = array([1,2,3,4,5])
          >>> constrain(x)
          array([ 3,  7, 13, 21, 31])
      """
      if args is None:
          args = ()
      if kwds is None:
          kwds = {}
  
      def dec(f):
          def func(x, *argz, **kwdz):
              return f(x, *argz, **kwdz) + penalty(x, *args, **kwds)
  
          return func
  
      return dec
  
file_path: mystic/mystic/coupler.py
label_desc: Use image node_id 6 for calling a global function with example usage: additive(penalty, args, kwds) and returns: dec, func, unknown