<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def load(cls, path, fmt=None, backend=None):
 r"""Load a graph from a file. Edge weights are retrieved as an edge attribute named "weight". Signals are retrieved from node attributes, and stored in the :attr:`signals` dictionary under the attribute name. `N`-dimensional signals that were broken during export are joined. Parameters path : string Path to the file from which to load the graph. fmt : {'graphml', 'gml', 'gexf', None}, optional Format in which the graph is saved. Guessed from the filename extension if None. backend : {'networkx', 'graph-tool', None}, optional Library used to load the graph. Automatically chosen if None. Returns ------- graph : :class:`Graph` The loaded graph. See Also -------- save : save a graph to a file from_networkx : load with NetworkX then import in the PyGSP from_graphtool : load with graph-tool then import in the PyGSP Notes ----- A lossless round-trip is only guaranteed if the graph (and its signals) is saved and loaded with the same backend. Loading from other formats is possible by loading in NetworkX or graph-tool, and importing to the PyGSP. The proposed formats are however tested for faithful round-trips. 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 load_networkx(path, fmt):
            nx = _import_networkx()
            load = getattr(nx, 'read_' + fmt)
            graph = load(path)
            return cls.from_networkx(graph)

        def load_graphtool(path, fmt):
            gt = _import_graphtool()
            graph = gt.load_graph(path, fmt=fmt)
            return cls.from_graphtool(graph)

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