<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(self, path, fmt=None, backend=None):
 r"""Save the graph to a file. Edge weights are stored as an edge attribute, under the name "weight". Signals are stored as node attributes, under their name in the :attr:`signals` dictionary. `N`-dimensional signals are broken into `N` 1-dimensional signals. They will eventually be joined back together on import. Supported formats are: * GraphML_, a comprehensive XML format. `Wikipedia <https://en.wikipedia.org/wiki/GraphML>`_. Supported by NetworkX_, graph-tool_, NetworKit_, igraph_, Gephi_, Cytoscape_, SocNetV_. * GML_ (Graph Modelling Language), a simple non-XML format. `Wikipedia <https://wikipedia.org/wiki/Graph_Modelling_Language>`_. Supported by NetworkX_, graph-tool_, NetworKit_, igraph_, Gephi_, Cytoscape_, SocNetV_, Tulip_. * GEXF_ (Graph Exchange XML Format), Gephi's XML format. Supported by NetworkX_, NetworKit_, Gephi_, Tulip_, ngraph_. If unsure, we recommend GraphML_. .. _GraphML: http://graphml.graphdrawing.org .. _GML: http://www.infosun.fim.uni-passau.de/Graphlet/GML/gml-tr.html .. _GEXF: https://gephi.org/gexf/format .. _NetworkX: https://networkx.github.io .. _graph-tool: https://graph-tool.skewed.de .. _NetworKit: https://networkit.github.io .. _igraph: https://igraph.org .. _ngraph: https://github.com/anvaka/ngraph .. _Gephi: https://gephi.org .. _Cytoscape: https://cytoscape.org .. _SocNetV: https://socnetv.org .. _Tulip: http://tulip.labri.fr Parameters path : string Path to the file where the graph is to be saved. fmt : {'graphml', 'gml', 'gexf', None}, optional Format in which to save the graph. Guessed from the filename extension if None. backend : {'networkx', 'graph-tool', None}, optional Library used to load the graph. Automatically chosen if None. See Also -------- load : load a graph from a file to_networkx : export as a NetworkX graph, and save with NetworkX to_graphtool : export as a graph-tool graph, and save with graph-tool Notes ----- A lossless round-trip is only guaranteed if the graph (and its signals) is saved and loaded with the same backend. Saving in other formats is possible by exporting to NetworkX or graph-tool, and using their respective saving functionality. The proposed formats are however tested for faithful round-trips. Edge weights and signal values are rounded at the sixth decimal when saving in ``fmt='gml'`` with ``backend='graph-tool'``. Examples -------- """


        if fmt is None:
            fmt = os.path.splitext(path)[1][1:]
        if fmt not in ['graphml', 'gml', 'gexf']:
            raise ValueError('Unsupported format {}.'.format(fmt))

        def save_networkx(graph, path, fmt):
            nx = _import_networkx()
            graph = graph.to_networkx()
            save = getattr(nx, 'write_' + fmt)
            save(graph, path)

        def save_graphtool(graph, path, fmt):
            graph = graph.to_graphtool()
            graph.save(path, fmt=fmt)

        if backend == 'networkx':
            save_networkx(self, path, fmt)
        elif backend == 'graph-tool':
            save_graphtool(self, path, fmt)
        elif backend is None:
            try:
                save_networkx(self, path, fmt)
            except ImportError:
                try:
                    save_graphtool(self, path, fmt)
                except ImportError:
                    raise ImportError('Cannot import networkx nor graph-tool.')
        else:
            raise ValueError('Unknown backend {}.'.format(backend))