<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def save_model(model, output_file=None, output_dir=None, output_prefix='pymzn'):
 """Save a model to file. Parameters model : str The minizinc model (i.e. the content of a ``.mzn`` file). output_file : str The path to the output file. If this parameter is ``None`` (default), a temporary file is created with the given model in the specified output directory, using the specified prefix. output_dir : str The directory where to create the file in case ``output_file`` is None. Default is ``None``, which creates a file in the system temporary directory. output_prefix : str The prefix for the output file if created. Default is ``'pymzn'``. Returns ------- str The path to the newly created ``.mzn`` file. """

    if output_file:
        mzn_file = output_file
        output_file = open(output_file, 'w+', buffering=1)
    else:
        output_prefix += '_'
        output_file = NamedTemporaryFile(
            dir=output_dir, prefix=output_prefix, suffix='.mzn', delete=False,
            mode='w+', buffering=1
        )
        mzn_file = output_file.name

    output_file.write(model)
    output_file.close()

    logger.info('Generated file {}'.format(mzn_file))
    return mzn_file