code: def apply_boundary_conditions_to_cm(external_indices, cm):
      
      cm = cm.copy()
      cm[external_indices, :] = 0  # Zero-out row
      cm[:, external_indices] = 0  # Zero-out columnt
      return cm
docs: Remove connections to or from external nodes.