<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def make_parent_dirs(path, mode=0o777):
 """ Ensure parent directories of a file are created as needed. """

  parent = os.path.dirname(path)
  if parent:
    make_all_dirs(parent, mode)
  return path