<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_dir_exists(path):
 """Ensure a directory exists."""

    if not op.exists(path):
        os.makedirs(path)
    assert op.exists(path) and op.isdir(path)