<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(directory):
 """Se asegura de que un directorio exista."""

    if directory and not os.path.exists(directory):
        os.makedirs(directory)