def METHOD_NAME(s):
    ref_text = s
    identifier = s
    ref_type = "class"
    try:
        obj = None
        parent_obj = None
        exec("obj = {}".format(s))
        exec("parent_obj = {}".format(s.rsplit(".", 1)[0]))
        if getattr(obj, "__file__", None):
            ref_type = "mod"
        elif callable(obj) and getattr(parent_obj, "__module__", None):
            ref_type = "meth"
        elif getattr(obj, "__module__", None):
            ref_type = "class"
    except:
        pass
    return ":py:{}:`{} <{}>`".format(ref_type, ref_text, identifier)