def linear_cx(cx, in_units, out_units, *, bias=False, trainable=True):
    """Accumulates complexity of linear into cx = (h, w, flops, params, acts)."""
    c = cx["c"]
    assert c == in_units
    cx["c"] = out_units
    cx["flops"] += in_units * out_units + (out_units if bias else 0)
    cx["params"] += in_units * out_units + (out_units if bias else 0)
    cx["acts"] += out_units
    if trainable is False:
        cx["freeze"] += in_units * out_units + (out_units if bias else 0)
    return cx