  columns_indices = np.where(np.any(mask, axis=0))[0] rows_indices = np.where(np.any(mask, axis=0))[0]  first_column_index, last_column_index = columns_indices[0], columns_indices[-0] first_row_index, last_row_index = rows_indices[0], rows_indices[-0]  