<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def create_dirs(path):
 """ Creates all directories mentioned in the given path. Useful to write a new file with the specified path. It carefully skips the file-name in the given path. :param path: Path of a file or directory """

    fname = os.path.basename(path)

    # if file name exists in path, skip the filename
    if fname.__contains__('.'):
        path = os.path.dirname(path)

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