<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_digraph(nx_digraph):
 """Returns a DirectedHypergraph object that is the graph equivalent of the given NetworkX DiGraph object. :param nx_digraph: the NetworkX directed graph object to transform. :returns: DirectedHypergraph -- hypergraph object equivalent to the NetworkX directed graph. :raises: TypeError -- Transformation only applicable to directed NetworkX graphs """

    import networkx as nx

    if not isinstance(nx_digraph, nx.DiGraph):
        raise TypeError("Transformation only applicable to directed \
                        NetworkX graphs")

    G = DirectedHypergraph()

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

    for edge in nx_digraph.edges_iter():
        tail_node = edge[0]
        head_node = edge[1]
        G.add_hyperedge(tail_node,
                        head_node,
                        copy.copy(nx_digraph[tail_node][head_node]))

    return G