<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(obj, filename, fmt='auto', backend=None, **kwargs):
 """ Saves the supplied object to file. The available output formats depend on the backend being used. By default and if the filename is a string the output format will be inferred from the file extension. Otherwise an explicit format will need to be specified. For ambiguous file extensions such as html it may be necessary to specify an explicit fmt to override the default, e.g. in the case of 'html' output the widgets will default to fmt='widgets', which may be changed to scrubber widgets using fmt='scrubber'. Arguments --------- obj: HoloViews object The HoloViews object to save to file filename: string or IO object The filename or BytesIO/StringIO object to save to fmt: string The format to save the object as, e.g. png, svg, html, or gif and if widgets are desired either 'widgets' or 'scrubber' backend: string A valid HoloViews rendering backend, e.g. bokeh or matplotlib **kwargs: dict Additional keyword arguments passed to the renderer, e.g. fps for animations """

    backend = backend or Store.current_backend
    renderer_obj = renderer(backend)
    if kwargs:
        renderer_obj = renderer_obj.instance(**kwargs)
    if Path is not None and isinstance(filename, Path):
        filename = str(filename.absolute())
    if isinstance(filename, basestring):
        supported = [mfmt for tformats in renderer_obj.mode_formats.values()
                     for mformats in tformats.values() for mfmt in mformats]
        formats = filename.split('.')
        if fmt == 'auto' and formats and formats[-1] != 'html':
            fmt = formats[-1]
        if formats[-1] in supported:
            filename = '.'.join(formats[:-1])
    return renderer_obj.save(obj, filename, fmt=fmt)