<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def mf(pred, props=None, value_fn=None, props_on_match=False, priority=None):
 """ Matcher factory. """


    if isinstance(pred, BaseMatcher):
        ret = pred if props_on_match else pred.props

    if isinstance(pred, basestring) or \
       type(pred).__name__ == 'SRE_Pattern':
        ret = RegexMatcher(pred, props=props, value_fn=value_fn)

    if isinstance(pred, set):
        return OverlayMatcher(pred, props=props, value_fn=value_fn)

    if isinstance(pred, list):
        deps = [p for p in pred if isinstance(p, BaseMatcher)]
        ret = ListMatcher([mf(p, props_on_match=True) for p in pred],
                          props=props, value_fn=value_fn,
                          dependencies=deps)

    if priority is not None:
        ret.priority = priority

    return ret