<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:

def str2dict(str_in):
    '''
    Extracts a dict from a string.

    Args:
        str_in (string) that contains python dict
    Returns:
        (dict) or None if no valid dict was found
    Raises:
        -
    '''
    dict_out = safe_eval(str_in)
    if not isinstance(dict_out, dict):
        dict_out = None
    return dict_out