code: def generate_mask(cx=None, cy=None):
      """generate a data mask, based on constraints for x and/or y
  
      cx: mystic.constraint function where x' = cx(x) and x is parameter array
      cy: mystic.constraint function where [y'] = cy([y]) and y is cost array
  
      returns a masking function for (x,y) data or monitors, where
      list[bool] = mask(x,y), with True where constraints are satisfied
  
      Examples:
        >>> mon = Monitor()
        >>> mon([0.0,0.5,1.0],2)
        >>> mon([2.0,3.0,4.0],3)
        >>> mon([4.0,5.0,6.0],4)
        >>> mon([5.0,5.5,6.5],6)
        >>>
        >>> @impose_bounds((0,5))
        ... def inputs(x):
        ...   return x
        ...
        >>> generate_mask(inputs)(mon)
        [True, True, False, False]
        >>> generate_mask(y=inputs)(mon)
        [True, True, True, False]
        >>>
        >>> @integers()
        ... def identity(x):
        ...   return x
        ...
        >>> generate_mask(identity)(mon)
        [False, True, True, False]
        >>> generate_mask(y=identity)(mon)
        [True, True, True, True]
      """
  
      def func(x, z=None):
          _x = getattr(x, "_x", x)
          _y = x._y if z is None else z
          _x = _x.tolist() if hasattr(_x, "tolist") else _x
          _y = _y.tolist() if hasattr(_y, "tolist") else _y
          from numpy import ones_like
  
          res = ones_like(_y, dtype=bool)
          if cx is not None:
              res = res & [i == cx(i) for i in _x]
          if cy is not None:
              res = res & [(i,) == cy((i,)) for i in _y]
          return res.tolist()
  
      return func
  
label_desc: Use image node_id 4 for calling a global function with example usage: generate_mask(cx, cy) and returns: func, res