<｜begin▁of▁sentence｜>### Instruction:
Using NetworkX, how can you construct a bipartite graph with two given degree sequences, where nodes in set A are intended to have degrees [3, 2, 1] and nodes in set B are intended to have degrees [2, 2, 2], in an alternating Havel-Hakimi style?
### Response:
import networkx as nx
from networkx.algorithms import bipartite

# Degree sequences for two partitions
aseq = [3, 2, 1]
bseq = [2, 2, 2]

# Create bipartite graph
B = bipartite.alternating_havel_hakimi_graph(aseq, bseq)

# Draw bipartite graph
pos = {node: (0 if node < len(aseq) else 1, i) for i, node in enumerate(B)}
nx.draw(B, pos=pos, with_labels=True, node_color=['red' if node < len(aseq) else 'blue' for node in B])
<|EOT|>
