<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def all_macro_systems(network, state, do_blackbox=False, do_coarse_grain=False, time_scales=None):
 """Generator over all possible macro-systems for the network."""

    if time_scales is None:
        time_scales = [1]

    def blackboxes(system):
        # Returns all blackboxes to evaluate
        if not do_blackbox:
            return [None]
        return all_blackboxes(system)

    def coarse_grains(blackbox, system):
        # Returns all coarse-grains to test
        if not do_coarse_grain:
            return [None]
        if blackbox is None:
            return all_coarse_grains(system)
        return all_coarse_grains_for_blackbox(blackbox)

    # TODO? don't consider the empty set here
    # (pass `nonempty=True` to `powerset`)
    for system in utils.powerset(network.node_indices):
        for time_scale in time_scales:
            for blackbox in blackboxes(system):
                for coarse_grain in coarse_grains(blackbox, system):
                    try:
                        yield MacroSubsystem(
                            network, state, system,
                            time_scale=time_scale,
                            blackbox=blackbox,
                            coarse_grain=coarse_grain)
                    except (StateUnreachableError,
                            ConditionallyDependentError):
                        continue