code: def _position_filter(mask):
      """generate a filter for a position mask (dict, set, or where)"""
      if mask is None:
          pairs = False  # the default format
          selector = lambda x: x
      elif type(mask) is set:
          _zip = zip
          if mask:
              from mystic.tools import _inverted
  
              _mask, pairs = _zip(*mask)
              _mask = set(_zip(_mask, _inverted(pairs)))
          else:
              _mask = mask
          pairs = True
          selector = lambda x: x - mask - _mask
      elif type(mask) is dict:
          pairs = False
          from mystic.tools import _symmetric
  
          selector = lambda x: dict(
              (k, v)
              for (k, v) in (
                  (i, j - _symmetric((mask[i] if i in mask else set())))
                  for (i, j) in x.items()
              )
              if v
          )
      else:
          from mystic.tools import _inverted
  
          _zip = zip
          _mask, pairs = mask
          mask = _mask + _mask, tuple(pairs) + tuple(_inverted(pairs))
          pairs = None  # XXX: special case, use where notation
          selector = lambda x: tuple(
              _zip(*(i for i in _zip(*x) if i not in _zip(*mask)))
          )  # FIXME: searching set would be faster
      return selector, pairs
  
file_path: mystic/mystic/collapse.py
imports: import mystic.monitors
label_desc: Use image node_id 11 for calling a global function with example usage: _position_filter(mask) and returns: selector,  pairs