Streaming entropy: read logits in block by block and compute the entropy (without materializing the full logits). Implement streaming_entropy(blocks), where blocks is an iterable of nonempty arrays of finite numbers partitioning one logit vector. Return the Shannon entropy of the softmax distribution as a real number. The result must be numerically stable for large-magnitude logits and must process each logit without storing all logits. For example, blocks [[0], [0]] returns ln(2), and blocks [[1000], [999]] returns approximately 0.582203. Assume at least one logit and at least one value per nonempty block.
def streaming_entropy(blocks):