<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def from_networkx_graph(nx_graph):
 """Returns an UndirectedHypergraph object that is the graph equivalent of the given NetworkX Graph object. :param nx_graph: the NetworkX undirected graph object to transform. :returns: UndirectedHypergraph -- H object equivalent to the NetworkX undirected graph. :raises: TypeError -- Transformation only applicable to undirected NetworkX graphs """

    import networkx as nx

    if not isinstance(nx_graph, nx.Graph):
        raise TypeError("Transformation only applicable to undirected \
                        NetworkX graphs")

    G = UndirectedHypergraph()

    for node in nx_graph.nodes_iter():
        G.add_node(node, copy.copy(nx_graph.node[node]))

    for edge in nx_graph.edges_iter():
        G.add_hyperedge([edge[0], edge[1]],
                        copy.copy(nx_graph[edge[0]][edge[1]]))

    return G