<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _str_to_datetime(datestr):
 """Convert `str` to `datetime.datetime`. """

    # try known string
    try:
        return DATE_STRINGS[str(datestr).lower()]()
    except KeyError:  # any other string
        pass

    # use maya
    try:
        import maya
        return maya.when(datestr).datetime()
    except ImportError:
        pass

    # use dateutil.parse
    with warnings.catch_warnings():
        # don't allow lazy passing of time-zones
        warnings.simplefilter("error", RuntimeWarning)
        try:
            return dateparser.parse(datestr)
        except RuntimeWarning:
            raise ValueError("Cannot parse date string with timezone "
                             "without maya, please install maya")
        except (ValueError, TypeError) as exc:  # improve error reporting
            exc.args = ("Cannot parse date string {0!r}: {1}".format(
                datestr, exc.args[0]),)
            raise