<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def ensure_parent_directory(path, ensure_parent=True):
 """ Ensures the parent directory exists. :param string path: the path of the file :param bool ensure_parent: if ``True``, ensure the parent directory of ``path`` exists; if ``False``, ensure ``path`` exists :raises: OSError: if the path cannot be created """

    parent_directory = os.path.abspath(path)
    if ensure_parent:
        parent_directory = os.path.dirname(parent_directory)
    if not os.path.exists(parent_directory):
        try:
            os.makedirs(parent_directory)
        except (IOError, OSError):
            raise OSError(u"Directory '%s' cannot be created" % parent_directory)