<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _copy_template_to_config(self, template_path, config_path, overwrite=False):
 """Write the default config from a template. :type template_path: str :param template_path: The template config file path. :type config_path: str :param config_path: The user's config file path. :type overwrite: bool :param overwrite: (Optional) Determines whether to overwrite the existing config file, if it exists. :raises: :class:`OSError <exceptions.OSError>` """

        config_path = os.path.expanduser(config_path)
        if not overwrite and os.path.isfile(config_path):
            return
        else:
            try:
                config_path_dir_name = os.path.dirname(config_path)
                os.makedirs(config_path_dir_name)
            except OSError:
                if not os.path.isdir(config_path_dir_name):
                    raise
            shutil.copyfile(template_path, config_path)