def while_loop_condition(iteration, matrix, inactive, old_inactive): """Returns false if the while loop should terminate.""" del matrix # Needed by the body, but not the condition. not_done = (iteration < dimension) not_converged = standard_ops.reduce_any( standard_ops.not_equal(inactive, old_inactive)) return standard_ops.logical_and(not_done, not_converged)