code: def _weight_filter(mask):
      """generate a filter for a weight mask (dict, set, or where)"""
      if mask is None:
          pairs = False  # the default format
          selector = lambda x: x
      elif type(mask) is set:
          pairs = True
          selector = lambda x: x - mask
      elif type(mask) is dict:
          pairs = False
          selector = lambda x: dict(
              (k, v)
              for (k, v) in (
                  (i, j - (mask[i] if i in mask else set()))
                  for (i, j) in x.items()
              )
              if v
          )
      else:
          _zip = zip
          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 10 for calling a global function with example usage: _weight_filter(mask) and returns: selector,  pairs