<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def write_config(config, config_path=CONFIG_PATH):
 """Write the config to the output path. Creates the necessary directories if they aren't there. Args: config (configparser.ConfigParser):
 A ConfigParser. """

    if not os.path.exists(config_path):
        os.makedirs(os.path.dirname(config_path))
    with open(config_path, 'w', encoding='utf-8') as f:
        config.write(f)