code: def valfilter(predicate, d, factory=dict):
      """Filter items in dictionary by value
  
      >>> iseven = lambda x: x % 2 == 0
      >>> d = {1: 2, 2: 3, 3: 4, 4: 5}
      >>> valfilter(iseven, d)
      {1: 2, 3: 4}
  
      See Also:
          keyfilter
          itemfilter
          valmap
      """
      rv = factory()
      for k, v in d.items():
          if predicate(v):
              rv[k] = v
      return rv
  
imports: import collections
  import operator
  from functools import reduce
  from collections.abc import Mapping
label_desc: Use image node_id 7 for calling a global function with example usage: valfilter(predicate, d, factory) and returns: rv