def _check_convergence(simplex,<EOL>best_vertex,<EOL>best_objective,<EOL>worst_objective,<EOL>func_tolerance,<EOL>position_tolerance):
objective_convergence = tf.abs(worst_objective -<EOL>best_objective) < func_tolerance<EOL>simplex_degeneracy = tf.reduce_max(<EOL>input_tensor=tf.abs(simplex - best_vertex)) < position_tolerance<EOL>return objective_convergence | simplex_degeneracy<EOL>
Returns True if the simplex has converged.

    If the simplex size is smaller than the `position_tolerance` or the variation
    of the function value over the vertices of the simplex is smaller than the
    `func_tolerance` return True else False.

    Args:
      simplex: `Tensor` of real dtype. The simplex to test for convergence. For
        more details, see the docstring for `initial_simplex` argument
        of `minimize`.
      best_vertex: `Tensor` of real dtype and rank one less than `simplex`. The
        vertex with the best (i.e. smallest) objective value.
      best_objective: Scalar `Tensor` of real dtype. The best (i.e. smallest)
        value of the objective function at a vertex.
      worst_objective: Scalar `Tensor` of same dtype as `best_objective`. The
        worst (i.e. largest) value of the objective function at a vertex.
      func_tolerance: Scalar positive `Tensor`. The tolerance for the variation
        of the objective function value over the simplex. If the variation over
        the simplex vertices is below this threshold, convergence is True.
      position_tolerance: Scalar positive `Tensor`. The algorithm stops if the
        lengths (under the supremum norm) of edges connecting to the best vertex
        are below this threshold.

    Returns:
      has_converged: A scalar boolean `Tensor` indicating whether the algorithm
        is deemed to have converged.