<｜begin▁of▁sentence｜>### Instruction:
Given a networkx graph with 10 nodes where each node belongs to one of two communities, can you create a NodePosition instance for each node that includes the node's ID, coordinates based on the ID, size, and community label?
### Response:
import networkx as nx
from graspologic.layouts import NodePosition

# Generate a synthetic network graph
G = nx.erdos_renyi_graph(n=10, p=0.5)

# Assign community labels to each node
community_labels = {i: i % 2 for i in G.nodes()}  # Two communities (0 and 1)

# Create NodePosition instances for each node
node_positions = []
for node_id in G.nodes():
    x, y = float(node_id), float(node_id)  # Example positions based on node_id
    size = float(node_id + 1)  # Size based on node_id
    community = community_labels[node_id]
    node_position = NodePosition(node_id=str(node_id), x=x, y=y, size=size, community=community)
    node_positions.append(node_position)

# Printing node positions
for node_position in node_positions:
    print(node_position)
<|EOT|>
