<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def apply_boundary_conditions_to_cm(external_indices, cm):
 """Remove connections to or from external nodes."""

    cm = cm.copy()
    cm[external_indices, :] = 0  # Zero-out row
    cm[:, external_indices] = 0  # Zero-out columnt
    return cm