<｜begin▁of▁sentence｜>### Instruction:
Using NetworkX's karate_club_graph API, generate a JSON object that describes the graph's nodes and edges, where each node has its corresponding 'club' label and each edge has an optional 'weight' label if provided.
### Response:
import networkx as nx

# Generate Zachary's Karate Club graph
G = nx.karate_club_graph()

# Create JSON object to describe the graph
graph_description = {
    'graph_nodes': [{'id': node, 'label': G.nodes[node]['club']} for node in G.nodes()],
    'graph_edges': [{'source': u, 'target': v, 'label': G[u][v]['weight'] if 'weight' in G[u][v] else None} for u, v in G.edges()]
}

# Output the JSON object
print(graph_description)
<|EOT|>
