<｜begin▁of▁sentence｜>### Instruction:
Using the py_random_state decorator, how would you enhance a function to add random edges between non-adjacent nodes in a graph with a given probability? Assume the graph has 5 nodes (0 to 4), and you want to add edges with a probability of 0.5 using a fixed random seed (42) for reproducibility.
### Response:
import networkx as nx

@nx.utils.py_random_state("random_state")
def create_random_edges(G, p, random_state=None):
    for u, v in nx.non_edges(G):
        if random_state.rand() < p:
            G.add_edge(u, v)
    return G

# Create a graph
G = nx.Graph()
G.add_nodes_from(range(5))

# Create random edges with a probability of 0.5
create_random_edges(G, 0.5, random_state=42)

print(G.edges())
<|EOT|>
