<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def emergence(network, state, do_blackbox=False, do_coarse_grain=True, time_scales=None):
 """Check for the emergence of a micro-system into a macro-system. Checks all possible blackboxings and coarse-grainings of a system to find the spatial scale with maximum integrated information. Use the ``do_blackbox`` and ``do_coarse_grain`` args to specifiy whether to use blackboxing, coarse-graining, or both. The default is to just coarse-grain the system. Args: network (Network):
 The network of the micro-system under investigation. state (tuple[int]):
 The state of the network. do_blackbox (bool):
 Set to ``True`` to enable blackboxing. Defaults to ``False``. do_coarse_grain (bool):
 Set to ``True`` to enable coarse-graining. Defaults to ``True``. time_scales (list[int]):
 List of all time steps over which to check for emergence. Returns: MacroNetwork: The maximal macro-system generated from the micro-system. """

    micro_phi = compute.major_complex(network, state).phi

    max_phi = float('-inf')
    max_network = None

    for subsystem in all_macro_systems(network, state, do_blackbox=do_blackbox,
                                       do_coarse_grain=do_coarse_grain,
                                       time_scales=time_scales):
        phi = compute.phi(subsystem)

        if (phi - max_phi) > constants.EPSILON:
            max_phi = phi
            max_network = MacroNetwork(
                network=network,
                macro_phi=phi,
                micro_phi=micro_phi,
                system=subsystem.micro_node_indices,
                time_scale=subsystem.time_scale,
                blackbox=subsystem.blackbox,
                coarse_grain=subsystem.coarse_grain)

    return max_network