<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _coarsegrain_space(coarse_grain, is_cut, system):
 """Spatially coarse-grain the TPM and CM."""

        tpm = coarse_grain.macro_tpm(
            system.tpm, check_independence=(not is_cut))

        node_indices = coarse_grain.macro_indices
        state = coarse_grain.macro_state(system.state)

        # Universal connectivity, for now.
        n = len(node_indices)
        cm = np.ones((n, n))

        return SystemAttrs(tpm, cm, node_indices, state)